How to Install Automad CMS with Apache and Let's encrypt on Debian 10

Automad is a free, open-source and flat content management system written in PHP language. It is fast, responsive and offers features that may not be available to other PHP based CMS. Automad uses a text file to store its content instead of a database. Automad provides a web-based interface for managing site, system settings, upload images and write a blog post. It ships with a built-in Markdown editor and one-click updater to keep your Automad up-to-date.

In this tutorial, we will show you how to install Automad CMS on Debian 10 using Apache web server.

Requirements

  • A server running Debian 10.
  • A root password is set up to your server.

Getting Started

Before starting, you will need to update your system with the latest version. You can do this by running the following command:

apt-get update -y
apt-get upgrade -y

Once your server is updated, restart your server to apply the changes.

Install Apache and PHP

Automad is based on PHP and runs on a web server. So you will need to install Apache, PHP and other required modules to your server. You can install all of them by running the following command:

apt-get install apache2 php libapache2-mod-php php-zip php-curl php-mbstring php-gd php-xml php-xmlrpc php-soap unzip -y

Once all the packages are installed, start Apache web server and enable it to start on system reboot with the following command:

systemctl start apache2
systemctl enable apache2

Once you have done, you can proceed to the next step.

Install Automad

First, you will need to download the latest version of Automad from the Bitbucket repository. You can download it with the following command:

wget https://bitbucket.org/marcantondahmen/automad/get/default.zip

Once the download is completed, extract the downloaded file with the following command:

unzip default.zip

Next, move the extracted directory to the Apache web root with the following command:

mv marcantondahmen-automad-c241e88edc3c /var/www/html/automad

Next, change the ownership of automad directory to www-data and give proper permission with the following command:

chown -R www-data:www-data /var/www/html/automad
chmod -R 755 /var/www/html/automad

Once you have done, you can proceed to the next step.

Configure Apache for Automad

Next, you will need to create an Apache virtual host configuration file to server Automad. You can create it with the following command:

nano /etc/apache2/sites-available/automad.conf

Add the following content:

<VirtualHost *:80>
     ServerAdmin [email protected]
     DocumentRoot /var/www/html/automad
     ServerName example.com

     <Directory /var/www/html/automad>
          Options FollowSymlinks
          AllowOverride All
          Require all granted
     </Directory>

     ErrorLog ${APACHE_LOG_DIR}/automadcms_error.log
     CustomLog ${APACHE_LOG_DIR}/automadcms_access.log combined

</VirtualHost>

Save and close the file, when you are finished. Then, check Apache for any syntax error with the following command:

apachectl configtest

If everything is fine, you should get the following output:

AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
Syntax OK

Next, enable the Apache virtual host and rewrite module with the following command:

a2ensite automad
a2enmod rewrite

Finally, restart Apache web server to apply the configuration changes:

systemctl restart apache2

Once you have finished, you can proceed to the next step.

Access Automad

Automad is now installed and configured, it's time to access Automad web interface.

Open your web browser and type the URL http://example.com. You will be redirected to the Automad site in the following screen:

Front page of Automad CMS

To create an Automad account, open your web browser and visit the URL http://example.com/dashboard. You will be redirected to the following page:

Create user

Move account file

Now, provide your desired username and password, then click on the Download Accounts File button to download the user registration form and copy it inside config directory:

mv config.php /var/www/html/automad/config/

Next, give proper permission to config.php file with the following command:

chown -R www-data:www-data /var/www/html/automad/config/config.php

Now, open your web browser and type the URL http://example.com/dashboard. You should see the Automad login page:

Login to your site

Now, provide your username and password, and click on the Log In button. You should see the Automad CMS default dashboard in the following page:

Your site in Automad

Secure Automad with Let's Encrypt

First, you will need to install Certbot tool to download and install Let's Encrypt free SSL for your website.

First, add the Certbot repository with the following command:

apt-get install software-properties-common
add-apt-repository ppa:certbot/certbot

Next, update the repository and install Certbot with the following command:

apt-get update -y
apt-get install certbot python-certbot-apache -y

Once installed, you will need to create a .well-known directory inside letsencrypt directory. You can create it with the following command:

mkdir -p /var/lib/letsencrypt/.well-known

Next, you will need to give proper permissions to letsencrypt directory. You can do it with the following command:

chgrp www-data /var/lib/letsencrypt
chmod g+s /var/lib/letsencrypt

Next, create a well-known.conf file with the following command:

nano /etc/apache2/conf-available/well-known.conf

Add the following lines:

Alias /.well-known/acme-challenge/ "/var/lib/letsencrypt/.well-known/acme-challenge/"
<Directory "/var/lib/letsencrypt/">
    AllowOverride None
    Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
    Require method GET POST OPTIONS
</Directory>

Save and close the file. Then, enable the required modules with the following command:

a2enmod ssl
a2enmod http2
a2enmod headers
a2enconf well-known

Next, restart Apache service to apply all the configuration changes:

systemctl restart apache2

Now, install Let's Encrypt free SSL for your domain example.com by running the following command:

certbot --apache -d example.com

First, you will need to provide a valid email address and agree to the terms of service as shown below:

Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator apache, Installer apache
Enter email address (used for urgent renewal and security notices) (Enter 'c' to
cancel): [email protected]

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
agree in order to register with the ACME server at
https://acme-v02.api.letsencrypt.org/directory
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(A)gree/(C)ancel: A

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let's Encrypt project and the non-profit
organization that develops Certbot? We'd like to send you email about our work
encrypting the web, EFF news, campaigns, and ways to support digital freedom.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: Y
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for example.com
Enabled Apache rewrite module
Waiting for verification...
Cleaning up challenges
Created an SSL vhost at /etc/apache2/sites-available/example.com-le-ssl.conf
Deploying Certificate to VirtualHost /etc/apache2/sites-available/example.com-le-ssl.conf
Enabling available site: /etc/apache2/sites-available/example.com-le-ssl.conf

Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: No redirect - Make no further changes to the webserver configuration.
2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
new sites, or if you're confident your site works on HTTPS. You can undo this
change by editing your web server's configuration.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2

Next, choose option 2 to download and install a free SSL certificate for your domain. Once the installation has been completed successfully. You should get the following output:

Enabled Apache rewrite module
Redirecting vhost in /etc/apache2/sites-enabled/example.com.conf to ssl vhost in /etc/apache2/sites-available/
example.com-le-ssl.conf

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled https://example.com

You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=example.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/example.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/example.com/privkey.pem
   Your cert will expire on 2019-10-22. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot again
   with the "certonly" option. To non-interactively renew *all* of
   your certificates, run "certbot renew"
 - Your account credentials have been saved in your Certbot
   configuration directory at /etc/letsencrypt. You should make a
   secure backup of this folder now. This configuration directory will
   also contain certificates and private keys obtained by Certbot so
   making regular backups of this folder is ideal.
 - If you like Certbot, please consider supporting our work by:
   Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
   Donating to EFF:                    https://eff.org/donate-le

Your Automad CMS is now secured with Let's Encrypt free SSL. You can access it by visiting the URL https://example.com.

Share this page:

0 Comment(s)