I have various virtual hosts for my web development work, including cnm. The
sites-available/cnm
my file says very simply:
<VirtualHost *:80>
ServerName cnm
DocumentRoot /var/www/cnm/public_html
</VirtualHost>
I upgraded to Ubuntu 13.10, and when I point my browser to cnm/, I see the /var/www/index.html file that seems to be indicated in the default file
sites-available/000-default.conf
which says (among other things):
<VirtualHost *:80>
DocumentRoot /var/www
What do I need to do to get Apache to read my cnm document root when I browse to cnm/ ?
NOTES:
I already tried renaming my sites-available/cnm file to sites-available/cnm.conf and enabling it with
a2ensite cnm
andservice apache2 reload
. That is a good thing, but it changes nothing.I already tried changing
<VirtualHost *:80>
to<VirtualHost cnm.localhost>
or to<VirtualHost cnm>
. That did nothing.
Ubuntu 13.10 uses apache 2.4, you should check all your apache configuration. But for this present case you should note that
a2ensite
anda2dissite
commands won't be able to see your files in /etc/apache2/sites-available if it does not end with.conf
, so rename it tosites-available/cnm.conf
and runa2ensite cnm
.Then your Virtualhost definition is certainly better with
*:80
, it means this virtualhost is activated for all IP interfaces (*
) on port 80.cnm.localhost
orcnm
are not valid values here, only IP numbers (Ip of your apache server) or*
for all, and a port number.Then check how you configuration is read by apache, running theses commands:
You should get something like:
If it is ok, and if you have the right Ip in your hosts file for
cnm
, and you can test that with a ping, then usinghttp://cnm/
should use the Virtualhost having cnm in the ServerName.If you have an answer from the default Virtualhost then it means apache is not finding the name used in your Host header in the list of ServerName and ServerAlias available for that IP/port and fallbacks to the default Virtualhost. If you are really stuck (and you did not forgot to restart) you can always remove the default Virtualhost and keep only the one you are working on.
Rename the file configuration "cnm" with the extension .conf
And ready!
I ran into a similar issue. My server name and my FQDN were the same to the default was running into the /var/www/html directory. I disabled the default configuration and my site worked like a breeze. Thanks @regilero.
fixed it for me.
I couldn't find any step by step tutorial on how to make it work on my side. I gathered bits and pieces here and there, so for those who need all the steps to follow, here there are:
Paste the following into the local-mydefault.conf file (Change the path '/your/full/path' to where you want to have your files. And change username to your own username):
Then type the following commands
I have the same issue on way is to disable 000-default and reload apache ,but this isn't the solution becuase you must have just one vhost at a same time :(
I found the answer to my issue. I needed to delete the files in /etc/apache2/sites-enabled.
sudo a2ensite mysite
.sudo service apache2 reload