Table of Contents

Apache2 Configuration

The configuration is built from a DigitalOcean Droplet, preconfigured with LAMP and WordPress:

Core configuration

Note: If no site is “enabled” then a default entry seems to run hosting files under: /var/www/html

Site configuration file location(s):

# All configuration files
/etc/apache2/sites-available/
 
# Enabled sites
/etc/apache2/sites-enabled/

Enable/disable configurations:

# Disable
sudo a2dissite datablog.roman-halliday.com.conf
 
# Enable
sudo a2ensite datablog.roman-halliday.com.conf

File Ownership

Make sure all files are owned correctly:

# Site content owned by www-data so webserver can modify files
chown -R www-data:www-data /var/www
 
# Configuration owned by root for security
chown -R root:root /etc/apache2

Refresh Configuration

Use one of:

systemctl reload apache2
service apache2 reload

SSL - Let's Encrypt

SSL Encryption (the use of https over http) is a bit standard now, fortunately it's become a lot easier with the addition of Lets Encrypt.

If you configure the http (non secure) websites under /etc/apache2/sites-enabled/, then the certbot script will leverage Lets Encrypt to create certificates, configure them and create extra configuration files for the SSL (appending -le-ssl to the file name) and add a redirect to the original .conf file.

certbot --apache

Troubleshooting

PHP testing page

Hosting can be tested with the file:

index.php
<?php
// For backup, rename this for easy reference: php_info.php
phpinfo();
?>

Managing Page redirects/apache changes

So many problems with cache in browsers. Good to test with a browser which can have all data cleared, and do work in private browsing.

Using wget to test the apache configuration, see some extra samples and docs over at Computer Hope - Linux wget command.

# Run a command to get the default page, and view the http redirects as returned by the server
wget --verbose datablog.roman-halliday.com
 
# Reload apache configuration
sudo service apache2 reload

Bug: extra index

I had an extra index.html file from before. The old server prioritised php pages over php. This one the other way around. It took time to realise the reason I was not getting one of the wiki pages working was because of the extra index.html'' file.

<head>
        <title>Romanian - Roman-Halliday.com</title>
</head>
<body>
        <h1>Romanian</h1>
        <p>wiki will be here</p>
</body>