美文网首页
centos 7 上nginx安装多个Laravel

centos 7 上nginx安装多个Laravel

作者: Martain | 来源:发表于2018-06-04 21:04 被阅读10次

1、单个Laravel 的 nginx 配置

cd /etc/nginx/
vim nginx.conf
 ...
server {
        listen       80;
        server_name  localhost;
        add_header      X-Frame-Options "SAMEORIGIN";
        add_header      X-XSS-Protection "1,mode=block";
        add_header      X-Content-Type-Options "nosniff";
        index index.html index.htm index.php;
        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.html index.htm index.php;
            try_files $uri $uri/ /index.php?$query_string;
        }

        error_page  404              /index.php;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        location ~ \.php$ {
            root           html;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        location ~ /\.ht {
            deny  all;
        }

    }
       include /etc/nginx/conf.d/*.conf;  #加载其他的配置文件
...

2、为每一个Laravel创建单独的配置文件,在conf.d文件加下创建一个监听8088端口的服务

server{

    listen 8088;
    server_name Lar;

    location / {
            root   html/Lar/public;
            index  index.html index.htm index.php;
            try_files $uri $uri/ /index.php?$query_string;
        }

     location ~ \.php$ {
            root           html/Lar/public;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }

}

相关文章

网友评论

      本文标题:centos 7 上nginx安装多个Laravel

      本文链接:https://www.haomeiwen.com/subject/mgsysftx.html