ubuntu 下安装 nginx+php5.3
环境说明:
Ubuntu 11.10
nginx 1.0.5
php5.3.6
1. 安装nginx
打开 /etc/apt/sources.list 文件,在该文件末尾增加如下内容:
##nginx
deb http://nginx.org/packages/ubuntu/ lucid nginx
deb-src http://nginx.org/packages/ubuntu/ lucid nginx
命令行安装nginx:
sudo apt-get install nginx
2. 命令行安装php5
sudo apt-get install php5
sudo apt-get install php5-cgi php5-fpm
3. nginx 和 php5(fastcgi) 都装好了以后将他们关联起来
创建fcgi.conf配置文件,内容如下:
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;
nginx 配置如下:
。。。
server {
listen 80;
server_name t.pw.com;
index index.html index.php index.htm;
root /var/www;
location ~.*\.(php|php5)?$ {
# index index.html index.php index.htm;
# root /var/www;
fastcgi_pass 127.0.0.1:9900;
fastcgi_index index.php;
include conf.d/fcgi.conf;
}
}
。。。
默认fastcgi启动监听端口为9000,这里因为和zendstudio中的xdebug冲突了,所以修改为9900端口。
4. 启动系统时默认启动nginx,php
打开 /etc/rs.local 添加如下内容
1 /etc/init.d/php-fpm start
2 /etc/init.d/nginx start
http://hi.baidu.com/hy0kl/blog/item/5327ea13dcf292095aaf531e.html
http://www.blogjava.net/daniel-tu/archive/2008/12/29/248883.html
http://wiki.nginx.org/NginxChs
http://blog.s135.com/nginx_php_v6/