Step 1: Add your custom host in /etc/hosts
. Execute this in your terminal
sudo gedit /etc/hosts
Then add your custom host. For example my custom host is mysite so I have added 127.0.0.1 mysite
. In your case it is store_2
127.0.0.1 localhost
127.0.1.1 yourhostname
127.0.0.1 mysite
Step 2:. Enable virtual hosts by editing httpd.conf
sudo gedit /opt/lampp/etc/httpd.conf
Find #Include etc/extra/httpd-vhosts.conf and remove the # to un-comment this line
step 3: Add new virtual host by opening the httpd-vhosts.conf file
sudo gedit /opt/lampp/etc/extra/httpd-vhosts.conf
Usually, by default there are two virtual hosts in this file. Comment these virtual hosts or delete them. For example in my case
#<VirtualHost *:80>
#ServerAdmin webmaster@dummy-host.example.com
#DocumentRoot "/opt/lampp/docs/dummy-host.example.com"
#ServerName dummy-host.example.com
#ServerAlias www.dummy-host.example.com
#ErrorLog "logs/dummy-host.example.com-error_log"
#CustomLog "logs/dummy-host.example.com-access_log" common
#</VirtualHost>
#<VirtualHost *:80>
#ServerAdmin webmaster@dummy-host2.example.com
#DocumentRoot "/opt/lampp/docs/dummy-host2.example.com"
#ServerName dummy-host2.example.com
#ErrorLog "logs/dummy-host2.example.com-error_log"
#CustomLog "logs/dummy-host2.example.com-access_log" common
#</VirtualHost>
Then add
NameVirtualHost 127.0.0.1
<VirtualHost 127.0.0.1>
DocumentRoot /opt/lampp/htdocs/
ServerName localhost
</VirtualHost>
<VirtualHost mysite>
ServerAdmin webmaster@localhost
DocumentRoot /opt/lampp/htdocs/your_project_folder/
ServerName mysite
ServerAlias mysite
RewriteEngine On
RewriteOptions inherit
CustomLog /var/log/apache2/mysite.log combined
<Directory /opt/lampp/htdocs/your_project_folder/>
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
In the above code, in your case the project folder is main_store. Also replace mysite with your store_2
Step 4: Restart XAMPP server. This is very IMPORTANT
sudo /opt/lampp/lampp restart
Step 5: Type http://mysite/
in browser’s address bar and it should work. In your case http://store_2/