/usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -u nginx -g nginx -f /usr/bin/php-cgi -P /var/run/fastcgi-php.pid当然,你不想在键入该命令时手动启动系统,使系统在开机时自动执行命令,打开/etc/rc.local:
vi /etc/rc.local在文件没为加入如下内容:
/usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -u nginx -g nginx -f /usr/bin/php-cgi -P /var/run/fastcgi-php.pid
配置nginx的:vi /etc/nginx/nginx.conf
配置是很容易理解
改变一下内容:
[...]
worker_processes 5;
[...]
keepalive_timeout 2;
[...]
虚拟主机配置。让我们如下修改默认的虚拟主机 :
[...]
server {
listen 80;
server_name _;#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root /usr/share/nginx/html;
index index.php index.html index.htm;
}error_page 404 /404.html;
location = /404.html {
root /usr/share/nginx/html;
}# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root /usr/share/nginx/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name;
include fastcgi_params;
}# deny access to .htaccess files, if Apache’s document root
# concurs with nginx’s one
#
location ~ /\.ht {
deny all;
}
}
[...]
现在保存文件,重新启动nginx的:
/etc/init.d/nginx restart
创建一个探针文件:info.php,看看那些模块正常运行了vi /usr/share/nginx/html/info.php
内容如下:
<?php
phpinfo();
?>
把双引号改为英文半角输入的单引号。
然后浏览器输入:http://192.168.0.100/info.php查看运行结果:
继续往下浏览,看看MYSQL运行情况:
相关软件连接:
- nginx: http://nginx.net/
- nginx Wiki: http://wiki.codemongers.com/Main
- PHP: http://www.php.net/
- MySQL: http://www.mysql.com/
- CentOS: http://www.centos.org/
