Blog

Magento2 site is not accessible

In this article, we are going to understand and resolve the Magento2 site url. I have explained this in the following steps.

There are only two steps to resolve this issue.

    • Step 1: Update the BASE URL
    • Step 2: Update the Document Root
    • Step 3: Clean Cache
    • Step 4: Hit the Site Url in the Browser

So let’s get started, follow each and every step carefully.

Step 1: Update the BASE URL

Run the folllowing command to connect to mysql.

Command 1:  mysql -u root -p

Enter the password.

Command 2:  use database_name;

Command 3:

Then update query to update the BASE URL.

UPDATE `core_config_data` SET value='http://127.0.0.1/magento2/pub/' WHERE path='web/unsecure/base_url';

magento2 =>  is the directory where magento has been installed.

Good you are done with the first step. Let’s go the second step.

Step 2: Update the Document Root

In this step, we are going to set the document root. So Go to the virtual host file by below command:

sudo nano /etc/apache2/sites-available/000-default.conf

Update Document url and comment ServerName in this file.

#ServerName yourname.magento.com

DocumentRoot /var/www/html

Step 3: Clean Cache

To check our latest changes on the site, clear cache:

php bin/magento cache:flush

Now, our final step is to hit the Url in the browser to see our site admin and hmepage.

Step 4: Hit the Url in the Browser

Then hit the URL http://127.0.0.1/magento2/pub in the browser for

Home Page – http://127.0.0.1/magento2/pub

Admin Page – http://127.0.0.1/magento2/pub/admin

That’s it.

Conclusion:

In this article, we learned how to set the Document root for the Magento2. Hope this helped. Do comment below your valuable feedback.

Leave a Reply

Your email address will not be published. Required fields are marked *