this kind is a simple question still I'm struggling to figure out how to achieve this.

I have a landing page, and if the user clicks to enter a certain section I want him to see the store (located at /magento).

When I'm installing magento through the command line there's a baseURL argument, what I should put in there? My intuition is it should be example.com/magento, but I get errors.

Maybe I'm not configuring nginx properly. Here's my super simple config:

server {
    listen                      80 default_server;
    listen                      443 default_server ssl;

    ssl_certificate             /etc/nginx/ssl/cert.pem;
    ssl_certificate_key         /etc/nginx/ssl/key.pem;

    client_max_body_size        10M;

    root /var/www/html;

    location ./magento {
            index index.php;

I tried using baseURL as example.com and example.com/magento, I also tried removing the location ./magento... from nginx. I will get either 404 or 403.

Any ideas on how tho achieve this goal? Thanks.


First try to setup the Magento properly and the try to set the location directive if needed.

All the Magento related files and directories should be there in the /var/www/html/magento directory.

  1. Run the line to create a new virtual host for your Magento site:

sudo nano /etc/nginx/sites-available/magento

  1. add the following in the above file

     upstream fastcgi_backend {
          //If php 7.0
          server  unix:/run/php/php7.0-fpm.sock;
          //If php 7.2
          //server  unix:/run/php/php7.2-fpm.sock;
     server {
          listen 80;     
          //Change the below example.com with your domain
          server_name www.example.com;   
          //Change the below paths if necessary  
          set $MAGE_ROOT /var/www/html/magento;  
          //Change/Create the directory if it is other than below one(magento)
          include /var/www/html/magento/nginx.conf.sample;

NOTE: You can keep listen and ssl related syntax as it.

  1. Activate host by creating a symlink:

ln -s /etc/nginx/sites-available/magento /etc/nginx/sites-enabled

  1. Verify the server configuration

nginx -t

  1. If successful, the following message displays:

nginx: configuration file /etc/nginx/nginx.conf test is successful

  1. Run the command to restart nginx:

systemctl restart nginx

Refer below official Magento guide for more information

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.