There is no sites-available/000-default.conf in /etc/apache2
The files in /etc/apache2/conf-available
are files that an admin is free to create, rename, remove, fill in with proper content, etc. If you have no 000-default.com, just create one.
You should then call
sudo a2ensite 000-default.conf
Caveats:
the virtualhosts coexist - from what I understood, you already have some non-standard configuration. Beware virtualhosts conflicting with each other. Chances are you may need a fresh install of apache2 including its configuration.
what files are finally loaded (included) as configs depends on some other config files, like
/etc/apache2/apache2.conf
with itsinclude
command (which then includes a specified file). Include can also be called in an included file.
FYI, the 000-default.conf for apache2 (version 2.4.7) goes as follows:
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
And you are best to use the following commands to enable/disable a site rather than creating a site by creating a symlink (which you still can do, but well... its typically rely on helper scripts e.g. in order to avoid typos)
a2ensite 000-default
a2dissite 000-default
If some configs don't kick in, you can try:
sudo service apache2 reload
or even deeper config-reload happens on:
sudo service apache2 restart
Reload does keep some connection-related data in the memory, and both take a fraction of a second on a typical fresh installation.
EDIT: I added a note about four usefull commands: a2ensite, a2dissite, service apache2 restart/reload and in the subsequent edit I re-organized the answer to better fit the question.
Related videos on Youtube
lungov
Updated on September 18, 2022Comments
-
lungov over 1 year
I'm trying to set up virtual hosts for Apache2. There are tons of tutorials, but they all presume that the file
/etc/apache2/sites-available/000-default.conf
is there. But if I run:$ cd /etc/apache2/ $ ls conf-available $ cd conf-available $ ls javascript-common.conf
I can't find anyone who had the same problem. Do I need to do anything before I start tutorials such as this?
https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-16-04
Everything is up to date. Ubuntu is 16.04 LTS.
-
wha7ever almost 3 yearsIf it might help somebody, I was using Vultr VPS and my 000-default.conf file was located in
/var/default-conf/apache2/sites-available
.
-
-
lungov almost 6 yearsThanks Patryk! When you say that I should stick to the manual, what manual is that? In the Apache site it says that there is no manual or official documentation, only a FAQ and the Forum. Before I try anything else, I'll reinstall Apache fresh, although it is a pretty recent install. And then if the file is not there I'll just create it based on the content you provided. Thanks again!
-
Patryk Mazurkiewicz almost 6 years@lungov - by saying "better to stick to the manual" I ment "when apache provides helper scripts like a2ensite - it is better to use this instead of doing all manually". I should probably edit my answer to correct this. And good luck!
-
rfay over 5 yearsThere's a typo early on here,
sudo a2ensite 000-defailt.conf
should besudo a2ensite 000-default.conf
-
Patryk Mazurkiewicz over 5 yearsThank you! I hope you found the article useful. All the best