Home > PHP Framework > Laravel > body text

Can laravel be configured to an existing site path in nginx?

藏色散人
Release: 2021-11-24 15:47:47
forward
2120 people have browsed it

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;
        }
}
Copy after login

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;
    }
}
Copy after login

[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!

Related labels:
source:segmentfault.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template