How to Install Flatpress CMS with Let's Encrypt SSL on Ubuntu 22.04

FlatPress is a free and open source and the fastest content management system. It is written in PHP language and is a great tool for anyone that doesn't have database access. It is a lightweight, easy-to-set-up blogging engine and great in the social & communications category. It supports multiple languages, plugins, themes, widgets, and much more.

In this tutorial. I am going to explain how to install FlatPress on Ubuntu 22.04 server.

Requirements

  • A server running Ubuntu 22.04.
  • A non-root user with sudo privileges.

Install Apache and PHP

By default, PHP 8.1 is the default PHP version in Ubuntu 22.04. But, FlatPress supports only the PHP 8.0 version. So, you will need to add the PHP repository to your system. You can add it with the following command:

apt install software-properties-common -y
add-apt-repository ppa:ondrej/php

Once the repository is added, install Apache, PHP, and all required PHP extensions by running the following command:

apt-get install apache2 php8.0 php8.0-mysql php8.0-curl php8.0-cgi libapache2-mod-php8.0 php8.0-mcrypt php8.0-xmlrpc php8.0-gd php8.0-mbstring php8.0 php8.0-common php8.0-xmlrpc php8.0-soap php8.0-xml php8.0-intl php8.0-cli php8.0-ldap php8.0-zip php8.0-readline php8.0-imap php8.0-tidy php8.0-sql php8.0-intl wget unzip -y

After installing all the packages, start the Apache service and enable it to start on boot time with the following command:

systemctl start apache2
systemctl enable apache2

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

Install FlatPress

First, visit the FlatPress Git repository and download the latest version with the following command:

wget https://github.com/flatpressblog/flatpress/archive/1.2.1.zip

Next, unzip the downloaded file with the following command:

unzip 1.2.1.zip

Next, copy the extracted directory to the Apache root directory and give proper permissions with the following command:

cp -r flatpress-1.2.1 /var/www/html/flatpress
chown -R www-data.www-data /var/www/html/flatpress
chmod -R 775 /var/www/html/flatpress

Configure Apache for FlatPress

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

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

Add the following lines:

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

     <Directory /var/www/html/flatpress/>
          AllowOverride All
          Require all granted
     </Directory>

     ErrorLog ${APACHE_LOG_DIR}/flatpress_error.log
     CustomLog ${APACHE_LOG_DIR}/flatpress_access.log combined

</VirtualHost>

Save and close the file. Then, enable the virtual host with the following command:

a2ensite flatpress

Next, enable the Apache rewrite module and reload the Apache service with the following command:

a2enmod rewrite
systemctl restart apache2

You can also check the Apache status with the following command:

systemctl status apache2

You should see the following output:

? apache2.service - The Apache HTTP Server
     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
     Active: active (running) since Sun 2022-11-20 11:37:30 UTC; 6s ago
       Docs: https://httpd.apache.org/docs/2.4/
    Process: 100768 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
   Main PID: 100772 (apache2)
      Tasks: 6 (limit: 2242)
     Memory: 14.3M
        CPU: 85ms
     CGroup: /system.slice/apache2.service
             ??100772 /usr/sbin/apache2 -k start
             ??100773 /usr/sbin/apache2 -k start
             ??100774 /usr/sbin/apache2 -k start
             ??100775 /usr/sbin/apache2 -k start
             ??100776 /usr/sbin/apache2 -k start
             ??100777 /usr/sbin/apache2 -k start

Nov 20 11:37:30 ubuntu2204 systemd[1]: Starting The Apache HTTP Server...

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

Secure FlatPress with Let's Encrypt SSL

It is a good idea to secure your FlatPress site with a Let's Encrypt SSL certificate. To do so, you will need to install the Certbot client in your system. Certbot is a client package that helps you to download and manage SSL certificates on your website.

You can install the Certbot with the following command:

apt-get install certbot python3-certbot-apache -y

Once the Certbot client has been installed successfully, run the following command to install the Let's Encrypt SSL for your website:

certbot --apache -d flatpress.example.com

You will be asked to provide your valid email and accept the term 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 flatpress.example.com
Enabled Apache rewrite module
Waiting for verification...
Cleaning up challenges
Created an SSL vhost at /etc/apache2/sites-available/flatpress-le-ssl.conf
Enabled Apache socache_shmcb module
Enabled Apache ssl module
Deploying Certificate to VirtualHost /etc/apache2/sites-available/flatpress-le-ssl.conf
Enabling available site: /etc/apache2/sites-available/flatpress-le-ssl.conf

Next, select whether or not to redirect HTTP traffic to HTTPS or configure Nginx to redirect all traffic to secure HTTPS access as shown in the following output:

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

Type 2 and hit Enter to start the process. Once the installation is completed, you should get the following output:

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

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

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

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/flatpress.example.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/flatpress.example.com/privkey.pem
   Your cert will expire on 2023-02-20. 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"
 - 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

At this point, your FlatPress site is secured with Let's Encrypt SSL. You can now access your site securely using HTTPS protocol.

Access FlatPress CMS

Now, open your web browser and type the URL https://flatpress.example.com. You will be redirected to the FlatPress installation page:'

FlatPress CMS Installer

Now, click on the Next button. You should see the Admin user creation page:

Create a user

Here, provide your admin username, password, email  and click on the Next button. You should see the following page:

FlatPress Installation finished

Click on the Login now button. You should see the following page:

FlatPress Login

Provide your admin username, password and click on the Login button. You should see the following page:

FlatPress Admin

Conclusion

This tutorial explained how to install FlatPress with Apache and Let's Encrypt SSL on Ubuntu 22.04. You can now create a simple and fast website and blog using the FlatPress CMS. Feel free to ask me if you have any questions.

Share this page:

1 Comment(s)