NGINX位置块用于路径Lumen / Laravel的子目录

时间:2018-01-23 10:57:59

标签: laravel nginx lumen nginx-location

我一直在寻找这个,但无法找到一个好的解决方案,

我在目录中的nginx服务器上添加了流明项目 /usr/share/nginx/html/sms-api

我正在尝试使用http://MY_IP_ADDRESS/sms-api/通过服务器ip访问应用程序并且它工作正常,但是当我从http://IP_ADDRESS/sms-api/login这样的流明访问任何路由时,它只返回404 Page

这是sms-api目录的位置块

# sms-api
location ^~ /sms-api {
    alias /usr/share/nginx/html/sms-api/public;
    try_files $uri $uri/ @sms-api;
    location ~* \.php {
        try_files $uri =404;            
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_index index.php;
        fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
        fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html/sms-api/public/index.php;
        include fastcgi_params;
    }
}
location @sms-api {
    rewrite ^sms-api/(.*)$ /sms-api/index.php/$1 last;
}
# sms-api

以及此上述位置所在的此IP的整个默认服务器块

server {
    listen   80;
    server_name  IP_ADDRESS;

    root   /usr/share/nginx/html;
    index index.php index.html index.htm;

    location / {
        try_files $uri $uri/ =404;
    }
    error_page 404 /404.html;
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
        root /usr/share/nginx/html;
    }

    # sms-api
    location ^~ /sms-api {
        alias /usr/share/nginx/html/sms-api/public;
        try_files $uri $uri/ @sms-api;
        location ~* \.php {
            try_files $uri =404;            
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_index index.php;
            fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
            fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html/sms-api/public/index.php;
            include fastcgi_params;
        }
    }
    location @sms-api {
        rewrite ^sms-api/(.*)$ /sms-api/index.php/$1 last;
    }
    # sms-api

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}

非常感谢任何指导和帮助,

由于

0 个答案:

没有答案