Apache2 shows default page instead of my page.

Hi there,
i am fairly new to the ubuntu-apache world, and i have now tried to deploy my very first django website onto a webserver. First i got my IP to work with the site and could access it through there. Then i got my domain to work aswell without apache2 showing the default website.

Now that i have installed certbot and got the ssl certificate and got that to work with redirections ect. i have gotten a new problem.
Now i cannot get apache2 to load my website after installing the website.

I've got both my website.le.ssl.conf and website.conf enabled. If i try to disable the website.conf site nothing happens. If i disable the website-le-ssl.conf site, i cant access it because my browser wont allow me to access an unsecure page.

What could be the problem? I would like to have possibilities to investigate to learn how to fix the problem.

Kind Regards
Lasse Jonassen

4 Replies

Hi there,

The typical reason for this is that either the DocumentRoot for your website is incorrect or unreadable (so Ubuntu falls back to showing the default page) or the HTTP Host header (the domain) doesn’t match what’s configured, so again it falls back to the default page.

Can you post the contents of your website.conf and website-le-ssl.conf for us to have a look at, and the domain you’re using?

Hi @andysh,

Some of the lines are off because of the text-box.

NOTE:
I have tried to change the Document Root in the website-le-ssl.conf file to the exact path of my website/project. But when i do that i get the message forbidden - You don't have permission to access this resource.

here are my files:

website.conf

<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.mydomain.com</virtualhost>

ServerAdmin webmaster@localhost
DocumentRoot /home/lasse/lassejonassen/

# 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


Alias /static /home/lasse/lassejonassen/static
<Directory /home/lasse/lassejonassen/static>
    Require all granted
</Directory>

Alias /media /home/lasse/lassejonassen/media
<Directory /home/lasse/lassejonassen/media>
    Require all granted
</Directory>

<Directory /home/lasse/lassejonassen/lassejonassen>
    <Files wsgi.py>
        Require all granted
    </Files>
</Directory>

WSGIScriptAlias / /home/lasse/lassejonassen/lassejonassen/wsgi.py
WSGIDaemonProcess django_app python-path=/home/lasse/lassejonassen python-home=/home/lasse/lassejonassen/venv
WSGIProcessGroup django_app

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

vim: syntax=apache ts=4 sw=4 sts=4 sr noet

Website-le-ssl.conf
<ifmodule mod_ssl.c="">
<virtualhost *:443="">
# 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.mydomain.com</virtualhost></ifmodule>

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

Alias /static /home/lasse/lassejonassen/static
<Directory /home/lasse/lassejonassen/static>
    Require all granted
</Directory>

Alias /media /home/lasse/lassejonassen/media
<Directory /home/lasse/lassejonassen/media>
    Require all granted
</Directory>

<Directory /home/lasse/lassejonassen/lassejonassen>
    <Files wsgi.py>
        Require all granted
    </Files>
</Directory>

#WSGIScriptAlias / /home/lasse/lassejonassen/lassejonassen/wsgi.py
#WSGIDaemonProcess django_app python-path=/home/lasse/lassejonassen python-home=/home/lasse/lassejonassen/venv
#WSGIProcessGroup django_app

Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/www.mydomain.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/www.mydomain.com/privkey.pem


<ifmodule mod_ssl.c="">
<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.mydomain.com
Redirect permanent / https://www.mydomain.com/
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/</virtualhost></ifmodule>

# 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


Alias /static /home/lasse/lassejonassen/static
<Directory /home/lasse/lassejonassen/static>
    Require all granted
</Directory>

Alias /media /home/lasse/lassejonassen/media
<Directory /home/lasse/lassejonassen/media>
    Require all granted
</Directory>

<Directory /home/lasse/lassejonassen/lassejonassen>
    <Files wsgi.py>
        Require all granted
    </Files>
</Directory>

#WSGIScriptAlias / /home/lasse/lassejonassen/lassejonassen/wsgi.py
#WSGIDaemonProcess django_app python-path=/home/lasse/lassejonassen python-home=/home/lasse/lassejonassen/venv
#WSGIProcessGroup django_app

RewriteEngine on

Some rewrite rules in this file were disabled on your HTTPS site,

because they have the potential to create redirection loops.

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


Thanks for posting that.

For future reference, when you post code snippets or file contents, do it between 2 lines of 3 “back tick” characters, like this:

```
some code or file contents here
```

It’ll display much better! :) Getting back to your question…

DocumentRoot /home/lasse/lassejonassen

The default web server user doesn’t normally have access to other users’ home directories, possibly explaining the Forbidden response when you changed the DocumentRoot.

I usually like to use the /srv folder to hold my web (and other files served by services, like Git.)

Try creating a folder in there, like /srv/www and move your app folder into it, so it’s accessible at /srv/www/lassejonassen.

Then update the paths in your Apache config files to use /srv/www/lassejonassen instead of /home/lasse/lassejonassen.

Don’t forget you may need to change ownership of the files to www-data to allow Apache access to them and restart Apache when you’re done.

chown -R www-data:www-data /srv/www/lassejonassen
chmod -R 0755 /srv/www/lassejonassen
systemctl restart apache2

I have moved my files into the /var/www folder. So now the path if /var/www/lassejonassen. I have updated the apache2.conf with the path and my le-ssl.conf file aswell.
I dont know why it still keeps showing me the index of/ page.

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