I want two setup two different version of magento 2 on my local nginx machine, v2.4.2 and v2.3.7 mapped with two different domains.
One version(2.4.2) is working fine on my nginx server at port 80 with domain- http://magento.local.in/ folder location /var/www/html/magento. Below is the nginx config file- /etc/nginx/site-enabled/magento (same config in site-available)
upstream fastcgi_backend {
server unix:/run/php/php7.4-fpm.sock;
}
server {
listen 80;
listen [::]:80;
server_name magento.local.in;
set $MAGE_ROOT /var/www/html/magento;
include /var/www/html/magento/nginx.conf.sample;
}
Now I want to setup another version(v2.3.7) at same server with different port (lets say 81). So I downloaded version files and successfully installed at location /var/www/html/magento23
I thought(not sure) new nginx config file would work perfectly for this so I created-
/etc/nginx/site-enabled/magento23
server {
listen 81;
listen [::]:81;
server_name magento23.local.com;
set $MAGE_ROOT /var/www/html/magento23;
include /var/www/html/magento23/nginx.conf.sample;
}
I am able to run every bin/magento command in the same directory magento23 but site is not accessible in the browser-
This is the /etc/hosts file –
127.0.0.1 magento.local.in
127.0.0.1:81 magetno23.local.com
127.0.1.1 prm
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
I do not understand why these two completely different project are not working. I think it could be done by single nginx config file but do not know how. I have tried to much to dig this and also follow some solutions as well –
https://askubuntu.com/questions/759513/how-to-run-multiple-magento2-setup-with-nginx
Magento 2: How to configure Nginx to use multiple websites with sub-folder
But nothing worked because I am not doing one setup with multiple website, store or store view. I am trying to setup two different independent versions with no dependencies.
Can anyone want to help me out here with the correct approach. Thank you.