Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannont access localhost websites after creating virtual host [duplicate]

Tags:

apache

I have created a virtualhost for one of my localhost websites:

<VirtualHost *:80>
  ServerName mysite 
  DocumentRoot /var/www/html/mysite/public
  <Directory /var/www/html/mysite/public>
    Options Indexes FollowSymLinks
    AllowOverride All 
    allow from all 
  </Directory>
</VirtualHost>

Now, I can't access other local websites anymore. for example when I go to localhost/anotherwwebite I get redirected to mysite.

like image 969
user16948 Avatar asked Aug 18 '12 03:08

user16948


1 Answers

To get it work please follow these steps:

  1. Enable Virtual host configuration file from httpd.conf 1

    un comment (remove # from start) below entry

    #Include conf/extra/httpd-vhosts.conf`

  2. Configure httpd-vhost.conf 2

    Here you have to write two configurations set one for localhost and one for virtual host.

    put following

<VirtualHost *:80>
ServerAdmin localhost.admin
DocumentRoot "C:\wamp\www"  >> For UBUNTU /opt/lampp/htdocs/
ServerName localhost
</VirtualHost>

(prior to virtual host)

<VirtualHost *:80>
ServerAdmin pimcore.test
DocumentRoot "C:\wamp\www\pimcore-latest"
ServerName pimcore.test
ErrorLog "logs/pimcore.test.log"
CustomLog "logs/pimcore.test.log" common
</VirtualHost>
  1. and following entries in system hosts 3

    127.0.0.1 localhost

    127.0.0.1 pimcore.test

of course these will vary depends of Your virtual server names.


1 : C:\wamp\bin\apache\Apache2.2.11\conf\httpd.conf OR /opt/lampp/etc/httpd.conf

2 : C:\wamp\bin\apache\Apache2.2.11\conf\extra\httpd-vhosts.conf OR /opt/lampp/etc/extra/httpd-vhosts.conf

3 : C:\WINDOWS\system32\drivers\etc\hosts: OR /etc/hosts

Regards

like image 73
masteryoda Avatar answered Sep 21 '22 03:09

masteryoda