I want to do nginx setup for handing two project with same domain.
Example domain: example.com
- Angular project should run with
example.com
- magento2 project should run with
example.com/shop
I tried the code below, but its not working.
location /shop {
alias /var/www/www.example.com/shop/;
index index.html;
try_files $uri $uri/
autoindex on;
}
Can please someone help me to do this.
2
Answers
You can start with the following config to serve your Applications:
I’m not 100% sure if the shop route will work. Maybe you need to configure php to serve it. Therefore you can follow this official example.
If you want to serve also to
www.example.com
you can setserver_name *.example.com
(docs).You should use official NGINX configuration sample as provided here.
Naturally, you will prefix all the Magento 2 locations with
/shop/
, for your specific case.So you will end up with this kind of config: