1分钟完美安装最新 CentOS + Nginx + PHP-FPM + MySQL
?? ? ? ? ? ? '$status $body_bytes_sent "$http_referer" '
?? ? ? ? ? ? '"$http_user_agent" $http_x_forwarded_for';
?? ? ? ?access_log? /www/logs/access.log? access;
?? ?}
?? ?server {
?? ? ? ?listen 80;
?? ? ? ?server_name www.21andy.com 21andy.com *.21andy.com;
?? ? ? ?root? /www/21andy.com;
?? ? ? ?if ($host !~* 21andy\.com$) {
?? ? ? ? ? ?return 444;
?? ? ? ?}
?? ? ? ?location / {
?? ? ? ? ? ?try_files $uri $uri/ /index.php?q=$uri&$args;
?? ? ? ?}
?? ? ? ?include server.conf; # 这里复用了,这段就省了
?? ? ? ?access_log? /www/logs/21andy.com_access.log? access;
?? ?}
}
# vi /etc/nginx/server.conf
index index.html index.htm index.php;#limit_conn? ?crawler? 20;
location ~ /\.ht {
?? ?deny all;
}
location ~ .*\.(sqlite|sq3)$ {
?? ?deny all;
}
location ~ .*\.php$ {
?? ?fastcgi_pass? unix:/tmp/php-cgi.sock;
?? ?#fastcgi_pass? 127.0.0.1:9000;
?? ?fastcgi_index index.php;
?? ?include fastcgi_params;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|ico)$ {
?? ?expires? ? ? 30d;
?? ?access_log? ?off;
}
location ~ .*\.(js|css)?$ {
?? ?expires? ? ? 30d;
?? ?access_log? ?off;
}
本行以下内容可以略过
php-fpm 也可以用以下设置,但建议用上面的,比较稳定
?? ?root? ? ? ? ? ?/www;
?? ?fastcgi_pass? ?127.0.0.1:9000;
?? ?fastcgi_index? index.php;
?? ?#下面这一行要加在 /etc/nginx/fastcgi_params 里
?? ?#fastcgi_param? SCRIPT_FILENAME? $document_root$fastcgi_script_name;
?? ?include? ? ? ? fastcgi_params;
}
不管是使用 php-cgi.sock 或 9000 端口方法,nginx 和 php-fpm 都要同时设置成一样的
nginx 的设置上面已经提过,记得同时修改 php-fpm.conf 相应的地方
# vi /etc/php-fpm.conf
或
<value name="listen_address">unix:/tmp/php-cgi.sock</value>Tags: centos, mysql, nginx, php-fpm, RPM, 安装
本文地址: http://www.21andy.com/blog/20100219/1701.html