0

I am setting up a few virtual hosts for my local Apache environment. I followed this as a basic guide: http://www.unixmen.com/setup-apache-virtual-hosts-on-ubuntu-15-10/

At the moment, I have the following structure: /var/www/home - there is a script here that looks inside the "sites" directory and produces a page with a button for each folder in the "sites" directory /var/www/sites - all sites are stored here.

My home.dev points to /var/www/home and localhost points to /var/www/sites (so I can type localhost/site1, if needed)

The problem is that only the localhost and home.dev work properly. When I address other sites, I get "requested URL not found" error. What is even stranger, I get the same page when I type "localhost" or "home.dev." This should not be happening. To be clear, none of the other sites work. I provide phpMyAdmin site as an example. Here are the listings of some config files. Can anyone give me a clue of what's going wrong?

/etc/apache2/sites-available/home.conf

<VirtualHost *:80> ServerName www.home.dev ServerAlias home.dev DocumentRoot /var/www/home/ <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /var/www/home> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all </Directory> </VirtualHost> 

/etc/apache2/sites-available/localhost.conf

<VirtualHost *:80> ServerName localhost ServerAlias localhost DocumentRoot /var/www/sites/ <Directory/> Options FollowSymLinks AllowOverride None </Directory> <Directory /var/www/sites> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all </Directory> </VirtualHost> 

/etc/apache2/sites-available/phpmyadmin.dev.conf

<VirtualHost *:80> ServerName phpmyadmin.dev ServerAlias phpmyadmin.dev DocumentRoot /var/www/sites/phpmyadmin <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /var/www/sites/phpmyadmin> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all </Directory> </VirtualHost> 

/etc/hosts

127.0.0.1 localhost 127.0.1.1 userman-desktop 127.0.2.1 home.dev 127.0.3.1 phpmyadmin.dev 127.0.5.1 sites.dev ::1 ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters 
2
  • This question may be better suited to Server Fault Commented Nov 30, 2015 at 0:48
  • I also asked there. Hopefully, double-dipping is cool on this site. Commented Nov 30, 2015 at 0:57

1 Answer 1

2

You have to enable your virtual hosts configurations, to do this try something like

sudo ln -s /etc/apache2/sites-available/home.conf /etc/apache2/sites-enable/ sudo ln -s /etc/apache2/sites-available/phpmyadmin.dev.conf /etc/apache2/sites-enable/ sudo ln -s /etc/apache2/sites-available/localhost.conf /etc/apache2/sites-enable/ 

then restart the apache service

sudo service apache2 restart 

And your /etc/hosts should be

127.0.0.1 localhost 127.0.0.1 userman-desktop 127.0.0.1 home.dev 127.0.0.1 phpmyadmin.dev 127.0.0.1 sites.dev ::1 ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters 

and your home.conf

<VirtualHost *:80> ServerName home.dev #<--- change this ServerAlias home.dev DocumentRoot /var/www/home/ <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /var/www/home> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all </Directory> </VirtualHost> 
Sign up to request clarification or add additional context in comments.

2 Comments

Out of curiousity, I checked the /etc/apache2/sites-enabled/ folder after reading your suggestion and found the following there: lrwxrwxrwx 1 root root 28 Nov 28 18:32 home.conf -> ../sites-available/home.conf lrwxrwxrwx 1 root root 34 Nov 28 21:40 phpmyadmin.conf -> ../sites-available/phpmyadmin.conf lrwxrwxrwx 1 root root 38 Nov 29 19:19 phpmyadmin.dev.conf -> ../sites-available/phpmyadmin.dev.conf That is, it seems like the symlinks are already there.
I see. Yes, I have tried that version of /etc/hosts. I changed it in hopes of fixing it.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.