Home > Article > PHP Framework > Can laravel be configured to an existing site path in nginx?
The following column Laravel Tutorial will introduce to you how to configure laravel in nginx under the path of an existing site. I hope it will be helpful to everyone!
Problem description:
How to configure laravel in nginx to the path of an existing site
The configuration file is as follows, there is already one The site is working. Created a new laravel project, in other path:/var/www/html/laravel.
How to configure to access sms.dev/laravel/path normally?
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; } }
Solution Method:
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; } }
[Related recommendations: The latest five Laravel video tutorials]
The above is the detailed content of Can laravel be configured to an existing site path in nginx?. For more information, please follow other related articles on the PHP Chinese website!