How to Install Pagekit CMS on CentOS 7.4, Part 1: LAMP Stack Setup
How to Install Pagekit CMS on CentOS 7.4, Part 1: LAMP Stack Setup
Explore how to install Pagekit CMS on CentOS 7.4.
Join the DZone community and get the full member experience.Join For Free
Pagekit is a modern, open-source, and free content management system (CMS). It provides a central place "Site Tree" to manage all of your content. You can make your menus, edit or update your pages, and add or remove widgets.
Pagekit provides a dashboard to provide your quick access to your content. It also provides you with an HTML and Markdown editor to provide you with a full-screen experience of code along with highlighting syntax. You can easily insert media including videos through the file manager.
Pagekit uses Data-reactive components with Vue.js for user interface development. It employs modular architecture and package management using Composer. It also comes with a monitoring system that helps to debug easily.
Pagekit CMS does not restrict its installation to any specific operating system (OS). You can use any operating system (OS) of your choice; however, the installation steps would vary according to the choice of operating system.
In this tutorial, we will host my Pagekit CMS on an Alibaba Cloud Elastic Compute Service(ECS) instance with CentOS 7.4 installed on it.
This tutorial is divided into 2 sub-tutorials.
- In the first part, we will add a super user, set up firewalls, set up Apache Server, MariaDB Server, install PHP 7 and its various modules, and install various other necessary packages.
- In the second part, we will learn to configure your domain, creating a virtual host and installing Let's Encrypt SSL to our website. We will also be installing Pagekit CMS and configuring it.
- You must have Alibaba Cloud Elastic Compute Service (ECS) activated and verified your valid payment method. If you are a new user, you can get free $300 credits in your Alibaba Cloud account. If you don't know about how to set up your ECS instance, you can refer to this tutorial.
- A domain name registered from Alibaba Cloud. If you have already registered a domain from Alibaba Cloud or any other host, you can update its domain nameserver records.
- You should setup your server's hostname.
- Access to VNC console in your Alibaba Cloud or SSH client installed in your PC.
Add a User with Root Privileges
After completing the prerequisites, log in as root user with your root username and password via SSH client (e.g. Putty — You can get Putty from https://www.putty.org ) or VNC console available in your Alibaba Cloud account dashboard.
In the first step, you will add a new user and give it sudo privileges. Sudo privileges will allow this username to make administrative changes on the system when required. This user will be used to login from via SSH for everyday use. Once you have added this user, to keep your server secure from various attacks, you will disable the remote root access to root user.
- To create a new user account, use the following command:
# useradd aareezwhere "aareez" can be any username of your choice.
- Now set your desired password for your chosen username. In my case, username was "aareez". When you will enter the following command, you will be prompted to enter a new password for your added username.
# passwd aareez
- Now assign username to sudo user's group to give administrative privileges. For this, we will check /etc/sudoers file and see whether sudoers group is enabled or not. For this purpose, we will execute the following command.
- After executing the above command, a file will be opened, find the following lines in the opened file.
Sometimes, by default, the second line %wheel ALL=(ALL) ALL is commented (starting with hash #), due to which even after adding username to sudoers, it gives an error on using sudo. To prevent this issue, if this line starts with '#' sign, remove this symbol and save the changes by typing :x and then hit Enter to save.
- Now you will add your username "aareez" to the "wheel" group by executing the following command:
# usermod -aG wheel aareezAfter execution of the above command, you can verify the membership of for that group by executing the following command:
# groups aareezYour username has been successfully added to sudoers group and it is able to make any administrative change.
- Now, log in by using your new username and password. OR Use the following command to switch user:
# su – aareezYou can see that you have been logged in from your new account now. If you want to verify this, you can use the command below:
Update Your CentOS 7 System
Before proceeding with installation of any kind of package, use the following command to update your CentOS system. To execute this command, remember to log in from non-root user with sudo privileges.
# sudo yum -y update
You will be prompted to enter your password. Now type your password and hit Enter key and wait for updating.
Now you have successfully updated your CentOS system. Your next step is to install Apache Web Server.
Install Nano Editor
You can edit any file easily using Nano editor due to its ease of use. To install Nano editor, execute the command below:
# sudo yum install nano
To install epel-release, execute the command below:
# sudo yum install epel-release
Note: You can use either Apache or NGINX for your LAMP (LEMP) stack. In this tutorial, I will be using an Apache Web Server to install PageKit CMS.
Install Apache Web Server
- To install the apache web-server, you will need to execute the following command:
# sudo yum -y install httpd
- After installation, you will need to enable apache server to run automatically when you boot your ECS. For that, execute the commands below:
# sudo systemctl enable httpd
- To start your apache server, execute the following command:
# sudo systemctl start httpd
- To ensure that your DocumentRoot directive is pointing to correct directory, check your Apache configuration file by using the following command:
# sudo nano /etc/httpd/conf/httpd.confNote: The configuration for DocumentRoot should look as DocumentRoot /var/www/html Press Ctrl + X, to exit from editor.
- Now open 00-base.conf by executing the following command and search for mod_rewrite to check either this module is loaded correctly or not.
# sudo nano /etc/httpd/conf.modules.d/00-base.confIf mod_rewrite module is already loaded, you will see the following line: LoadModule rewrite_module modules/mod_rewrite.so Semi-colon is used for commenting a line in any Apache module. If the above lines starts with a semi-colon (;), remove the semi-colon and uncomment the line.
- Now to make mod_rewrite work correctly with your PageKit CMS, you will need to edit Apache's configuration. To open the file for editing, use the command below:
# sudo nano /etc/httpd/conf/httpd.conf
- Find section <Directory "/var/www/html"> and modify the value for AllOverridefrom AllowOverride none to AllowOverride All. After modification, the section will look like:
<Directory "/var/www/html"> Options Indexes FollowSymLinks AllowOverride All Require all granted </Directory>
- Now save the changes done by pressing Ctrl+X, then press 'Y' and then hit Enter key. Your changes have been saved.
- To make the changes work correctly, we will need to restart apache. To do so, execute the command below:
# sudo systemctl restart httpd
- To verify, you have successfully installed Apache Web Server. Open https://184.108.40.206 in your web browser where 220.127.116.11 is my ECS IP address. Remember to replace it with your ECS IP address. You will see the following page.
Setup Firewalls for HTTP and HTTPS
- If you have activated firewalls, you will have to define a rule in Alibaba Cloud security group for your cloud server to add an exception for port 80/tcp, 443/tcp. You can enable these ports while creating ECS instance, but in case, if you have forgotten to unblock these ports, you can follow the procedure below. By default, these ports are blocked by the firewalls. To do this, go to your Elastic Compute Service section. Click on More for the ECS you are using for ImpressPages CMS and click Security Group Configuration. Click on Configure Rules and then click on Quickly Create Rules. Add the configurations as shown in the screenshot below and click OK.
Disable SELinux (Security Enhanced Linux)
You will have to disable SELinux to avoid any type of permissions related issues for PageKit CMS. To do so, first of all, check whether SELinux is enabled or disabled. To check, use the following command:
# sudo sestatus
It is disabled by default in Alibaba Cloud ECS. However, if you had made any changes previously to your ECS, you may need to follow this step. If status is disabled, skip this step. Otherwise, open the file using the following command:
# sudo nano /etc/selinux/config
Change SELINUX=enforcing to SELINUX=disabled
After disabling SELinux, you will have to reboot your ECS.
Install PHP 7.1
- To install PHP 7.1 on CentOS, you will need to add an external repository. To do so, run the following command:
# sudo rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
- After adding repository, install PHP 7.1 along with modules required by PageKit CMS. Execute the following command to do so:
# sudo yum install -y php71w php71w-cli php71w-fpm php71w-common php71w-mbstring php71w-zip php71w-mysql php71w-sqlite3 php71w-curl php71w-simplexml php71w-xml
Install MariaDB Server
- In replacement of MySQL server, Debian uses MariaDB server by default. To install MariaDB, use the following command:
# sudo apt-get -y install mariadb-serverYou can also use Alibaba Cloud Aspara DB for RDS as an alternative. Alibaba Cloud AsparaDB for RDS frees you from managing a database and you can focus on your business. It also provides protection against SQL injections, network attacks, brute force attacks and many other types of database attacks. It is highly scalable, highly available, and easy to use.
- After successful installation, enable MariaDB server to start automatically when system reboot. To do so, use the following command:
# sudo systemctl enable mariadb
- To start MariaDB server, execute the command below:
# sudo systemctl start mariadb
- Now to secure your MariaDB server, execute the command:
# sudo mysql_secure_installationThe root password will be blank by default, just hit enter button to proceed and select 'Y' and choose your password. You have successfully secured your MariaDB server.
- To unzip any zip folder, you will require an unzipping tool. To do so, use the following command:
# sudo yum -y install unzip
We have successfully installed LAMP Stack and other necessary packages to continue with the second part of this tutorial. In the next part, we will learn how to configure your domain in Alibaba Cloud DNS, how to create a virtual host to point your domain name to your ECS IP address, and how to finally install PageKit on our ECS instance.
Opinions expressed by DZone contributors are their own.