Why Apache virtual hosts on Ubuntu 14.04 is not working?
Solution 1
I forgot to add host in /etc/hosts
:
127.0.0.1 localhost
127.0.0.1 bow.loc
I thought apache does it automatically.
Solution 2
Since Apache 2.4, each virtual host file should have the .conf extension.
You can rename each virtual host file to include the .conf extension:
mv /etc/apache2/sites-available/example.com /etc/apache2/sites-available/example.com.conf
Use the a2ensite command to add the virtual host:
a2ensite example.com.conf
And reload Apache:
service apache2 reload
Solution 3
Well, I have been trying all these solutions offered..but sadly nothing worked! Alas i edited
/etc/hosts
to make entry
127.0.1.1 example.com test.com
and it worked!!
(Sorry if I'm not talking much technically!)
Solution 4
I wrote a python script that will automate the apache virtual host creation steps ... this video explains how, download/code on GitHub
Related videos on Youtube
Victor Bocharsky
Updated on September 18, 2022Comments
-
Victor Bocharsky over 1 year
I installed Apache 2.4 on Ubuntu 14.04 and it was working fine by
http://localhost/
address. But when I tried to add a new virtual host, for examplehttp://bow.loc
and restart apache, new address was not available onhttp://bow.loc
and available onhttp://localhost
.My configuration is:
<VirtualHost *:80> ServerName www.bow.loc ServerAlias bow.loc DocumentRoot /var/www/html/bow/web <Directory /var/www/html/bow> AllowOverride All Options FollowSymLinks MultiViews Order allow,deny Allow from all <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ /app.php [QSA,L] </IfModule> </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>
How can I get my site by
http://bow.loc
?-
jmarceli about 9 yearsCheck out my answer here. Got similar problem and it turns out to be the problem with system DNS configuration.
-
-
Victor Bocharsky about 10 yearsThanks! And after this actions I don't need manually modified the
/etc/hosts
file and add hosts to it? Does apache will write new hosts automatically? -
Ari Pratomo about 10 yearsApache doesn't write new hosts automatically, you should write it manually. CMIIW
-
Victor Bocharsky about 10 yearsSo, my config is right, and problem in order that I forgot to add host in
/etc/hosts
-
David Foerster about 9 yearsPlease explain, where to put this and what it does. Don't just post commands or configuration artefacts. See How do I write a good answer?
-
flickerfly almost 9 yearsI've not had to do that any time before on a server. I do it from the client for testing purposes all the time though. Can you clarify what you are saying here?
-
Victor Bocharsky almost 9 years@flickerfly What are you meant? I made my virtualhosts points to my local machine to handle them with installed
Apache
server -
user3531005 over 8 yearsI forgot to add this as well! :P
-
lucaferrario over 7 yearsDamn, I wasted one our on this on a Debian 8 VM! Thanks!!!
-
Victor Bocharsky over 7 years@lucaferrario haha, me either. Simple bugs difficult to reveal ;) You're welcome!