I created multi websites for AWS public EC2 domain and its ip address. Below are the steps I which followed.
- Create new website(code: webtwo), store and storeview in Magento admin
- Configure its base url in
stores / configuration / General / Web
- Create site configuration for the new website under /etc/nginx/sites-available/
Consider below as an example
Create file name for webtwo
And the code would be:
server {
listen 80;
server_name x.xxx.xx.xxx;
set $MAGE_ROOT /var/www/html/site;
set $MAGE_RUN_CODE webtwo;
set $MAGE_RUN_TYPE website;
include /var/www/html/site/nginx.conf.sample;
}
Do not modify anything in magento
file under /etc/nginx/sites-available/. If any changes required, then modify accordingly. Unless do not modify the file.
Run nginx -t
and confirm the changes are taken by Nginx
Navigate to /etc/nginx/sites-enabled/ and run the command for creating symlink ln -s /etc/nginx/sites-available/webtwo webtwo
Navigate to magento root directory and open the file nginx.confg.sample
and add the below code
fastcgi_param MAGE_RUN_TYPE $MAGE_RUN_TYPE;
fastcgi_param MAGE_RUN_CODE $MAGE_RUN_CODE;
under # PHP entry point for main application
And it would look like
# PHP entry point for main application
location ~ ^/(index|get|static|errors/report|errors/404|errors/503|health_check)\.php$ {
try_files $uri =404;
fastcgi_pass fastcgi_backend;
fastcgi_buffers 1024 4k;
fastcgi_param PHP_FLAG "session.auto_start=off \n suhosin.session.cryptua=off";
fastcgi_param PHP_VALUE "memory_limit=756M \n max_execution_time=18000";
fastcgi_read_timeout 600s;
fastcgi_connect_timeout 600s;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
# START - Multisite customization
fastcgi_param MAGE_RUN_TYPE $MAGE_RUN_TYPE;
fastcgi_param MAGE_RUN_CODE $MAGE_RUN_CODE;
# END - Multisite customization
include fastcgi_params;
}
- Now restart Nginx by systemctl restart nginx and the multi website site is ready and you can browse with the new ip / domain.