nginx设置

打开目录  /etc/nginx/nginx.conf

1.重定向

server {
      server_name localhost
      listen 80;
     
      location / {
        rewrite ^(.*)$  https://fengnovo.github.io/ last;
      }
}

2.反向代理

server {
      server_name localhost
      listen 80;
     
      location / {
        proxy_pass http://127.0.0.1:8000;
      }
}

 3.设置root目录

server {
      server_name localhost
      listen 80;
      root /var/www/html;
      index index.php index.html index.htm;

     
      location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/run/php/php7.0-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
      }

}
root /var/www/html;  apache默认的根目录在/var/www/html下
即只要在
/var/www/html目录下新建php目录并新建index.php,就可以在xxx.xxx.xxx.xxx/php访问到php目录下的index.php
Reference:
https://www.cnblogs.com/zqunor/p/8524646.html
posted @ 2018-10-03 21:01  fengnovo  阅读(119)  评论(0编辑  收藏  举报