How to Install Pagekit CMS on CentOS 7.4, Part 2: Installing Pagekit
Look at how to install Pagekit on our Alibaba Cloud Elastic Compute Service (ECS) instance.
Join the DZone community and get the full member experience.Join For Free
This is the second part of my tutorial about how to install Pagekit CMS on CentOS 7.4.
In the previous tutorial, we have set up a LAMP stack and other required packages for Pagekit. In the second part of the tutorial, we will install Pagekit on our Alibaba Cloud Elastic Compute Service (ECS) instance.
But before doing that, we will need to configure our domain. We will also secure the domain with Let's Encrypt (SSL). After that, we will create a database and then finally install Pagekit CMS on our ECS instance.
If you bought your domain from Alibaba Cloud, it will automatically set up DNS records. You will only be required to add the domain to Alibaba Cloud DNS. In this case, if you have already registered the domain from any other registrar, you will need to add that domain in Alibaba Cloud DNS and update its nameserver records on your registrar account. Once your DNS records are propagated, check them from intodns.com.
To setup domain name bought from a third party, follow the steps below:
- Login to your Alibaba Cloud account and click on Alibaba Cloud DNS (available in left sidebar of your dashboard). Click Add Domain Name.
- You will see a popup form. Now, type your complete domain name with TLD (in my case imarslan.com) and click Confirm.
- Now your domain has been added to Alibaba Cloud DNS. You need to configure our domain. Click on Configure, right below the Add Domain Name button.
- If you bought domain from Alibaba Cloud, your all nameservers would be configured already. If you bought it from some other registrar, Alibaba Cloud DNS configuration page will detect it and provide your information for changing nameservers.
- Now add A record and its value will be the IP address of your ECS instance as shown below.
- You can skip this step if you bought a domain from Alibaba Cloud. If you bought a domain from a third party, you will need to visit the domain registrar's website. The steps differ according to the registrar.
- Now go back to Alibaba Cloud DNS page and click Add Record button to add records, after adding save them. To get records details, you can use intodns.com.
Create Virtual Host
- Once your nameservers are updated, you can set up a virtual host to point your domain on your Alibaba Cloud ECS IP Address. To set up a virtual host on your ECS, execute the following command. Replace imarslan.com with your domain name.
# sudo nano /etc/httpd/conf.d/imarslan.com.conf
- Write or copy and paste the following text in the opened file. Replace imarslan.com and www.imarslan.com with your own domain name and email@example.com with your email address.
After adding the text, use Ctrl + X, then press 'Y', then hit Enter key to save the file.
<VirtualHost *:80> # Admin email, Server Name (domain name), and any aliases ServerAdmin firstname.lastname@example.org ServerName imarslan.com ServerAlias www.imarslan.com # Index file and Document Root (where the public files are located) DirectoryIndex index.html index.php DocumentRoot /var/www/html/ # Log file locations LogLevel warn ErrorLog /var/www/html/error.log CustomLog /var/www/html/access.log combined </VirtualHost>
- Now restart your Apache Server to load the changes by using the following command
# sudo systemctl restart httpd
- After setting up the virtual host, you can access your website by accessing your domain. In my case, I used www.imarslan.com to access my website. Note: The above configurations of the virtual host are for HTTP protocol. To set up an HTTPS protocol, you will have to install SSL. To install SSL and allow HTTPS to provide a secured experience to your users, you will need to install Let's Encrypt. Let's Encrypt will provide you free SSL for your domain.
- To begin installation of Let's Encrypt from GitHub repository, you will need to install Git. Execute the following command to install Git.
# sudo yum install git
- You will be asked "Is this ok?", enter 'y' and hit Enter key.
Configure Let's Encrypt SSL
- For installation of Let's Encrypt SSL, you will have to stop your Apache Server. Use the command below to stop apache server. Remember, Certbot uses port 80 to get SSL certificate. Apache server uses same port 80. So, to avoid conflict, Apache server must be stopped until you get SSL certificate issued.
# sudo systemctl stop httpd
- You will get a clone of Let's Encrypt from official GitHub repository that will be installed in /opt/letsencrypt. To clone, type the following command and hit Enter.
# sudo git clone https://github.com/letsencrypt/letsencrypt /opt/letsencrypt
- Now navigate to /opt/letsencrypt by executing the command:
# cd /opt/letsencrypt
- Now create your SSL certificate. Let's Encrypt performs challenges for Domain Validation on the basis of which Certificate Authority (CA) will authenticate your domain. On validation, you will be issued a SSL certificate by CA. To create SSL certificate for your domain using Let's Encrypt, use the following command:
# sudo -H ./letsencrypt-auto certonly --standalone -d imarslan.com -d www.imarslan.comNote: Remember to replace imarslan.com with your own domain name.
- Now you will be prompted to write your email address. Type your email and hit Enter.
- You will be asked to agree with terms. Type A and hit Enter to proceed.
- Now when you will have to setup virtual host again to make it compatible with HTTPS. You will also want to stop people accessing your website without SSL. For this purpose, you may force SSL and every user will be redirected to secured website via HTTPS. For this purpose, execute the command below:
# sudo nano /etc/httpd/conf.d/imarslan.com.conf
- After executing the above command, a file will be opened. Copy the text below to this opened file.
Replace imarslan.com with your domain name. This above code will force SSL and all of the traffic will be redirected to HTTPS version of the website.
<IfModule mod_ssl.c> <VirtualHost *:443> ServerName imarslan.com ServerAdmin email@example.com ServerAlias www.imarslan.com SSLEngine on SSLCertificateFile /etc/letsencrypt/live/imarslan.com/cert.pem SSLCertificateKeyFile /etc/letsencrypt/live/imarslan.com/privkey.pem SSLCertificateChainFile /etc/letsencrypt/live/imarslan.com/chain.pem DirectoryIndex index.html index.php DocumentRoot /var/www/html/ # Log file locations LogLevel warn ErrorLog /var/www/html/error.log CustomLog /var/www/html/access.log combined </VirtualHost> </IfModule> <VirtualHost *:80> # Admin email, Server Name (domain name), and any aliases ServerAdmin firstname.lastname@example.org ServerName imarslan.com ServerAlias www.imarslan.com Redirect permanent / https://www.imarslan.com/ # Log file locations LogLevel warn ErrorLog /var/www/html/error.log CustomLog /var/www/html/access.log combined </VirtualHost>
- Use MariaDB shell to login as root user and execute the following command:
# sudo mysql -u root -p
- Now the command prompt will ask you to enter password for user 'root'. Enter the password and hit enter key, you will be prompted to MariaDB command prompt.
- To create the database and user for this database for your PageKit CMS, use the following query:
where pk_db can be changed to your desired name.
CREATE DATABASE pk_db CHARACTER SET utf8 COLLATE utf8_general_ci; CREATE USER 'pk_db'@'localhost' IDENTIFIED BY 'SecurePassword'; GRANT ALL PRIVILEGES ON pk_db.* TO 'pk_db'@'localhost'; FLUSH PRIVILEGES; EXIT;
Install PageKit CMS Files
- To begin the installation of PageKit CMS, navigate to directory cd /var/www/html/because in Apache Server, we use this as web-directory. Note: In case, if you get any error like 'No such directory or file', then create htmldirectory. To do so, navigate to cd /var/www and execute the following command to create html directory and type cd html and hit enter.
# sudo mkdir html
- Now use the following command to get PageKit CMS package for installation. The following command will fetch the latest version of PageKit CMS from its official website.
# sudo wget http://pagekit.com/api/download/latest -O pagekit.zip
- Now you will have to list the files in the directory to see files & folders. To list the files in current directory, use the command:
# ls -li
- Downloaded PageKit CMS is saved in compressed form as pagekit.zip. Now you will have to unzip the compressed zip folder as listed when executed ls -li command. To do so, use the command:
# sudo unzip pagekit.zip
- Change the owner of files to avoid permissions issues. This will allow apache to access files of CMS without any issue. Execute command below:
# sudo chown -R apache:apache /var/www/html
- After performing the above steps, restart Apache to reload the latest configurations using the command:
# sudo systemctl restart httpd
Accessing Pagekit CMS
Congratulations! Now it's time to access your Pagekit CMS. Just open the website in your browser. In my case, I will open www.imarslan.com. Now we will proceed towards completion of installation of Pagekit CMS which will involve different settings.
Complete the Installation of PageKit CMS
- As you are accessing the link first time, you will be automatically redirected to the installer page as shown below. Click the arrow shown in the figure to proceed to the next step.
- In the next step, you will be asked to select your desired language. Select your desired language and click Next.
- In the next step, you will have to connect a database. First of all, you will choose driver as MySQL from the drop-down list as shown below.
- After this, add the values for database configurations. Add the following values as we used in the query above.
Host localhost Database Name pk_db Username pk_db Password SecurePassword
- Now you will have to set up your website. In site title, give any title to your website, select any username of your choice, and set a strong password for it. This will allow you to access the admin panel, give your email, and then hit Install.
- Now you will be redirected to Amin panel login page automatically. The link to the admin panel is https://www.yourdomain.com/admin/login. To log in, use your username and password and hit login.
You have successfully installed Pagekit CMS on Alibaba Cloud ECS.
You can access your admin panel by using the admin panel URL you have configured. To view your website, you can simply access it through https://www.yourdomain.com.
Opinions expressed by DZone contributors are their own.