linux服务器使用yum安装nginx

一,安装nginx和php-fpm

  yum install nginx php-fpm

 

二, 找到nginx.conf

  find / -name nginx.conf

 

三,添加解析php配置

   在server{}中添加如下来解析php

  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  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }

 

四,nginx / php-fpm启动/停止

  nginx -s stop #停止nginx

  nginx -c  /etc/nginx/nginx.conf #启动nginx

  systemctl restart php-fpm.service #重启php-fpm

 

  查看开机自启列表

  systemctl list-unit-files|grep enabled

  systemctl enable nginx.service #开机自启nginx

  systemctl enable php-fpm.service #开机自启php-fpm

 

五.配置多域名( * 如果不配置的话就略过此步骤)

  1,nginx.conf底部添加引用多个域名配置

     include /etc/nginx/vhost/*

  2.将server{}中间的内容复制并注释掉,在vhost目录中新建一个www.****.com.conf文件, 同时将复制的内容粘贴到该.conf文件中

  3.同理,若要配置二级域名或者多域名,就将2生成的文件复制一份并重命名

    4.nginx重启即可

   

posted on 2017-11-23 14:43  转身的猫  阅读(244)  评论(0编辑  收藏  举报

导航