Trouble with Directories in /var/html/www (Ubuntu 20.04LTS)

I have a number of domains on my Ubuntu 20.04LTS distro. When I configure the file /etc/apache2/sites-available/domain.com.conf for each domain, I set the DocumentRoot to /var/www/html/domain.com/public_html.

As you'd expect, the site files are all in the public_html folder and everything works correctly for all my domains except for one. Despite it being configured like the rest of the other domains, its site files are actually showing up in /var/www/html/. So if I go to https://marcmanley.dev, the domain comes up fine but the site files are not in /var/www/html/marcmanley.dev/public_html but rather are in /var/www/html/. Any clues as to what's going on here?

What I'm saying is, the domain, marcmanley.dev, is treating /var/www/html/ as its DocumentRoot instead of /var/www/html/marcmanley.dev/public_html despite having it point there.

If I'm not being clear, this is what the html directory looks like.

Here's the .conf file of a working domain:

$ cat /etc/apache2/sites-available/imammarc.com.conf
<virtualhost *:80="">
ServerAdmin marcmanleydev@gmail.com
ServerName imammarc.com
ServerAlias www.imammarc.com</virtualhost>

DirectoryIndex index.html index.php
DocumentRoot /var/www/html/imammarc.com/public_html
LogLevel warn
ErrorLog /var/www/html/imammarc.com/log/error.log
CustomLog /var/www/html/imammarc.com/log/access.log combined

RewriteEngine on
RewriteCond %{SERVER_NAME} =imammarc.com [OR]
RewriteCond %{SERVER_NAME} =www.imammarc.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

and that of the trouble domain (marcmanley.dev)

$ cat /etc/apache2/sites-available/marcmanley.dev.conf
<virtualhost *:80=""> ServerAdmin marcmanleydev@gmail.com ServerName marcmanley.dev ServerAlias www.marcmanley.dev DirectoryIndex index.html index.php DocumentRoot /var/www/html/marcmanley.dev/public_html LogLevel warn ErrorLog /var/www/html/marcmanley.dev/log/error.log CustomLog /var/www/html/marcmanley.dev/log/access.log combined </virtualhost>

Additionally:

$ ls -lR /etc/apache2/sites-available
total 84
-rw-r--r-- 1 root root 1516 May 31 23:35 000-default.conf
-rw-r--r-- 1 root root 1569 Jun 1 01:14 000-default-le-ssl.conf
-rw-r--r-- 1 root root 6338 Apr 13 17:19 default-ssl.conf
-rw-r--r-- 1 root root 495 Jun 4 05:38 eid.rocks.conf
-rw-r--r-- 1 root root 536 Jun 4 05:38 eid.rocks-le-ssl.conf
-rw-r--r-- 1 root root 572 Jun 4 05:31 goodbookorganics.com.conf
-rw-r--r-- 1 root root 613 Jun 4 05:31 goodbookorganics.com-le-ssl.conf
-rw-r--r-- 1 root root 762 Jun 1 01:10 imammarc.com.conf
-rw-r--r-- 1 root root 729 Jun 1 01:10 imammarc.com-le-ssl.conf
-rw-r--r-- 1 root root 516 Jun 4 06:44 islaam.rocks.conf
-rw-r--r-- 1 root root 557 Jun 4 06:44 islaam.rocks-le-ssl.conf
-rw-r--r-- 1 root root 399 Jun 1 02:12 marcmanley.dev.conf
-rw-r--r-- 1 root root 523 Jun 4 20:19 marcmanley.me.conf
-rw-r--r-- 1 root root 564 Jun 4 20:19 marcmanley.me-le-ssl.conf
-rw-r--r-- 1 root root 574 Jun 1 04:25 mynew.faith.conf
-rw-r--r-- 1 root root 615 Jun 1 04:25 mynew.faith-le-ssl.conf
-rw-r--r-- 1 root root 621 Jun 1 06:57 ramadaan.rocks.conf
-rw-r--r-- 1 root root 632 Jun 1 06:57 ramadaan.rocks-le-ssl.conf
-rw-r--r-- 1 root root 530 Jun 4 05:51 shaykhchef.com.conf
-rw-r--r-- 1 root root 571 Jun 4 05:51 shaykhchef.com-le-ssl.conf

and

