繁体   English   中英

多项目文件夹的Nginx配置

Nginx configuration for multi-project folders

提示:本站收集StackOverFlow近2千万问答,支持中英文搜索,鼠标放在语句上弹窗显示对应的参考中文或英文, 本站还提供   中文繁体   英文版本   中英对照 版本,有任何建议请联系yoyou2525@163.com。

我正在尝试为位于不同文件夹中的多项目php设置nginx配置文件。 我的生产服务器中有以下配置文件。

server {
    listen 80;

    error_log /LOGS/ardu_error.log debug;
    access_log /LOGS/ardu_access.log;

    set $applicationEnv "production";

    location ~ /ardu-component/ {
        root /srv/www/ardu-component/;

        try_files $uri /index.php$is_args$args;
    }

    location ~ ^/index\.php(/|$) {
        # the ubuntu default
        fastcgi_pass   127.0.0.1:9000;

        fastcgi_split_path_info ^(.+\.php)(/.*)$;
        include fastcgi_params;

        fastcgi_param APPLICATION_ENV $applicationEnv;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param HTTPS off;
    }

    #return 404 for all php files as we do have a front controller
    location ~ \.php$ {
        return 404;
    }
}
server {
    listen 80;

    error_log /LOGS/ardu_error.log debug;
    access_log /LOGS/ardu_access.log;

    set $applicationEnv "production";

    location ~ /ardu-component/ {
        root /srv/www/ardu-component/;

        try_files $uri /index.php$is_args$args;
    }

    location ~ ^/index\.php(/|$) {
        # the ubuntu default
        fastcgi_pass   127.0.0.1:9000;

        fastcgi_split_path_info ^(.+\.php)(/.*)$;
        include fastcgi_params;

        fastcgi_param APPLICATION_ENV $applicationEnv;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param HTTPS off;
    }

    #return 404 for all php files as we do have a front controller
    location ~ \.php$ {
        return 404;
    }
}

我打开浏览器,尝试连接到/ ardu-component /,但从nginx收到“ File not found错误。

在nginx调试日志中,我看到以下信息。 它似乎可以很好地解析位置和内容,但最终位于/usr/share/nginx...而我没有在conf中进行配置。 我不是开发者,所以我不知道该如何解决。

2019/09/18 23:14:21 [debug] 2720#2720:* 4 http脚本var:“ / ardu-component /” 2019/09/18 23:14:21 [debug] 2720#2720:* 4试用使用文件:“ / ardu-component /”“ / srv / www / ardu-component / ardu-component /” 2019/09/18 23:14:21 [调试] 2720#2720:* 4 http脚本副本:“ /index.php“ 2019/09/18 23:14:21 [debug] 2720#2720:* 4 http脚本var:”“ 2019/09/18 23:14:21 [debug] 2720#2720:* 4试用使用文件:“ / index.php”“ / srv / www / ardu-component / index.php” 2019/09/18 23:14:21 [调试] 2720#2720:* 4内部重定向:“ / index。 PHP?” 2019/09/18 23:14:21 [调试] 2720#2720:* 4重写阶段:1 ... 2019/09/18 23:14:21 [调试] 2720#2720:* 4 http脚本var:“ / usr / share / nginx / html“ 2019/09/18 23:14:21 [debug] 2720#2720:* 4 http脚本var:” /index.php“ 2019/09/18 23:14:21 [debug ] 2720#2720:* 4 fastcgi参数:“ SCRIPT_FILENAME:/usr/share/nginx/html/index.php” 2019/09/18 23:14:21 [debug] 2720#2720:* 4 HTTP脚本副本:“ HTTPS“ 2019/09/18 23:14:21 [debug] 2720#2720:* 4 http脚本副本:” off“ 2019/09/18 23:14:21 [debug] 2720#2720:* 4 fastcgi param: “ HTTPS:关闭”

提前致谢。

1 个回复

首先,如果server_name,您的本地主机,设置本地主机

第二个设置您的/ srv / www

server {  
     location ~ /\. { deny  all; }
    listen *:80 ;       
     server_name   localhost     ;
      root   /srv/www;


    location / {root   /srv/www/;




                    index  index.htm  index.html  index.php;
    }



   location ^~ /ardu-component {    
        try_files $uri /index.php$is_args$args;
    }


        location ~ ^/.+\.php {
              fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME /home/lecad/public_html/$fastcgi_script_name;
                    fastcgi_param PATH_INFO $fastcgi_script_name;
    fastcgi_param PHP_ADMIN_VALUE "open_basedir=\"/srv/www/:/tmp:/usr/local/lib/php:\"
    include_path=\"/usr/lib/php:/usr/local/lib/php:/tmp:/srv/www/\"";
               include /etc/nginx/fastcgi_params;
            }}  

如果那不起作用,请尝试

更新

try_files $uri /index.php$is_args$args;

try_files /ardu-component/$uri /ardu-component/index.php$is_args$args;

希望对您有帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题
 
粤ICP备18138465号  © 2020-2022 STACKOOM.COM