首页 > Web开发 > 详细

yum安装nginx+php环境

时间:2016-03-04 19:28:37      阅读:179      评论:0      收藏:0      [点我收藏+]

安装nginx+php环境:

    1、使用yum安装nginx,php,php-fpm

        yum install nginx php-fpm php

    2、配置nginx的配置文件:

        vim /etc/nginx/conf.d/default.conf

        修改如下位置:

        location / {

                root   /usr/share/nginx/html;

                index  index.html index.htm index.php;//添加

               }

    3、设置nginx对php的支持:

         vim /etc/nginx/conf.d/default.conf

        修改:(去掉前面的“#”注释)      

    location ~ \.php$ {

        root           html;

        fastcgi_pass   127.0.0.1:9000;

        fastcgi_index  index.php;

       # fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;

      #对照,注意修改,使用绝对路径

     fastcgi_param  SCRIPT_FILENAME  /usr/share/nginx/html$fastcgi_script_name;

        include        fastcgi_params;

    }

    4、设置php-fpm的配置:

         vim /etc/php-fpm.d/www.conf

        修改:

    ; RPM: apache Choosed to be able to access some dir as httpd

          ;user = apache

        user = nginx

    ;设置为nginx用户,这样nginx可以使用。

    ; RPM: Keep a group allowed to write in log dir.

    ;同理设置成nginx组

        ;group = apache

        group = nginx

    5、设置开机自启动:

          chkconfig php-fpm on

                               chkconfig  nginx on

                 6、启动服务:

                                 /etc/init.d/nginx start

                                 /etc/init.d/php-fpm start

                         或:

                                service php-fpm start

                                service mysqld start

                7、测试:

                        浏览器直接输入IP地址出现nginx欢迎界面,nginx安装成功

                        删除主页文件,自己加入phpinfo()函数测试

                        cd  /usr/share/nginx/html/

                         rm -f ./index.html

                        echo "<?php phpinfo(); ?>" > ./index.php

                        从新打开网页出现php详细的信息,nginx+php配置完成。

yum安装nginx+php环境

原文:http://heheyue.blog.51cto.com/11245910/1747614

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!