By Arslan Ud Din Shafiq, Alibaba Cloud Tech Share Author. Tech Share is Alibaba Cloud's incentive program to encourage the sharing of technical knowledge and best practices within the cloud community.
This is second part of my tutorial about how to install CouchCMS on Ubuntu 16.04.
In the previous tutorial, we have set up a LAMP stack and other required packages for CouchCMS. In the second part of the tutorial, we will install CouchCMS 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 CouchCMS on our ECS instance.
If you 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 a third party, follow the steps below:
# sudo nano /etc/apache2/sites-available/imarslan.com.conf
<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.
# sudo systemctl restart apache2
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.
# sudo apt-get install git
# sudo systemctl stop apache2
#sudo apt-get install -y software-properties-common
# sudo add-apt-repository ppa:certbot/certbot
You will be prompted to press Enter key to continue this process.
# sudo apt-get update
# sudo apt-get install python-certbot-apache
You will be prompted whether you want to continue or not. Type 'Y' and hit Enter key.
# sudo certbot --apache -d imarslan.com -d www.imarslan.com
Note: Remember to replace imarslan.com with your own domain name.
Type 2 and hit Enter.
# sudo nano /etc/apache2/sites-available/imarslan.com.conf
<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.
# sudo mysql -u root -p
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.
# sudo a2dissite *default
# sudo a2ensite imarslan.com.conf
# sudo service apache2 restart
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
# sudo wget https://www.couchcms.com/kachua/download.php?auth=09d2u96CspF%2FhQxWXku4qxlhRy%2BQT0Il2I4cmwZyRTfGC4lHjtFA%7CDe0cWHewtiw9J6imMfeyIZ68beUSRJdU%7C0%7C0%7C0%7C1%7C9f1a888fb75a8d4647ae893a6309deeb -O Couch.zip
# ls -la
# sudo unzip Couch.zip
# sudo mv ./CouchCMS-2.0/* /var/www/html
# sudo chown -R www-data:www-data html
# sudo systemctl restart apache2
# sudo mv ./couch/config.example.php ./couch/config.php
# 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 it's time to access your CouchCMS. 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.
That's it! You have successfully installed CouchCMS 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.
Web Development the DevOps Way – Alibaba Cloud Best Practices
2,599 posts | 762 followers
FollowAlibaba Clouder - April 23, 2019
Alibaba Clouder - May 22, 2018
Alibaba Clouder - April 26, 2019
Alibaba Clouder - November 13, 2019
Alibaba Clouder - August 2, 2018
Alibaba Clouder - June 13, 2019
2,599 posts | 762 followers
FollowElastic and secure virtual cloud servers to cater all your cloud hosting needs.
Learn MoreAn encrypted and secure cloud storage service which stores, processes and accesses massive amounts of data from anywhere in the world
Learn MoreLearn More
More Posts by Alibaba Clouder
5316206321858932 May 2, 2019 at 12:11 pm
I am trying to install CouchCMS on Debian based php mysql web hosting (https://www.cloudways.com/en/php-cloud-hosting.php ). The stack is already configured. I am using Nginx and Apache. I am trying to install Couch through composer. After the installation, I am getting error for database connection. How do i connect the database on the server, which is MySQL, with this CMS?
Arslan ud Din Shafiq April 20, 2020 at 1:31 pm
Kindly try to execute steps in "Create Database" heading in the above article. After it open file sudo nano /var/www/html/couch/config.php and update database values mentioned under heading "Install Couch CMS Files" in point 12.