鍍金池/ 問答/PHP  Linux  網(wǎng)絡(luò)安全/ laravel 如何在nginx中配置到一個已經(jīng)有的站點的路徑下

laravel 如何在nginx中配置到一個已經(jīng)有的站點的路徑下

現(xiàn)在配置文件如下,已經(jīng)有一個站點在工作了。新建了一個laravel的工程,在其他路徑:/var/www/html/laravel.

如何配置才能正常訪問 sms.dev/laravel/path ?

server{
        listen 80;
        server_name sms.dev;
        index index.php index.html index.htm;
        root /var/www/html/sms;
        location /laravel/ {
            # 這里如何配置呢?
        }
        location ~ .*\.(php|php5)?$
        {
                fastcgi_pass  127.0.0.1:9000;
                fastcgi_index index.php;
                include fcgi.conf;
        }
        
        if (!-e $request_filename) {
                return 404;
        }
}

回答
編輯回答
傻叼

location /xxx {

try_files $uri $uri/ /xxx/index.php?$query_string;

}

2018年9月14日 07:38
編輯回答
我以為

stackoverflow 上面找到了答案:https://stackoverflow.com/que...

location ^~ /app/ {
    alias /var/www/laravel/public/;

    if (!-e $request_filename) { rewrite ^ /app/index.php last; }

    location ~ \.php$ {
        if (!-f $request_filename) { return 404; }

        include snippets/fastcgi-php.conf;

        fastcgi_param SCRIPT_FILENAME $request_filename;
        fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    }
}
2018年5月12日 11:35
編輯回答
笑浮塵

謝邀。

方式很多種。

1.匹配到 localtion 后,修改 root 即可,推薦方式
2.匹配到 location 后,內(nèi)部反向代理到新的 server 即可。

2017年6月9日 21:24
編輯回答
孤客

遇到同樣的問題,nginx下,在二級目錄,不知如何配置

2017年7月14日 22:37