By Sai Sarath Chandra, Alibaba Cloud Community Blog author
Serendipity is a PHP-powered weblog engine that gives users an easy way to maintain a blog. Before diving into the details of Serendipity, let's take a quick overview of PHP. Hypertext Preprocessor (PHP) is a general-purpose programming language originally designed for web development. It is one of the most powerful languages as it is very easy to learn and maintain. Already adopted by many, it's also a highly popular client-server, web-based programming languages. PHP looks elegant even when compared to modern web development languages like JavaScript.
While the default package of Serendipity is designed for casual bloggers, it offers an expandable framework to empower professional applications. Serendipity offers a bunch of features to support developers and users.
Its robust WYSIWYG editor features an image manager, extended entry support and allows using any language, such as Markdown and Textile.
Unlike other content management systems (CMSs), Serendipity allows accepting, sending and auto discovering the trackbacks and pingbacks. This functionality ensures that you get a notification whenever you react to articles in other blogs, as well as when another blogger links to your article.
Serendipity also supports multiple databases and therefore, allows moving beyond the MySQL database. Instead, it lets you use the PostgreSQL and SQLite database as the backend. It fulfills all the certifications, including HTML5, CSS3, RSS2.0, and Atom. 1.0. Additionally, it effectively supports conditional GET for caching RSS feeds on the client-side with UTF-8 environments.
This tutorial explores how to set up Serendipity on Alibaba Cloud Elastic Compute Service (ECS) with Ubuntu 16.04 (64-bit) system image installed.
If you don't know how to set up ECS instance, refer to this tutorial or a quick-start guide.
Access the ECS instance via Putty using the following details.
IP: ECS Instance Internet IP Address
Port: 22
Username: Root
Password: Provided at run time
For any Linux devices like Macintosh/Ubuntu, log in using SSH as shown below.
ssh root@149.129.ABC.XYZ
The authenticity of host '149.129.ABC.XYZ (149.129.ABC.XYZ)' can't be established.
ECDSA key fingerprint is SHA256:tyuWLYqL7IwGNdvD8e3THTSMyHlNPkMBdCkMf5D/ifw.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '149.129.ABC.XYZ' (ECDSA) to the list of known hosts.
root@149.129.ABC.XYZ's password:
Enter the password to proceed.
Welcome to Ubuntu 16.04.4 LTS (GNU/Linux 4.4.0-117-generic x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
Welcome to Alibaba Cloud Elastic Compute Service!
Let's start by updating and upgrading the Serendipity package using the commands below.
root@SERENDIPITY:~# sudo apt-get update -y
root@SERENDIPITY:~# sudo apt-get upgrade -y
Next, install the latest version of the Nginx web server from the official repository. Update the official source link in the source file as shown below.
root@SERENDIPITY:~# sudo nano /etc/apt/sources.list
Considering we are working with Ubuntu 16.04 version for this tutorial, update the file with the following content.
deb http://nginx.org/packages/ubuntu/ xenial nginx
deb-src http://nginx.org/packages/ubuntu/ xenial nginx
In case, you are using Ubuntu 18.04 version then update the file with the following content.
deb http://nginx.org/packages/ubuntu/ bionic nginx
deb-src http://nginx.org/packages/ubuntu/ bionic nginx
Execute the below commands to install Nginx.
sudo apt-get update
sudo apt-get install nginx
Now start and enable the Nginx service. Check whether the following error occurs while starting the service.
root@SERENDIPITY:~# sudo systemctl start nginx
Failed to start nginx.service: Unit nginx.service not found.
In case the preceding error occurs, repeat the installation process by executing the command below.
root@SERENDIPITY:~# sudo apt-get install nginx -y --allow-unauthenticated
Note: It is not recommended on the production environment.
Next, let's install PHP by executing the following commands.
root@SERENDIPITY:~# 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
Post package installation, run the following command to make some changes in the php-ini file.
root@SERENDIPITY:~# sudo nano /etc/php/7.0/cli/php.ini
Now update the following file fields with the respective values shown below.
max_execution_time = 300
max_input_time = 300
memory_limit = 128M
post_max_size = 32M
upload_max_filesize = 32M
Next, create the PHP-FPM pool for the user.
root@SERENDIPITY:~# sudo nano /etc/php/7.0/fpm/pool.d/www-data.conf
[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 = /
Restart the FPM modules by running the command below.
root@SERENDIPITY:~# sudo systemctl restart php7.0-fpm
Install and Configure the MariaDB by executing the following command.
root@SERENDIPITY:~# sudo apt-get install mariadb-server -y
After successful installation, start and enable MariaDB using the following commands.
root@SERENDIPITY:~# sudo systemctl start mysql
root@SERENDIPITY:~# sudo systemctl enable mysql
Next, install the MySQL by running the command below.
root@SERENDIPITY:~# sudo mysql_secure_installation
Answer the following questions as per your requirements. The following snippet shows the answers for this tutorial.
Change the root password? [Y/n] Y
Remove anonymous users? [Y/n] Y
Disallow root login remotely? [Y/n] n
Remove test database and access to it? [Y/n] n
Reload privilege tables now? [Y/n] Y
Post successful installation, create a user and database as well as grant privileges to the same by implementing the steps below.
Step 1: Login into the Database
root@SERENDIPITY:~# mysql -u root -p
Enter Password.
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 47
Server version: 10.0.36-MariaDB-0ubuntu0.16.04.1 Ubuntu 16.04
Step 2: Create a Database
MariaDB [(none)]> CREATE DATABASE serendipity_db;
Query OK, 1 row affected (0.00 sec)
Step 3: Create a User
MariaDB [(none)]> CREATE USER 'user'@'localhost' IDENTIFIED BY 'password';
Query OK, 0 rows affected (0.00 sec)
Step 4: Grant User Privileges
MariaDB [(none)]> GRANT ALL PRIVILEGES ON serendipity_db.* TO 'user'@'localhost';
Query OK, 0 rows affected (0.00 sec)
Step 5: Reflect Changes
MariaDB [(none)]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.01 sec)
Download the latest distribution of the Serendipity package as shown below.
root@SERENDIPITY:~# wget https://github.com/s9y/Serendipity/archive/master.zip
Also, install the "unzip" package to extract the downloaded package by running the following commands.
root@SERENDIPITY:~# apt install unzip
root@SERENDIPITY:~# unzip Serendipity-master.zip
Now, run the following command to move the directory and all its content to the Nginx web root directory.
root@SERENDIPITY:~# sudo cp -ar Serendipity-master /var/www/html/serendipity
Next, give the permissions to Serendipity by executing the command below.
root@SERENDIPITY:~# sudo chown -R www-data:www-data /var/www/html/serendipity
Now to configure Nginx, create a file "serendipity.conf
" in the Nginx directory as shown below.
root@SERENDIPITY:/etc/nginx# sudo nano serendipity.conf
Update the file content with the following information.
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;} }
Lastly, restart the Nginx to reflect the changes by executing the command below.
root@SERENDIPITY:~# sudo systemctl restart nginx
There you go! You have successfully set up Serendipity on your Alibaba Cloud ECS Ubuntu Instance.
Access the website using https://<ECS-Internet-IP>/
.
How to Install Hugo Static Site Generator on Alibaba Cloud ECS
2,599 posts | 762 followers
FollowAlibaba Clouder - July 5, 2019
Alibaba Clouder - July 5, 2019
Alibaba Clouder - July 5, 2019
Alibaba Clouder - January 15, 2019
Alibaba Clouder - January 17, 2019
Alibaba Clouder - May 21, 2018
2,599 posts | 762 followers
FollowAutomate performance monitoring of all your web resources and applications in real-time
Learn MoreExplore Web Hosting solutions that can power your personal website or empower your online business.
Learn MoreExplore how our Web Hosting solutions help small and medium sized companies power their websites and online businesses.
Learn MoreElastic and secure virtual cloud servers to cater all your cloud hosting needs.
Learn MoreMore Posts by Alibaba Clouder