0

I have a magento2 folder on my localhost

var/www/html/magento2

I want to open a website like magento2.com instead of localhost/magento2.

How to achieve this.

i have read many tutorials but there are lots of issues.

Sometime Magento2.com opens the apache webpage, some times CSS issue on the front end.

please Help.

2

Step 1: copy default config file.

Run from command line:: sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/magento2.com.conf

Step 2: add below code on new file magento2.com.conf

<VirtualHost *:80>
    ServerAdmin magento2@test.com
    ServerName magento2.com
    ServerAlias www.magento2.com
    DocumentRoot /var/www/html/magento2
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
    <Directory /var/www/html/magento2>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
    </Directory>
</VirtualHost>

Step 3: Enable virtual host configuration files

From command line: sudo a2ensite magento2.com.conf

Step 4: start apache service

From command line: sudo service apache2 restart

Step 5: add host entry

From command line: sudo nano /etc/hosts

add below line in hosts file

127.0.0.1 magento2.com

Step 6:

upade below url on value column of core_config_data.

http://magento2.com/

Step 7: go to var/www/html/magento2 & run below commands,

1. sudo chmod -R 0777 var pub generated
2. sudo php bin/magento c:f
| 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.