01 Jan 2011

在ubuntu上配置 nginx和php+fastcgi

(1)安装php5
apt-get install php5 php-pear php5-cli php5-common php5-xcache php5-cgi php5-mysql php5-curl  php5-gd  php5-imagick  php5-xmlrpc  php5-dev php5-memcache
(2)安装nginx
apt-get install nginx
(3)安装spawn-fcgi
 apt-get install spawn-fcgi
(4)设置,也是最头疼滴地方哦

在/etc/nginx/fastcgi_params 文件最后,加入一行,可以用sudo gedit /etc/nginx/fastcgi_params打开文件
fastcgi_param SCRIPT_FILENAME     $document_root$fastcgi_script_name;
设置php.ini的 cgi.fix_pathinfo=1;doc_root=
拷贝/etc/nginx/sites-availab修改本机hosts文件,指定一个域名
修改server_name
在server_name同级增加root 设置为网站根目录
location里 加上 index.php
php的fast-cgi配置

    location ~ \.php$ {
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        include fastcgi_params;     
    }

$ sudo killall -HUP php5-cgi
$ sudo /usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -C 5 -u www-data -g www-data -f /usr/bin/php5-cgi -P /var/run/fastcgi-php.pid
$ /etc/init.d# sudo /etc/init.d/nginx restart 
在网站内放个phpinfo测试一下,ok了。

24 Jul 2010

在centos上装rubyee,passenger和memcached ,搭建rails环境

流水笔记一则.

我之前已在服务器配置了nginx,php,mysql等,现在先安装ruby企业版

cd /tmp
wget http://rubyforge.org/frs/download.php/71096/ruby-enterprise-1.8.7-2010.02.tar.gz
tar -xzvf ruby-enterprise-1.8.7-2010.02.tar.gz
cd ruby-enterprise-1.8.7-2010.02
./installer

然后按照提示做

设置一下环境变量 
export PATH=/rubyee/bin:$PATH
接着
ruby -v
gem -v
看到版本号,说明rubyee 安装ok

下来
gem install passenger
passenger-install-nginx-module

按照提示在nginx配置文件里增加:

http {
     ...
     passenger_root /rubyee/lib/ruby/gems/1.8/gems/passenger-2.2.14;
     passenger_ruby /rubyee/bin/ruby;
     ...
}

  server {
     listen 80;
     server_name www.yourhost.com;
     root /somewhere/public;   # <--- be sure to point to 'public'!
     passenger_enabled on;
  }

rails 欧了~

下来开始装 memcached,

memcached 的使用需要libeven的支持

cd /tmp
wget http://www.monkey.org/~provos/libevent-1.4.14a-stable.tar.gz
tar -zxvf libevent-1.4.14a-stable.tar.gz
cd libevent-1.4.14-stable
./configure --prefix=/usr
make && make install

cd /tmp
wget http://memcached.org/latest
tar -zxvf memcached-1.4.5.tar.gz
cd memcached-1.4.5
./configure --prefix=/usr/local
make && make install

 现在可以用
service memcached start  


  service memcached stop  

这两个很骚的命令来管理memcached服务了,欧了~

安装mysql gem
gem install --no-rdoc --no-ri mysql -- --with-mysql-dir=/usr/local/mysql --with-mysql-config=/usr/local/mysql/bin/mysql_config

安装 ImageMagick

wget ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick.tar.gz
tar xvfz ImageMagick.tar.gz
cd ImageMagick*
./configure --disable-static --with-modules --with-gs-font-dir=/usr/share/fonts/type1/gsfonts
make
sudo make install
cd ..
rm -Rf ImageMagick*

wget http://rubyforge.org/frs/download.php/70067/RMagick-2.13.1.tar.bz2
tar -jxf RMagick-2.13.1.tar.bz2
cd RMagick*
./configure --disable-static --with-modules --without-perl --without-magick-plus-plus --with-jpeg=yes --with-png=yes --with-tiff=yes --with-quantum-depth=8  --with-gs-font-dir=/usr/share/fonts/type1/gsfonts
ruby setup.rb
ruby setup.rb install
cd ..
rm -Rf RMagick*

最后 上传 rails 程序
接着 rake gems:install

centos安装rmagick出现以下错误:
libMagickCore.so.2: cannot open shared object file: No such file or directory – /usr/lib/ruby/gems/1.8/gems/rmagick-2.8.0/lib/RMagick2.so
解决办法:

ldconfig /usr/local/lib

错误[memcache-client] Could not load SystemTimer gem, falling back to Ruby's slower/unsafe timeout library: no such file to load -- system_timer
rake aborted!

sudo gem install system_timer

Magick::ImageMagickError (unable to read font `/usr/local/lib/ImageMagick-6.6.3/config//usr/share/fonts/type1/gsfonts/n019003l.pfb' @ error/annotate.c/RenderFreetype/1056: `(null)'):
错误

wget http://sourceforge.net/projects/gs-fonts/files/gs-fonts/8.11%20%28base%2035%2C%20GPL%29/ghostscript-fonts-std-8.11.tar.gz/download
 tar -zxvf ghostscript-fonts-std-8.11.tar.gz
解压后拷贝到需要的目录

09 Jul 2009

nginx下typecho的rewrite

导数据到typecho的时候是在localhost的windows xp系统上用的apache,部署时用的是nginx
先是发现无法登陆按照这篇帖子内的方法配置了vhost.conf,发现可以登陆了,接着又出现了
无法编辑post的问题,具体症状见这篇帖子,甚是郁闷啊,google+baidu 找到一片描写wp的
rewrite的帖子,因typecho与wp笔记像,抱着试试看的想法,在测试站点试验了一下,嘿嘿
能用,转寄在此,备忘

location / {
        index index.html index.php;
        if (-f $request_filename/index.html){
            rewrite (.*) $1/index.html break;
        }
        if (-f $request_filename/index.php){
            rewrite (.*) $1/index.php;
        }
        if (!-f $request_filename){
            rewrite (.*) /index.php;
        }
    }

同时感谢Atlantis  :-)