2. yum -y install nginx
3. service nginx restart
看到 WELCOME TO NGINX 说明安装成功!
4.yum -y install php-fpm
5.让nginx支持 php-fpm
找到/etc/nginx/conf.d/default.conf,打开编辑它
>vi /etc/nginx/conf.d/default.conf
去掉下面部分的注释用于支持php 脚本:
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
其中:
fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name;
/usr/share/nginx/html指你的网站目录
include /etc/nginx/fastcgi_params;
/etc/nginx/fastcgi_params; 要确保找对文件地址
6.
重启nginx服务
>/etc/init.d/nginx stop
>/etc/init.d/nginx start
启动php-fpm
>/usr/local/sbin/php-fpm
建立php测试文件
vi phpinfo.php
其内容:
<?php
phpinfo();
?>
浏览http://(你机器的ip地址)/phpinfo.php
如果出一个php的特色标志页面,就说明安装成功了。