Serendipity is a free and open source web-based content management system available under a BSD license.
It is written in PHP and uses PostgreSQL, MySQL, SQLite database backends. Serendipity comes with more than 80 official templates so your can completely customize your web site as per your requirements.
Serendipity is available in English, German, Danish, French and many more. You can use Serendipity as a single installation to serve multiple and independent weblogs.
In this tutorial, we will learn how to install Serendipity on Ubuntu 16.04 server.
Requirements
- A server running Ubuntu 16.04.
- A normal user with sudo privileges setup on your server.
Update the System
Before installing any packages, it is recommended to update your system with the latest stable version. You can do this with the following command:
sudo apt-get update -y
sudo apt-get upgrade -y
Once your system is up to date, you can proceed to install Nginx web server.
Install Nginx Web Server
You can install the latest version of the Nginx web server from the official Nginx repository.
You can add the Nginx repository by editing the /etc/apt/sources.list file:
sudo nano /etc/apt/sources.list
Add the following lines:
deb http://nginx.org/packages/ubuntu/ xenial nginx
deb-src http://nginx.org/packages/ubuntu/ xenial nginx
Save and close the file when you are finished, then update the repository with the following command:
sudo apt-get update -y
Once repository is up to date, install Nginx with the following command:
sudo apt-get install nginx -y
Next, start the Nginx service and enable it to start on boot time with the following command:
sudo systemctl start nginx
sudo systemctl enable nginx
Install PHP
Next, you will need to install PHP and other required modules to your server. You can install it by running the following command:
sudo apt-get install php7.0 php7.0-cli php7.0-fpm libapache2-mod-php7.0 php7.0-mbstring imagemagick wget unzip php7.0-curl php7.0-zip php7.0-gd php7.0-mysql php7.0-mcrypt php7.0-curl -y
Once all the packages are installed, you will need to make some changes in php.ini file:
sudo nano /etc/php/7.0/cli/php.ini
Change the following lines:
max_execution_time = 300
max_input_time = 300
memory_limit = 128M
post_max_size = 32M
upload_max_filesize = 32M
Save and close the file when you are finished.
Next, create a new PHP-FPM pool for your user.
sudo nano /etc/php/7.0/fpm/pool.d/www-data.conf
Add the following lines:
[www-data]
user = www-data
group = www-data
listen = 127.0.0.1:9000;
listen.owner = www-data
listen.group = www-data
listen.mode = 0666
pm = ondemand
pm.max_children = 5
pm.process_idle_timeout = 10s
pm.max_requests = 200
chdir = /
Save and close the file then restart PHP-FPM servcie with the following command:
sudo systemctl restart php7.0-fpm
Install and Configure MariaDB
You will need to install MariaDB server to store data. You can install it with the following command:
sudo apt-get install mariadb-server -y
Start MariaDB and enable it to automatically start at boot time.
sudo systemctl start mysql
sudo systemctl enable mysql
By default, MariaDB is not secured, so you will need to secure it first. You can secure it by running the mysql_secure_installation script.
sudo mysql_secure_installation
Answer all the questions as shown below:
Set root password? [Y/n] n
Remove anonymous users? [Y/n] y
Disallow root login remotely? [Y/n] y
Remove test database and access to it? [Y/n] y
Reload privilege tables now? [Y/n] y
Once MariaDB is secured, log in to the MySQL shell and create a database for Serendipity:
mysql -u root -p
Enter your root password when prompt, then create a database for Serendipity. It is recommended to set secure password:
MariaDB [(none)]>CREATE DATABASE serendipity_db;
Query OK, 1 row affected (0.00 sec)
Next, create a username and password for Serendipity with the following command:
MariaDB [(none)]>CREATE USER 'user'@'localhost' IDENTIFIED BY 'password';
Query OK, 1 row affected (0.00 sec)
Next, grant privileges to the serendipity database with the following command:
MariaDB [(none)]>GRANT ALL PRIVILEGES ON serendipity_db.* TO 'user'@'localhost';
Query OK, 1 row affected (0.00 sec)
Next, you will need to run the FLUSH PRIVILEGES command so that the privileges table will be reloaded by MariaDB and we can use new credential:
MariaDB [(none)]>FLUSH PRIVILEGES;
Query OK, 1 row affected (0.00 sec)
Next, exit from the MariaDB console with the following command:
MariaDB [(none)]>\q
Once you are done, you can proceed to the next step.
Download Serendipity
First, you will need to downlaod the latest version of the Serendipity. You can download Serendipity from GitHub repository with the following command:
wget https://github.com/s9y/Serendipity/archive/master.zip
Once the download is complete, unzip the downloaded file with the following command:
unzip Serendipity-master.zip
Next, move the extracted directory to the Nginx web root directory with the following command:
sudo cp -ar Serendipity-master /var/www/html/serendipity
Next, give proper permission to the serendipity directory:
sudo chown -R www-data:www:data /var/www/html/serendipity
Configure Nginx for Serendipity
Next, you will need to create a virtual server block for Serendipity. You can do this by creating serendipity.conf file inside /etc/nginx/sites-available/ d$
sudo nano /etc/nginx/sites-available/serendipity.conf
Add the following lines:
server {
listen 80;
server_name yourdomain.com;
root /var/www/html/serendipity/;
index index.php;
access_log /var/log/nginx/serendipity-access.log;
error_log /var/log/nginx/serendipity-error.log;
charset en_us.UTF-8;
location / {
error_page 404 = @serendipity; }
location @serendipity { rewrite ^(.*)$ /index.php?q=$1 last; }
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
Save and close the file when you are finished.
Next, test the nginx configuration and restart php7.0-fpm and Nginx services for the changes to take effect:
nginx -t
sudo systemctl restart php7.0-fpm
sudo systemctl restart nginx
Access Serendipity
Before accessing the Serendipity Web Interface, you will need to allow the HTTP service through UFW firewall.
By default UFW is disabled on your system, so you need to enable it first. You can enable it with the following command:
sudo ufw enable
Once UFW firewall is enabled, you can allow HTTP service by running the following command:
sudo ufw allow http
You can now check the status of UFW firewall by running the following command:
sudo ufw status
Next, Open your web browser and type the URL http://yourdomain.com, then complete the required steps to finish the installation
Congratulations! You have successfully installed Serendipity with Nginx on Ubuntu 16.04 server.