Centos7下nginx1.12.2配置

---恢复内容开始---

1.更新yum源 yum update,下载最新nginx版本 yum install nginx

2.安装完成nginx后,访问服务器,可以观察到 welcometo nginx,这说明已经安装成功了

3.试着访问服务器的文件,发现访问不到, 一直下载该php文件

4.解决不能访问php文件的方法是

  location / {
        index index.html index.htm index.php;
        charset utf-8;

       }

        location ~ \.php$ {
           # root          html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param SCRIPT_FILENAME /var/www/html$fastcgi_script_name;


            include        fastcgi_params;
        }

4.1:这里先要查看9000端口是否在工作 netstat -antp 查看,如果没有发现9000端口, 那就开启该端口php-cgi -b 127.0.0.1:9000 &  这时候,再次查看下,90000端口已经在工作了

5.这时候再次访问php文件,发现可以访问了, 但是又一个问题出现了(路由,访问路口文件如index.php可以出来,但是一添加模块和控制器就变成404了)

6先不管路由,先配置虚拟主机(一个虚拟主机 也就是一个server),登录阿里云 ,解析一个二级域名, 再将

server {
        listen       80;
        server_name  wx.gdlearn.com;
        root         /usr/share/nginx/html;

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;


        location / {
        index index.html index.htm index.php;

       }

    }

  添加到nginx.conf配置文件里面去

注意:安装nginx的时候要安装php-fpm

 

---恢复内容结束---

1.更新yum源 yum update,下载最新nginx版本 yum install nginx

2.安装完成nginx后,访问服务器,可以观察到 welcometo nginx,这说明已经安装成功了

3.试着访问服务器的文件,发现访问不到, 一直下载该php文件

4.解决不能访问php文件的方法是

  location / {
        index index.html index.htm index.php;
        charset utf-8;

       }

        location ~ \.php$ {
           # root          html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param SCRIPT_FILENAME /var/www/html$fastcgi_script_name;


            include        fastcgi_params;
        }

4.1:这里先要查看9000端口是否在工作 netstat -antp 查看,如果没有发现9000端口, 那就开启该端口php-cgi -b 127.0.0.1:9000 &  这时候,再次查看下,90000端口已经在工作了

5.这时候再次访问php文件,发现可以访问了, 但是又一个问题出现了(路由,访问路口文件如index.php可以出来,但是一添加模块和控制器就变成404了)

6先不管路由,先配置虚拟主机(一个虚拟主机 也就是一个server),登录阿里云 ,解析一个二级域名, 再将

server {
        listen       80;
        server_name  wx.gdlearn.com;
        root         /usr/share/nginx/html;

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;


        location / {
        index index.html index.htm index.php;

       }

    }

  添加到nginx.conf配置文件里面去

注意:安装nginx的时候要安装php-fpm

 

posted @ 2018-03-02 13:32  咣咚咣咚  阅读(317)  评论(1)    收藏  举报