• Get In Touch
May 29, 2017

How to Install FlatPress on Ubuntu 14.04

Want your very own server? Get our 1GB memory, Xeon V4, 25GB SSD VPS for £10.00 / month.
Get a Cloud Server

FlatPress is a blogging engine that save posts as simple text files so we don’t need a database.

Several features of FlatPress:

  • Standard-compliant (XHTML valid)
  • No need to fiddle with SQL
  • Easy to backup! Just copy one directory
  • Easy plugin system
  • Widget support
  • Easy to customize with themes (powered by Smarty)

You can learn more about FlatPress from the FlatPress website.

Objective

In this tutorial we’ll learn how to install FlatPress on Ubuntu 14.04. We will also install and configure its prerequisites.

Prerequisites

We will install FlatPress on a fresh installation of Ubuntu Server 14.04. We also need these application to be able to run FlatPress:

  • Apache 2
  • PHP > 5.3.1

Update Base System

Before we install FlatPress, let’s update the system to the latest update.

$ sudo apt-get update
$ sudo apt-get -y upgrade

Install Apache 2

After applying latest update to our base system, Lets’s start installing Apache 2 and required libraries.

$ sudo apt-get -y install apache2 apache2-bin apache2-data apache2-mpm-prefork libaio1 libapr1 libaprutil1 libdbd-mysql-perl libdbi-perl libhtml-template-perl libterm-readkey-perl libwrap0 ssl-cert tcpd

We can check Apache 2 service status using command below:

sudo service apache2 status
 * apache2 is running

We can also check whether Apache 2 is listening on which port using command below.

 sudo netstat -naptu | grep apache
tcp6       0      0 :::80                   :::*                    LISTEN      14873/apache2

Install PHP 5

The last component that we have to install before we can install flatpress is PHP 5. We will install PHP 5 and several common PHP libraries.

$ sudo apt-get -y install php5-cli php5-common php5-json php5-readline

Restart Apache 2 process so the changes will be applied:

$ sudo service apache2 restart

Install Flatpress

All prerequisites are already installed. So we’re ready to install flatpress. The latest stable version of flatpress is available FlatPress download page.

At the time of this writing, the latest stable version is version 1.0.3, let’s download flatpress compressed file using wget.

$ wget -c https://github.com/evacchi/flatpress/archive/v1.0.3.tar.gz

Extract FlatPress archive:

$ tar xzf v1.0.3.tar.gz

Move flatpress-1.0.3 folder to Apache directory as flatpress.

$ sudo mv flatpress-1.0.3 /var/www/flatpress

Change ownership of flatpress directory to www-data user and group.

$ sudo chown -R www-data:www-data /var/www/flatpress

Flatpress files is ready, now let’s create Apache Virtual Host configuration to serve flatpress.

Configure Apache Virtual Host for http Only

Create new apache configuration file on /etc/apache2/sites-available/flatpress.conf with contents below.

<VirtualHost *:80>
    ServerName flatpress.exampleserver.xyz

    DocumentRoot /var/www/flatpress

    <Directory /var/www/flatpress>
        Options -Indexes +FollowSymLinks +MultiViews
        AllowOverride All
        Require all granted
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/flatpress.exampleserver.xyz-error.log
    CustomLog ${APACHE_LOG_DIR}/flatpress.exampleserver.xyz-access.log combined

</VirtualHost>

Don’t forget to change flatpress.exampleserver.xyz above with the domain name that you use for your flatpress installation.

Enable the site using a2ensite command.

$ sudo a2ensite flatpress

Reload the apache2 process so it read the new virtualhost configuration:

$ sudo service apache2 reload

FlatPress Installer

Open the FlatPress URL, we will be redirected to FlatPress installer.

First step, click Next

HP_NO_IMG/data/uploads/users/f94d86e4-8771-4484-b2df-35ce7fb402d0/1833882765.png” alt=”” />

Create admin user. input username, password email and FlatPress URL. Click Next

HP_NO_IMG/data/uploads/users/f94d86e4-8771-4484-b2df-35ce7fb402d0/1447541034.png” alt=”” />

Done. FlatPress installation finished.

HP_NO_IMG/data/uploads/users/f94d86e4-8771-4484-b2df-35ce7fb402d0/1617502886.png” alt=”” />

Our FlatPress site is ready.

HP_NO_IMG/data/uploads/users/f94d86e4-8771-4484-b2df-35ce7fb402d0/1756608998.png” alt=”” />

When we click login from the sidebar of the homepage we will get FlatPress login prompt.

HP_NO_IMG/data/uploads/users/f94d86e4-8771-4484-b2df-35ce7fb402d0/155997909.png” alt=”” />

After successfully login we will go to FlatPress administration are where we can manage our FlatPress site.

HP_NO_IMG/data/uploads/users/f94d86e4-8771-4484-b2df-35ce7fb402d0/1339753175.png” alt=”” />