$ ls -lR /etc/apache2/sites-enabled
total 4
lrwxrwxrwx 1 root root 52 May 31 23:34 000-default-le-ssl.conf -> /etc/apache2/sites-available/000-default-le-ssl.conf
lrwxrwxrwx 1 root root 33 Jun 4 05:20 eid.rocks.conf -> ../sites-available/eid.rocks.conf
lrwxrwxrwx 1 root root 50 Jun 4 05:38 eid.rocks-le-ssl.conf -> /etc/apache2/sites-available/eid.rocks-le-ssl.conf
lrwxrwxrwx 1 root root 44 Jun 4 05:30 goodbookorganics.com.conf -> ../sites-available/goodbookorganics.com.conf
lrwxrwxrwx 1 root root 61 Jun 4 05:31 goodbookorganics.com-le-ssl.conf -> /etc/apache2/sites-available/goodbookorganics.com-le-ssl.conf
lrwxrwxrwx 1 root root 36 Jun 1 00:25 imammarc.com.conf -> ../sites-available/imammarc.com.conf
lrwxrwxrwx 1 root root 53 Jun 1 01:10 imammarc.com-le-ssl.conf -> /etc/apache2/sites-available/imammarc.com-le-ssl.conf
lrwxrwxrwx 1 root root 36 Jun 4 05:43 islaam.rocks.conf -> ../sites-available/islaam.rocks.conf
lrwxrwxrwx 1 root root 53 Jun 4 06:44 islaam.rocks-le-ssl.conf -> /etc/apache2/sites-available/islaam.rocks-le-ssl.conf
lrwxrwxrwx 1 root root 38 Jun 1 02:13 marcmanley.dev.conf -> ../sites-available/marcmanley.dev.conf
lrwxrwxrwx 1 root root 38 Jun 1 02:02 marcmanley.dev.old.conf -> ../sites-available/marcmanley.dev.conf
lrwxrwxrwx 1 root root 37 Jun 4 17:46 marcmanley.me.conf -> ../sites-available/marcmanley.me.conf
lrwxrwxrwx 1 root root 54 Jun 4 20:19 marcmanley.me-le-ssl.conf -> /etc/apache2/sites-available/marcmanley.me-le-ssl.conf
lrwxrwxrwx 1 root root 35 Jun 1 04:00 mynew.faith.conf -> ../sites-available/mynew.faith.conf
lrwxrwxrwx 1 root root 52 Jun 1 04:25 mynew.faith-le-ssl.conf -> /etc/apache2/sites-available/mynew.faith-le-ssl.conf
lrwxrwxrwx 1 root root 38 Jun 1 05:54 ramadaan.rocks.conf -> ../sites-available/ramadaan.rocks.conf
lrwxrwxrwx 1 root root 55 Jun 1 06:57 ramadaan.rocks-le-ssl.conf -> /etc/apache2/sites-available/ramadaan.rocks-le-ssl.conf
lrwxrwxrwx 1 root root 38 Jun 4 05:51 shaykhchef.com.conf -> ../sites-available/shaykhchef.com.conf
lrwxrwxrwx 1 root root 55 Jun 4 05:51 shaykhchef.com-le-ssl.conf -> /etc/apache2/sites-available/shaykhchef.com-le-ssl.conf

6 Replies

Hey there -

I took a look at the information that you posted in your question, and from what I can see, it looks to be correct as per our example:

Configure Virtual Hosts

I want to direct you to Apache's docs for further guidance, as it explains in detail how DocumentRoot works in conjunction with your URL-Path:

Apache - Mapping URLs to Filesystem Locations

I'm not seeing anything amiss in what you've provided that jumps out at me, but I might be missing something. I'll add some additional tags to this to give it more visibility to the rest of the Linode Community as well.

Couple of things:

lrwxrwxrwx 1 root root 38 Jun 1 02:13 marcmanley.dev.conf -> ../sites-available/marcmanley.dev.conf
lrwxrwxrwx 1 root root 38 Jun 1 02:02 marcmanley.dev.old.conf -> ../sites-available/marcmanley.dev.conf

Both these symlinks evaluate to the same physical file. This may or may not be causing a conflict in Apache.

One other thing I noticed is that marcmanley.dev does not have a Let’s Encrypt config file (*-le-ssl.conf) like your other sites, but you have indicated you’re trying https://marcmanley.dev. This may be causing HTTPS requests to be falling back to the default vhost at /var/www/html.

Thank you for the quick reply. What's odd is that while there's no ssl config file for marcmanley.dev it nonetheless is encrypted when you visit the site. Did I screw something?

Yes you’re right it is, and the certificate on it is for marcmanley.dev/www.marcmanley.dev.

What is in your /etc/apache2/sites-available/000-default-le-ssl.conf file?

<ifmodule mod_ssl.c="">
<virtualhost *:443=""></virtualhost></ifmodule>

ServerAdmin marcmanleydev@gmail.com
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
ServerName marcmanley.dev
Include /etc/letsencrypt/options-ssl-apache.conf
ServerAlias www.marcmanley.dev
SSLCertificateFile /etc/letsencrypt/live/marcmanley.dev/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/marcmanley.dev/privkey.pem

Ah, well that’s why!

The SSL configuration for marcmanley.dev is in the 000-default-le-ssl.conf file, and it is pointing it to /var/www/html.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct