Apache2 now pointing to new default page

My Apache2 server has a new default page: Apache2 Ubuntu Default Page (located at /var/www/html/index.html)

All my webserver served files are at: /opt/lampp/htdocs folder.

Why has this change happened and how to fix it?

3

1 Answer

Apache2 from the Ubuntu repository gets it's default location from /etc/apache2/sites-available.

The default page configuration is the 000-default.conf file in that location.

You can either modify that page or use it as a template and make your own configuration file. If you want to have a page with the location of /opt/lampp/htdocs as it's server route you can do that in this manner:

1) Copy the 00-default.conf file to a new name. For an easy method to remember to purpose, you can call the filename, mywebsite.conf to have the configuration for .

Now edit this new page with these changes:

Change from:

<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 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

change to:

<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 ServerAlias mywebsite.com ServerAdmin webmaster@localhost DocumentRoot /opt/lampp/htdocs # We must also allow access to the new root directory; by # default only access to /var/www is allowed. <Directory /opt/lampp/htdocs> Require all granted </Directory> # 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

After you have created the virtual host for your website, enable this new configuration with:

$ sudo a2ensite mywebsite.conf

The system will then prompt you to restart the server for the changes to take effect, which you can do with:

$ sudo systemctl restart apache2

The two important changes are:

  1. ServerName
  2. DocumentRoot

Now you can you will be able to access your website by the name given in the ServerName or the ServerAlias directives.

I left the comments in the configuration files example to show the options that can be enabled by removing the "#" desired option. Also the comments are a valuable resource explaining the configuration options.

12

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like