I have an apache2 config on Ubuntu. Everything was working well until I tried to move all my canonical redirect virtualhosts into a single file instead of having them scattered across lots of other config files.
I arranged my config filenames so that I could strictly control which site was loaded first, and therefore control which of them was Apache's default site. This is the first two files in /etc/apache2/sites-enabled, sorted lexically as ls does by default:
elyograg@smeagol:/etc/apache2$ sudo ls -al sites-enabled
total 12
drwxr-xr-x 2 root root 4096 Oct 6 16:13 .
drwxr-xr-x 9 root root 4096 Oct 6 16:12 ..
lrwxrwxrwx 1 root root 51 Jul 22 2017 000000-unknown.REDACTED.org.conf -> ../sites-available/000000-unknown.REDACTED.org.conf
lrwxrwxrwx 1 root root 47 Oct 6 16:13 0000-canonical-redirect.conf -> ../sites-available/0000-canonical-redirect.conf
Today I added the 0000-canonical-redirect.conf file and I want it to be the second site config file that Apache loads. It used to be that it would load the 000000 file as the default site, but since I added the new one, Apache is choosing that file instead of the 000000 one like I expected it to.
I will be downloading and looking at the source code, but I was hoping that maybe people have run into this before and know for sure that it is a bug.
elyograg@smeagol:~$ dpkg -l | grep apache2
ii apache2 2.4.52-1ubuntu4.1 amd64 Apache HTTP Server
ii apache2-bin 2.4.52-1ubuntu4.1 amd64 Apache HTTP Server (modules and other binary files)
ii apache2-data 2.4.52-1ubuntu4.1 all Apache HTTP Server (common files)
ii apache2-utils 2.4.52-1ubuntu4.1 amd64 Apache HTTP Server (utility programs for web servers)
ii libapache2-mod-dnssd 0.6-3.2 amd64 Zeroconf support for Apache 2 via avahi
ii libapache2-mod-passenger 6.0.10-3build2 amd64 web application server - apache2 integration
ii libapache2-mod-wsgi-py3 4.9.0-1ubuntu0.1 amd64 Python 3 WSGI adapter module for Apache
EDIT: I tried what I hoped would be a more explicit naming, but it still loads the redirect file first.
elyograg@smeagol:/etc/apache2$ ls -al sites-enabled/
total 12
drwxr-xr-x 2 root root 4096 Oct 6 16:41 .
drwxr-xr-x 9 root root 4096 Oct 6 16:12 ..
lrwxrwxrwx 1 root root 50 Oct 6 16:25 _0000-unknown.REDACTED.org.conf -> ../sites-available/_0000-unknown.REDACTED.org.conf
lrwxrwxrwx 1 root root 46 Oct 6 16:41 111-canonical-redirect.conf -> ../sites-available/111-canonical-redirect.conf
In #httpd on IRC, I was guided to the problem. Not surprised it was user error. Apache is running with LANG=C and my shell is running with LANG=en_US.UTF-8 ... and ls was showing me the order I wanted. Apache is sorting the files exactly as LANG=C dictates and my naming scheme wasn't correct for the results I wanted.
if you want to add symbolic link you must define full path of the source file.
I see you only use
../sites-available/some-file.conf
Please try to define full location of the source file like this:
Then reload/restart the service: