lsyf8 发表于 2018-12-17 10:29:23

yum安装nginx+php环境

  安装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;
  indexindex.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_indexindex.php;
  # fastcgi_paramSCRIPT_FILENAME/scripts$fastcgi_script_name;
  #对照,注意修改,使用绝对路径
  fastcgi_paramSCRIPT_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
                                 chkconfignginx 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 "" > ./index.php
                          从新打开网页出现php详细的信息,nginx+php配置完成。



页: [1]
查看完整版本: yum安装nginx+php环境