title: Nginx: Serve multiple Laravel apps with same url but two different sub locations in Linux
body: <p>I want to serve multiple Laravel apps in a single nginx server, the first one has a root directory in <code>/var/www/html/app1</code>, the second one has <code>/var/www/html/app2</code>, and so on. The <code>index.php</code> file of each app is in a subdirectory named <code>/public</code>.</p>
  
  <p>Whenever user calls <code>http://www.mywebsite.com/app1</code>, nginx shoulds return the app1 and if user calls <code>http://www.mywebsite.com/app2</code>, nginx shoulds return the app2.</p>
  
  <p>My current nginx <code>conf</code> file is as below:</p>
  
  <pre><code>server {
          listen 80 default_server;
          listen [::]:80 default_server;
  
          root /var/www/html;
  
          index index.php index.html index.htm index.nginx-debian.html;
  
          server_name _;
  
          location /app1 {
                  root /var/www/html/app1/public;
                  index index.php;
          }
  
          location /app2 {
                  root /var/www/html/app2/public;
                  index index.php;
          }
  
          location / {
                  # First attempt to serve request as file, then
                  # as directory, then fall back to displaying a 404.
                  # try_files $uri $uri/ =404;
                  try_files $uri $uri/ /index.php$is_args$args;
          }
  
          location ~ \.php$ {
                  include snippets/fastcgi-php.conf;
                  fastcgi_pass unix:/run/php/php7.2-fpm.sock;
          }
  
  }
  </code></pre>
  
  <p>But, nginx always returning 404 page result. What's going wrong here?</p>