php 应用程序的 Nginx 子目录

php 应用程序的 Nginx 子目录

我知道网上有很多关于此问题的答案,但是我尝试了很多设置,但都没有用。

我想做的事 :

  • 通过 IP/doc 访问位于 /var/www/doc 的 PHP 应用程序

我不想破坏的是:

  • RuTorrent 位于 /var/www/rutorrent

我的实际设置:

  • Debian 9 上的 Nginx 与 PHP 7.3

实际设置:

server {
    listen 80 default_server;
    server_name _;

    charset utf-8;
    index index.html index.php;
    client_max_body_size 10M;

    access_log /var/log/nginx/rutorrent-access.log combined;
    error_log /var/log/nginx/rutorrent-error.log error;

    error_page 500 502 503 504 /50x.html;

    auth_basic "seedbox";
    auth_basic_user_file "/etc/nginx/passwd/rutorrent_passwd";

    root /var/www;

    location ^~ /doc {
        alias   /doc/public;
        index  index.php;

        location ~ \.php$ {
            fastcgi_pass   127.0.0.1:9000;
            include        fastcgi_params;
            fastcgi_param  SCRIPT_FILENAME $request_filename;
        }
    }

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

    location = /50x.html {
        root /usr/share/nginx/html;
    }

    location = /favicon.ico {
        access_log off;
        log_not_found off;
    }

    location /rutorrent {
        try_files $uri $uri/ /index.html;
    }

    location ~ ^/rutorrent/(conf|share)/(.+)$ {
        deny all;
    }

    location ~ \.php$ {
        fastcgi_index index.php;
        include /etc/nginx/fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_pass unix:/run/php/php7.3-fpm.sock;
    }

    location ~* \.(jpg|jpeg|gif|css|png|js|map|woff|woff2|ttf|svg|eot)$ {
        expires 30d;
        access_log off;
    }

    location = /CASPER {
        include scgi_params;
        scgi_pass 127.0.0.1:5001;
        auth_basic "seedbox";
        auth_basic_user_file "/etc/nginx/passwd/rutorrent_passwd_casper";
    }
}

提前感谢您所花的时间!

相关内容