I have placed my Laravel 5 project in /var/www/my_project/ and I would like to reach it at http://my_domain.com/my_project/. However, I can't figure out how to configure the nginx server block.
What I want is this:
http://my_domain.com/should be empty at this point. Later, another project will be visible here.http://my_domain.com/my_project/should be the project I am trying to add now.
Please note that the Laravel public folder is located at /var/www/my_project/public.
This is my nginx configuration (at /etc/nginx/sites-enabled/):
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /var/www/my_project/public;
index index.php index.html index.htm;
server_name my_ip;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
What is the best way to achieve the desired configuration?
/var/www/and add a location aslocation /my_project { alias /var/www/my_project/public; }http://my_domain.com/my_project/returns the nginx/Ubuntu 404 page. Thank you for the suggestion though!