安装
在ubuntu 10.10里面还没有专门的fastcgi包,必须通过lighttp里面附带的fastcgi加上自定义的脚本来启动fastcgi进程。但是在ubuntu 11.10里面有了一个php5-fpm的包专门用来处理fastcgi,免去了自己倒腾脚本的麻烦。把这一堆包装上安装就算是完事了:
1 | sudo apt-get install nginx php5 php5-fpm mysql-server mysql-client |
配置
配置也很简单,直接在/etc/nginx/sites-avalable里面添加一个自己的配置文件,然后创建一个到/etc/nginx/sites-enabled/的软链接即可:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | server { listen 80; ## listen for ipv4; this line is default and implied root /path/to/root/; index index.php index.html index.htm; # Make site accessible from http://localhost/ server_name _; location / { # 找不到页面的时候返回到index.html try_files $uri $uri/ /index.html; } # 将错误页面重定向到制定的文件 error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/www; } # 处理php文件 location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi_params; # 在使用wordpress必须要有这个rewrite,否则访问rss的时候会出现404错误 if( !-e $request_filename) { rewrite ^/wordpress/(.+)$ /wordpress/index.php?q=$1 last; } } |






近期评论