Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

How to install Serendipity with Nginx on an Ubuntu 16.04 VPS

In this tutorial, we are going to provide you with step-by-step instructions on how to install Serendipity with Nginx on an Ubuntu 16.04 Virtual Server.
Serendipity is a simple and easy to use CMS (content management system) written in PHP. Serendipity offers more than 80 official templates so your can completely customize your web site according to your needs with a click of a button. The installation process should take about 5-10 minutes if you follow the very easy steps described below.

Make sure your package list and the OS packages are up to date by running the following commands:

sudo apt-get update
sudo apt-get upgrade

To install the latest Nginx version from the official Nginx repository, edit the ‘/etc/apt/sources.list’ file:

sudo vi /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

Install MySQL:

sudo apt-get install -y mariadb-server

Stop and remove Apache service:

sudo service apache2 stop
sudo apt-get remove apache2

Install Nginx on your virtual server:

sudo apt-get update
sudo apt-get install nginx

Configure Nginx to start on boot:

sudo update-rc.d -f nginx defaults

Install Imagemagick binary:

sudo apt-get install imagemagick

Install PHP and PHP modules required by Serendipity:

sudo apt-get install php7.0 php7.0-cli php7.0-fpm libapache2-mod-php7.0 php7.0-mbstring php7.0-curl php7.0-zip php7.0-gd php7.0-mysql php7.0-mcrypt php7.0-curl

Then, start with the Serendipity installation procedure. Get the latest version of Serendipity available at their official Github repo to a directory of your virtual server and extract it using the following commands:

sudo apt-get install wget unzip
cd /opt/
wget https://github.com/s9y/Serendipity/releases/download/2.0.3/serendipity-2.0.3.zip
unzip serendipity-2.0.3.zip
mkdir -p /var/www/html
mv serendipity /var/www/html

Create a new Nginx configuration file and add the following virtual block for your domain name:

vi /etc/nginx/conf.d/your-domain.com.conf

Add the following lines:

server {
listen 80;
server_name your-domain.com;
root /var/www/html/serendipity/;
index index.php;
access_log /var/log/nginx/your-domain.com-access.log;
error_log /var/log/nginx/your-domain.com-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;
}
}

Do not forget to replace your-domain.com with your actual domain name. Then, delete the ‘default’ Nginx configuration file:

rm /etc/nginx/conf.d/default.conf

Open the ‘/etc/php/7.0/fpm/pool.d/www.conf’ file and change the ‘listen’ variable:

change:

listen = /run/php/php7.0-fpm.sock

to

listen = 127.0.0.1:9000;

Locate the PHP configuration file:

# php -i | grep -i php.ini
Configuration File (php.ini) Path => /etc/php/7.0/cli
Loaded Configuration File => /etc/php/7.0/cli/php.ini

Edit the ‘/etc/php/7.0/cli/php.ini’ configuration file:

vi /etc/php/7.0/cli/php.ini

Add/modify the following settings:

max_execution_time = 300
max_input_time = 300
memory_limit = 128M
post_max_size = 32M
upload_max_filesize = 32M

The web server user (www-data) needs to be able to write to files and directories inside the ‘/var/www/serendipity’ directory, so it can easily be accomplished by executing the following command:

sudo chown www-data:www-data -R /var/www/html/serendipity/

Test the nginx configuration:

# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

If test is successful, restart php7.0-fpm and Nginx services for the changes to take effect:

sudo service php7.0-fpm restart
sudo service nginx restart

Serendipity requires a database to work as this is where data is saved, so create a new MySQL database:

[user]$ mysql -u root -p

MariaDB [(none)]> CREATE DATABASE serendipity;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON serendipity.* TO 'serendipityuser'@'localhost' IDENTIFIED BY 'your-password';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> \q

Do not forget to replace ‘your-password’ with a strong password.

Open http://your-domain.com/ using your favorite web browser and follow the easy instructions. Once installed, log in to the administrator back-end and configure Serendipity according to your needs.

That is it. The Serendipity installation is now complete


PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.



This post first appeared on Virtual-Server.org Virtual Server, please read the originial post: here

Share the post

How to install Serendipity with Nginx on an Ubuntu 16.04 VPS

×

Subscribe to Virtual-server.org Virtual Server

Get updates delivered right to your inbox!

Thank you for your subscription

×