bar2
1642
14
Laravel

NGINX setup for multiple projects

Posted 3 years ago by bar2
server 
{
    listen   443 ssl;

    root /var/www/domain.net/laravel-api/public;
    index index.php index.html index.htm;

    client_max_body_size 80m;

    ssl_certificate /root/apis.domain.net.crt;
    ssl_certificate_key /root/apis.domain.net.key;

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

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }

    server_name apis.domain.net;
}

Above server configuration is working fine as it is. But I want to map more than 1 project to apis.domain.net such as

apis.domain.net/laravel-api-1
apis.domain.net/laravel-api-2

When I try to change the server_name to apis.domain.net/laravel-api-1 for this given project (/var/www/domain.net/laravel-api/public) laravel starts to return 404 for every page. How can I achieve this?

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.