Configure https only site for flatpress

Secure connection is now a requirement for web application.

Last step that we will do in this tutorial is changing the connection to only use https.

We assume that you already have SSL certificate and private key.

Let’s create new apache virtual host configuration on /etc/apache2/sites-available/flatpress-ssl.conf with contents below. Don’t forget to change:

  • ServerName
  • SSLCertificateFile
  • SSLCertificateChainFile
  • SSLCertificateKeyFile
<VirtualHost *:80>
   ServerName flatpress.exampleserver.xyz
   Redirect permanent / https://flatpress.exampleserver.xyz/
</VirtualHost>

<VirtualHost *:443>

    ServerName flatpress.exampleserver.xyz

    DocumentRoot /var/www/flatpress

    <Directory /var/www/flatpress>
        Options -Indexes +FollowSymLinks +MultiViews
        AllowOverride All
        Require all granted
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/flatpress.exampleserver.xyz-error.log
    CustomLog ${APACHE_LOG_DIR}/flatpress.exampleserver.xyz-access.log combined

    SSLEngine on
    SSLCertificateFile      /etc/apache2/ssl/flatpress.exampleserver.xyz.crt
    SSLCertificateChainFile /etc/apache2/ssl/flatpress.exampleserver.xyz.crt
    SSLCertificateKeyFile   /etc/apache2/ssl/flatpress.exampleserver.xyz.key

    # Uncomment the following directive when using client certificate authentication
    #SSLCACertificateFile    /path/to/ca_certs_for_client_authentication


    # HSTS (mod_headers is required) (15768000 seconds = 6 months)
    Header always set Strict-Transport-Security "max-age=15768000"

</VirtualHost>

 # intermediate configuration, tweak to your needs
SSLProtocol             all -SSLv2 -SSLv3
SSLCipherSuite          ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS
SSLHonorCipherOrder     on

We will also disable flatpress http only virtual host and enable the new virtual host config.

$ sudo a2dissite flatpress
$ sudo a2ensite flatpress-ssl

The new virtual host configuration need Apache mod_ssl and mod_headers modules. We need to enable those modules.

$ sudo a2enmod ssl
$ sudo a2enmod headers

Now, restart Apache 2 service so it will reload its configuration. We need to restart instead of reload since we enable new module.

$ sudo service apache2 restart

We need to change flatpress configuration to works with https.

Open /var/www/flatpress/defaults.php. Find this line

define('BLOG_BASEURL', 'http://'.$_SERVER['HTTP_HOST']. BLOG_ROOT);

Replace the http:// above with https://

Summary

In this tutorial we learned how to install flatpress on Ubuntu 14.04.

We installed all the prerequisites and also configure Apache 2 virtual hosts to be able to serve flatpress.

We also configure https settings for flatpress so we run FlatPress securely.

Want your very own server? Get our 1GB memory, Xeon V4, 25GB SSD VPS for £10.00 / month.
Get a Cloud Server

Share this Article!

Related Posts

Node.js Authentication – A Complete Guide with Passport and JWT

Node.js Authentication – A Complete Guide with Passport and JWT

Truth be told, it’s difficult for a web application that doesn’t have some kind of identification, even if you don’t see it as a security measure in and of itself. The Internet is a kind of lawless land, and even on free services like Google’s, authentication ensures that abuses will be avoided or at least […]

Node.js and MongoDB: How to Connect MongoDB With Node

Node.js and MongoDB: How to Connect MongoDB With Node

MongoDB is a document-oriented NoSQL database, which was born in 2007 in California as a service to be used within a larger project, but which soon became an independent and open-source product. It stores documents in JSON, a format based on JavaScript and simpler than XML, but still with good expressiveness. It is the dominant […]

Using MySQL with Node.js: A Complete Tutorial

Using MySQL with Node.js: A Complete Tutorial

Although data persistence is almost always a fundamental element of applications, Node.js has no native integration with databases. Everything is delegated to third-party libraries to be included manually, in addition to the standard APIs. Although MongoDB and other non-relational databases are the most common choice with Node because if you need to scale an application, […]

Node.Js Vs Django: Which Is the Best for Your Project

Node.Js Vs Django: Which Is the Best for Your Project

Django and NodeJs are two powerful technologies for web development, both have great functionality, versatile applications, and a great user interface. Both are open source and can be used for free. But which one fits your project best? NodeJs is based on JavaScript, while Django is written in Python. These are two equally popular technologies […]

Nodejs Vs PHP:  Which Works Best?

Nodejs Vs PHP: Which Works Best?

Before getting into the “battle” between Node.js and PHP we need to understand why the issue is still ongoing. It all started with the increased demand for smartphone applications, their success forcing developers to adapt to new back-end technologies that could handle a multitude of simultaneous requests. JavaScript has always been identified as a client-side […]