下面由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视频教程】
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号