Couch CMS – installation and configuration on server

Couch CMS is an open source content management system (CMS) that is available under Common Public Attribution License Version 1.0 (CPAL-1.0). Couch can be used free, modified and distributed. To modify copyright and Couch CMS logo, commercial license is also available.

Couch CMS is for designers. They need no knowledge or expertise in PHP. The designers can simply use HTML or XHTML design in Couch CMS. Couch CMS does not provide any code of HTML. It is simple CMS but not only for simple sites. This is safe from XSS, CSRF and other attacks and have been used to make thousands of websites.

CouchCMS 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.

Couch CMS Prerequisites:

  1. A registered domain name and a VPS.
  2. You should setup your server’s hostname.

Before you begin:

After completing the prerequisites, login as root user with your root username & password via SSH client (e.g. Putty – You can get Putty from https://www.putty.org )

Add a User with Root Privileges:

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 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.

  1. To create a new user account, use the following command:
# adduser aareez

where “aareez” can be any username of your choice.

Now set your desired password and retype your desired password. Then, enter your full name, room number, work phone, home phone, and other. After entering the information, hit Enter key. To confirm the data is correct, type ‘Y’ and hit Enter key.

  1. 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.
# visudo
  1. After executing the above command, a file will be opened, find the following lines in the opened file.

couch cms

Sometimes by default the second line %sudo    ALL=(ALL:ALL)    ALL is commented (starting with hash #), due to which even after adding username to sudoers, it gives error on using sudo. To prevent this issue, if this line starts with ‘#’ sign, remove this symbol and save the changes by typing 😡 and then hit Enter key to save.

  1. Now you will add your username “aareez” to the “sudo” group by executing the following command:
# adduser aareez sudo

After execution of the above command, you can verify the membership of for that group by executing the following command:

# groups aareez

Your username has been successfully added to sudoers group and it is able to execute any root command.

  1. Now, log in by using your new username and password. OR Use the following command to switch user:
# su – aareez

You 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:

# whoami

Update your Ubuntu 16.04 System:

Before proceeding with installation of any kind of package, use the following command to update your Ubuntu system. To execute this command, remember to login from non-root user with sudo privileges.

# sudo apt-get update

You will be prompted to enter your password. Now type your password and hit Enter key and wait for updating.

Now execute the following command to upgrade packages:

# sudo apt-get -y upgrade

You will be prompted to configurations below. Select the option to install the package maintainer’s version

Now you have successfully updated and upgraded your Ubuntu system. Your next step is to install Apache Web Server.

Install Apache Web Server:

To install the apache web-server, you will need to execute the following command:

# sudo apt-get -y install apache2

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 apache2

To start your apache server, execute the following command:

# sudo systemctl start apache2

To ensure that your DocumentRoot directive is pointing to correct directory, check your Apache configuration file by using the following command:

# sudo nano /etc/apache2/sites-enabled/000-default.conf

Note: The configuration for DocumentRoot should look as

# DocumentRoot /var/www/html

Press Ctrl + X, to exit from editor.

Now execute the following command to enable mod_rewrite module in apache.

# sudo a2enmod rewrite

To make the changes work correctly, we will need to restart apache. To do so, execute the command below:

# sudo systemctl restart apache2

To verify, you have successfully installed Apache Web Server. Open http://47.254.28.97 in your web browser where 254.28.97 is my ECS IP address. Remember to replace it with your ECS IP address. You will see the following page.

Install PHP 7.0

To install PHP 7.0 on Ubuntu 16.04 along with its modules required for Couch CMS, you will need to execute the following command.

# sudo apt-get -y install php php-gd php-mbstring php-common php-mysql libapache2-mod-php php-curl

Install MariaDB (MySQL) Server

Ubuntu 16.04 uses MariaDB MySQL by default. To install MySQL, use the following command:

# sudo apt-get -y install mysql-server

After executing the above command, you will be prompted to type new password. This password will be used to access MySQL server. Type your new password that you want to set and hit Enter

Now you will be prompted to repeat the same password. Type same password that you typed in previous screen and hit Enter.

Install unzip:

To unzip any zip folder, you will require unzip tool. To do so, use the following command:

# sudo yum -y install unzip

You have successfully installed LAMP Stack & other necessary packages to continue with second part of How to install Couch CMS on Ubuntu 16.04 tutorial. In the next part, you will learn how configure your domain in Alibaba Cloud DNS, how to create virtual host to point your domain name to your ECS IP address and how to install Let’s Encrypt SSL to make your website secure.

After successful installation, enable MySQL server to start automatically when system reboot. To do so, use the following commands:

# sudo systemctl enable mysql

To start MySQL server, execute the command below:

# sudo systemctl start mysql

Now to secure your MySQL server, execute the command:

# sudo mysql_secure_installation

The root password will be blank by default, just hit enter button to proceed and select ‘Y’ and choose your password. The length of password must be 8 characters minimum otherwise you may face some extra steps to force use of weak password as shown below. You have successfully secured your MariaDB server.

This is second section of my tutorial about how to install Couch CMS on Ubuntu 16.04, in the previous tutorial, you learnt to setup LAMP stack and other required packages for Couch. You did firewall setup. Now this is second part of this tutorial and in this part, you will learn to configure your domain. You will point your domain to your ECS IP address, you will update nameservers in case if you have bought domain from some other registrar instead of Alibaba Cloud. You will learn how to create virtual hosts. You will learn to install Let’s Encrypt and install SSL on your domain. To learn all these, let’s get started by domain configuration.

Domain Configuration:

If you already bought your domain from Alibaba Cloud, it will automatically setup DNS records. You will only require to add domain to Alibaba Cloud DNS. In case, if you have already registered 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 3rd party, follow the steps below:

  1. Login to your Alibaba Cloud account and click on Alibaba Cloud DNS (available in left sidebar of your dashboard). After this click button Add Domain Name.
  2. You will see a popup form. Now, type your complete domain name with TLD e.g. in my case imarslan.com and click Confirm button.
  3. Now your domain has been added in Alibaba Cloud DNS. Next step is to configure domain. Click on Configure, right below the Add Domain Name button.
  4. 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.
  5. Now add A record and its value will be IP address of your ECS instance.
  6. You can skip this step, if you have bought domain from Alibaba Cloud. If you have bought domain from Godaddy, follow the steps below:
  7. Open all domains list and click Manage DNS next to that domain.
  8. Click Change button.
  9. Select Custom option from dropdown list and type nameservers provided in instructions given by Alibaba Cloud.
  10. If you have domain registered at Namecheap, follow the steps below:
  11. Open your domains list and click manage button next to your domain name.
  12. Select Custom DNS from drop down list, add nameservers instructed by Alibaba Cloud and click tick button to save them.
  13. 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 setup virtual host to point your domain on your Alibaba Cloud ECS IP Address. To setup virtual host on your ECS, execute the following command. Replace com with your domain name.

# sudo nano /etc/apache2/sites-available/imarslan.com.conf

Write or copy & paste the following text in opened file. Replace com and www.imarslan.com  with your own domain name and itsaareez@example.com with your email address.

 

<VirtualHost *:80>

# Admin email, Server Name (domain name), and any aliases

ServerAdmin itsaareez@example.com

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>

 

After adding the text, use Ctrl + X, then press ‘Y’, then hit Enter key to save the file.

Now restart your Apache Server to load the changes by using the following command

# sudo systemctl restart apache2

After setting up virtual host, you can access your website by accessing your domain. In my case, I used imarslan.com to access my website.

Note: The above configurations of virtual host are for HTTP protocol. To setup 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.

Install Git:

To begin installation of Let’s Encrypt from GitHub repository, you will need to install Git. Execute the following command to install Git.

# sudo apt-get install git

You will be asked “Do you want to continue?”, type ‘y’ and hit Enter key.

Let’s Encrypt SSL Configuration:

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 apache2

To install add-apt-repository command, install software-properties-common. To do so, execute the following command:

#sudo apt-get install -y software-properties-common

Now add the required repository to install client for Let’s Encrypt SSL certificates. To do so, execute the following command.

# sudo add-apt-repository ppa:certbot/certbot

You will be prompted to press Enter key to continue this process.

Now you will need to update your package list by executing the command below to get the new repository’s information.

# sudo apt-get update

Now execute the following command to install Certbot.

# sudo apt-get install python-certbot-apache

You will be prompted whether you want to continue or not. Type ‘Y’ and hit Enter key. 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 certbot --apache -d imarslan.com -d www.imarslan.com

Replace imarslan.com with your domain name.

Now you will be prompted to write your email address. Type your email and hit Enter. After it, you will be asked to agree with terms. Type A and hit Enter key to proceed. You will be prompted to select vhost number. In my case, it is 2 for imarslan.com

Type 2 and hit Enter key.

You will be asked whether you would like to redirect all traffic to https version or not. Choose any option from 1 or 2 according to your choice. I have chosen 2 because I want to redirect all my traffic to https version of my website.

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/apache2/sites-available/imarslan.com.conf

After executing the above command, a file will be opened. Copy the text below to this opened file.

<IfModule mod_ssl.c>

<VirtualHost *:443>

ServerName imarslan.com

ServerAdmin itsaareez@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 itsaareez@example.com

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>

 

 

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.

Now you can access your website with domain name. Just type your domain name in address box of browser and hit Enter. Here you go….your website is being served via HTTPS and everything is fine.

In this section, you have setup your domain and secured your website via SSL. In next section of this series, you will learn about how to install Couch CMS on your Alibaba Cloud ECS and how to do its initial settings. You will also create database for Couch and make other settings.

In the above section, we installed LAMP Stack, setup firewalls, installed various necessary modules, configuration of domain and installation of Let’s Encrypt SSL. This is third and last tutorial of this series. In this section, you will learn to create database with user and password for your Couch CMS. You will also learn to install Couch CMS and how-to setup and connect Couch CMS with database. Let us proceed with creation of database.

Create database:

Use MySQL 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 Couch CMS, use the following query:

CREATE DATABASE co_db CHARACTER SET utf8 COLLATE utf8_general_ci;

CREATE USER ‘co_db’@’localhost’ IDENTIFIED BY ‘Password’;

GRANT ALL PRIVILEGES ON co_db.* TO ‘co_db’@’localhost’;

FLUSH PRIVILEGES;

EXIT;

 

where co_db can be changed to your desired name.

Install Couch CMS files:

First of all, disable default Apache virtual host by executing the following command:

# sudo a2dissite *default

Now enable your website by executing the following command.

# sudo a2ensite imarslan.com.conf

Execute the following command to reload your apache server, otherwise, your domain will keep showing default page of apache host.

# sudo service apache2 restart
  1. To begin installation of Couch 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 html directory. 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 Couch CMS package for installation. The following command will fetch the latest version of Couch CMS from its official website.

# sudo wget

https://www.couchcms.com/kachua/download.php?auth=09d2u96CspF%2FhQxWXku4qxlhRy%2BQT0Il2I4cmwZyRTfGC4lHjtFA%7CDe0cWHewtiw9J6imMfeyIZ68beUSRJdU%7C0%7C0%7C0%7C1%7C9f1a888fb75a8d4647ae893a6309deeb

   -O Couch.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 -la

Downloaded Couch CMS is saved in compressed form as zip. Now you will have to unzip the compressed zip folder as listed when executed ls -la command. To do so, use the command:

# sudo unzip Couch.zip

Now use the following command to move files from extracted folder to your root directory.

# sudo mv ./CouchCMS-2.0/* /var/www/html

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 www-data:www-data *

After performing the above steps, restart Apache to reload the latest configurations using the command:

# sudo systemctl restart apache2

Now you will have to database configuration for Couch CMS installation. For this purpose, you will need to edit php file. Use the following command to change config.example.php to config.php

 

# sudo mv ./couch/config.example.php ./couch/config.php

Now open php file in nano editor and add the following text then use Ctrl+X, then press ‘Y’ and then hit Enter key to save the changes. Use the following command to open file.

# sudo nano /var/www/html/couch/config.php
 

define( ‘K_GMT_OFFSET’, 0 );

define( ‘K_DB_NAME’, ‘co_db’ );

define( ‘K_DB_USER’, ‘co_db’ );

define( ‘K_DB_PASSWORD’, ‘Password’ );

define( ‘K_DB_HOST’, ‘localhost’ );

define( ‘K_PRETTY_URLS’, 1 );

define( ‘K_USE_CACHE’, 1 );

define( ‘K_EMAIL_TO’, ‘youremail@yourdomain.com’ );

define( ‘K_EMAIL_FROM’, ‘contact@yourdomain.com’ );

 

Congratulations, now this is time to access your Couch CMS. Just open website in your browser. In my case, I will open www.imarslan.com/couch . Now we will proceed towards completion of installation of Couch CMS which will involve different settings. 

Complete the installation of Couch CMS:

To access Couch CMS, use your domain name instead of using any kind of IP address. Write the address of your Couch CMS website in your browser’s address box and hit enter. In my case, I will use the following URL. You will need to replace it with your link.

https://www.imarslan.com/couch

Enter details for Super Admin. Select email, password and username of your choice. Then click Install button to proceed further.

In the next step, you will be redirected to the completion page. Click on log in.

In the next step, you will have to enter your username and password and then click Login

Here you go….you have completed the series of how to install Couch CMS on Alibaba Cloud ECS. You started from adding a super user, setting up Apache Server, MariaDB, PHP 7 along with its various modules, installing various supporting modules, firewalls setup, and then configured your domain name, setup nameservers, pointed your domain to your ECS’s IP address, then created Virtual Host for HTTP protocol, installed Let’s Encrypt SSL certificate and modified Virtual Host according to HTTPS requirements. After that you have to install Couch CMS and then how to setup Couch CMS.

Leave a Reply

Your email address will not be published. Required fields are marked *