【问题标题】:How to config a laravel project in an exist php project with nginx alias?如何使用 nginx 别名在现有的 php 项目中配置 laravel 项目?
【发布时间】:2017-12-29 21:32:35
【问题描述】:

这是我现有项目的 nginx config 文件。我可以访问 sms.dev/index.php 。 现在,我想在/var/www/html/laravel 文件夹上部署一个新的laravel 项目,并使用sms.dev/laravel 之类的域来访问我的新laravel 项目。 如何做到这一点?

server{
        listen 80;
        server_name sms.dev;
        index index.php index.html index.htm;
        root /var/www/html/sms;
        location /laravel/ {
            # how to config it ?
        }
        location ~ .*\.(php|php5)?$
        {
                fastcgi_pass  127.0.0.1:9000;
                fastcgi_index index.php;
                include fcgi.conf;
        }

        if (!-e $request_filename) {
                return 404;
        }
}

【问题讨论】:

  • this answer
  • 无论我访问什么浏览器都会返回 404。

标签: php laravel nginx


【解决方案1】:

尝试在您的位置块中添加try_files $uri $uri/ /index.php?$query_string;

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-05-18
    • 2017-08-05
    • 1970-01-01
    • 1970-01-01
    • 2017-06-14
    • 1970-01-01
    • 2017-01-19
    • 1970-01-01
    相关资源
    最近更新 更多