Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Katerou22's avatar

Nginx multiple projects in one domain errors

Hey there, This is my config here for nginx i have domain named tstdmn and two laravel projects first tstdmn.com project and second florist project i want to deploy florist project into the tstdmn.com/florist , i set it all but it return blank page at tstdmn.com/florist what's my issue here?! And i know the problem is with my nginx configuration because i switch the florist project to the main project and it works, its not from my laravel configurations

    root /var/www/html/tstdmn.com/public;

 
    # Add index.php to the list if you are using PHP
    index index.html index.php index.htm index.nginx-debian.html;

    server_name tstdmn.com www.tstdmn.com;

    location / {

            # First attempt to serve request as file, then
            # as directory, then fall back to displaying a 404.
            try_files $uri $uri/ /index.php?$query_string;
    }

    location ^~ /florist {
alias /var/www/html/florist/florist_backend/public;
try_files $uri $uri/ @laravel1;

location ~ \.php {
    fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
    fastcgi_split_path_info ^(.+\.php)(.*)$;
    include /etc/nginx/fastcgi_params;
     }
}

location @laravel1 {    
        rewrite /florist/(.*)$ /florist/index.php?/$query_string last;
    }

        location ~ \.php$ {
              include snippets/fastcgi-php.conf;
              fastcgi_pass unix:/run/php/php7.1-fpm.sock;
     }

And so another routes of project show's blank like /register

0 likes
5 replies
NereuOliveira's avatar

Hi,

First of all, I think you should try to wrap the tow projects configurations on separate server blocks, for example:

server {
    listen 8080;
    root /data/up1;

    location / {
    }
}

It should look like something like this:

server {
    listen 80 default_server;
    listen [::]:80 default_server;
    server_name tstdmn.com www.tstdmn.com;
    root /var/www/html/tstdmn.com/public;

 
    # Add index.php to the list if you are using PHP
    index index.html index.php index.htm index.nginx-debian.html;

    location / {

            # First attempt to serve request as file, then
            # as directory, then fall back to displaying a 404.
            try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php {
        fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
        fastcgi_split_path_info ^(.+\.php)(.*)$;
        include /etc/nginx/fastcgi_params;
        }
    }
}

server {
    listen 80;
    listen [::]:80;
    server_name tstdmn.com/florist www.tstdmn.com/florist;
    root /var/www/html/florist/florist_backend/public;

 
    # Add index.php to the list if you are using PHP
    index index.html index.php index.htm index.nginx-debian.html;

    location / {

            # First attempt to serve request as file, then
            # as directory, then fall back to displaying a 404.
            try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php {
        fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
        fastcgi_split_path_info ^(.+\.php)(.*)$;
        include /etc/nginx/fastcgi_params;
        }
    }
} 

I never did this way before, I usually use subdomains, If it doesn't work you could try it:

server_name florist.tstdmn.com;

You can find more information about this kind of configurations here: http://nginx.org/en/docs/beginners_guide.html

Katerou22's avatar

i have server block in my code i just dont mention it here,

server_name tstdmn.com/florist www.tstdmn.com/florist;

i use it and nginx errors not acceptable parameters in server name:

nginx: [warn] server name "tstdmn.com/florist" has suspicious symbols in /etc/nginx/sites-enabled/tstdmn.com:98

NereuOliveira's avatar

All right, instead of "tstdmn.com/florist", have you tried using the subdomain as I mentioned before (florist.tstdmn.com)?

You just have to configure your DNS for this subdomain pointing to the same server and then NGINX takes care of serving the right application.

I think NGINX can not solve the "tstdmn.com/florist" server name because it resides on the main project. For that to work, you should try to configure the main project route not NGINX.

1 like
Katerou22's avatar

Thank you , i changed my method to the subdomain and configure dns its working perfect but i have some issue when i run nginx reload it warns conflict of tstdmn.com

Katerou22's avatar
Katerou22
OP
Best Answer
Level 1

First i created a block like this and then i config the dns

Solution by @NereuOliveira SOLVED:

server { listen 80; listen [::]:80;

    root /var/www/html/florist/florist_backend/public;

    # Add index.php to the list if you are using PHP
    index index.html index.php index.htm index.nginx-debian.html;

    server_name florist.tstdmn.com;

    location / {

            # First attempt to serve request as file, then
            # as directory, then fall back to displaying a 404.
            try_files $uri $uri/ /index.php?$query_string;
    }

..... and some code not related

Please or to participate in this conversation.