laravel在nginx中能配置到已有站点路径吗?

laravel在nginx中能配置到已有站点路径吗?,第1张

laravel在nginx中能配置到已有站点路径吗? 下面由Laravel教程栏目带大家介绍关于laravel怎么在nginx中配置到一个已有站点的路径下,希望对大家有所帮助!

问题描述:

laravel 如何在nginx中配置到一个已经有的站点的路径下

现在配置文件如下,已经有一个站点在工作了。新建了一个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 ^~ /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;
    }
}

【相关推荐:最新的五个Laravel视频教程】

以上就是laravel在nginx中能配置到已有站点路径吗?的详细内容,

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/701123.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-23
下一篇 2022-04-23

发表评论

登录后才能评论

评论列表(0条)

保存