5

I'm trying to host 3 sites with Apache in Ubuntu 20.04 but when I try connecting to them I get

Not Found. The requested URL was not found on this server.

This is my virtual host file

<VirtualHost *:80> ServerName nico1.com Redirect permanent / https://nico1.com </VirtualHost> <VirtualHost *:443> ServerName nico1.com DocumentRoot /var/www/index1.html <Directory /var/www/index1.html> AllowOverride All </Directory> SSLEngine on SSLCertificateFile /etc/ssl/private/nico1.crt SSLCertificateKeyFile /etc/ssl/private/nico1.key </VirtualHost> <VirtualHost *:80> ServerName nico2.com Redirect permanent / https://nico2.com </VirtualHost> <VirtualHost *:443> ServerName nico2.com DocumentRoot /var/www/index2.html <Directory /var/www/> AllowOverride All </Directory> SSLEngine on SSLCertificateFile /etc/ssl/private/nico2.crt SSLCertificateKeyFile /etc/ssl/private/nico2.key </VirtualHost> <VirtualHost *:80> ServerName nico3.com Redirect permanent / https://nico3.com </VirtualHost> <VirtualHost *:443> ServerName nico3.com DocumentRoot /var/www/index3.html <Directory /var/www/> AllowOverride All </Directory> SSLEngine on SSLCertificateFile /etc/ssl/private/nico3.crt SSLCertificateKeyFile /etc/ssl/private/nico3.key </VirtualHost> 

And when I run systemctl status apache2 I get

Warning: DocumentRoot [/var/www/index1.html] does not exist
Warning: DocumentRoot [/var/www/index2.html] does not exist
Warning: DocumentRoot [/var/www/index3.html] does not exist

This is clearly the error here but I don't know how to solve it. I have already tried changing permissions and making www-data the owner of the files in the past and I've also set /var/www/ in this directive in /etc/apache2/apache2.conf

<Directory /var/www/> Options Indexes FollowSymLinks AllowOverride All Require all granted </Directory> 

These are currently the permissions of the files

-rw-r--r-- 1 alumno root 499 Mar 5 19:07 index1.html
-rw-r--r-- 1 alumno root 110 Mar 6 11:55 index2.html
-rw-r--r-- 1 alumno root 110 Mar 5 19:09 index3.html

How can I fix this error?

1 Answer 1

17

You are doing it wrong. The DocumentRoot parameter for a virtualhost must be a directory, and not a file! Create 3 subdirectories nico1, nico2, nico3, and move the correct index inside (you should probably rename it from index?.html to index.html)

See DocumentRoot.

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.