Install PyroCMS on Alibaba Cloud

By Arslan Ud Din Shafiq, Alibaba Cloud Community Blog author and Alibaba Cloud MVP.

PyroCMS is a Laravel PHP Framework based web application built using Laravel and has a versatile admin panel and is responsive and compatible with all screen sizes as well as supports multilingual system.

In this tutorial, I will be installing and setting up PyroCMS on an Alibaba Cloud Elastic Compute Service (ECS) instance with Ubuntu 16.04.

Prerequisites

  • You must have Alibaba Cloud Elastic Compute Service (ECS) activated and verified your valid payment method. If you don’t know how to setup your ECS instance, you can refer to this tutorial or quick-start guide. Your ECS instance must have at least 2GB RAM and 2 Core processor.
  • 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.
  • Domain name must be pointed to your Alibaba Cloud ECS’s IP address
  • Access to VNC console in your Alibaba Cloud or SSH client installed in your PC
  • Set up your server’s hostname and create user with root privileges.

Setting up Your Environment

Setting up Your Server

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

# sudo apt update && sudo apt upgrade

Installing PHP

PyroCMS requires PHP 7.0 or later. In this tutorial, you will install PHP 7.2. To do so, run the following steps.

First, you’ll need to install python software properties and software properties common. To do so, run the command below.

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

Add a repository for newer versions of PHP.

# sudo add-apt-repository ppa:ondrej/php

Then, update the system to refresh the available repositories.

# sudo apt update

To install PHP 7.2, run the following command.

# sudo apt install -y php7.2

Installing the Required PHP Extensions

PyroCMS requires the following PHP extensions:

  1. php7.2-cli
  2. php7.2-fpm
  3. php7.2-mysql
  4. php7.2-curl
  5. php7.2-sqlite3
  6. php7.2-gd
  7. php7.2-mbstring
  8. php7.2-dom

To install the above extensions of PHP, run the following command.

# sudo apt-get -y install php7.2-cli php7.2-fpm php7.2-dom php7.2-mbstring php7.2-mysql php7.2-curl php7.2-sqlite3 php7.2-gd

When you have done installation of the above extensions, apache2 will be installed automatically, so in other words you won’t need to install it manually.

Run the following command to check installed PHP version.

# php –version

Installing MariaDB

PyroCMS supports MySQL, PostgreSQL, MSSQL, Redis and SQLite. In this tutorial, you will use MariaDB server for MySQL. By default, Ubuntu repository has older version of MariaDB server. To use new version of MariaDB, you will need to add MariaDB repository to your Ubuntu system. To do so, follow the steps below.

Verify the keys by running the command below.

# sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8

Add the repository by running the command below.

# sudo add-apt-repository 'deb [arch=amd64,i386,ppc64el] http://mirror.nodesdirect.com/mariadb/repo/10.2/ubuntu xenial main'

Update the system by running the command below.

# sudo apt update

Install MariaDB by running the following command.

# sudo apt install -y mariadb-server

Start and enable the MariaDB server so that after reboot, so that the server can start automatically.

# sudo systemctl start mariadb
# sudo systemctl enable mariadb

Run the following command to enhance security of MariaDB server and set password for the root user.

# sudo mysql_secure_installation

Connect to the MySQL shell as root user using the command below and enter your password.

# sudo mysql -u root -p

Run the following MySQL queries in your MariaDB server.

CREATE DATABASE pyro CHARACTER SET utf8 COLLATE utf8_general_ci;
CREATE USER 'aareez'@'localhost' IDENTIFIED BY '654321Ab';
GRANT ALL PRIVILEGES ON pyro.* TO 'aareez'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Installing Unzip

You will need to install unzip which will be used to unzip the compressed zip folder. To install unzip, run the following command.

# sudo apt-get install unzip -y

Installing Curl

To install curl, run the following command.

# sudo apt-get install curl -y

Installing Git

To install git, run the following command.

# sudo apt-get install git -y

Installing Composer

To install and setup composer, run the following commands.

# php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
# php -r "if (hash_file('SHA384', 'composer-setup.php') === '93b54496392c062774670ac18b134c3b3a95e5a5e5c8f1a9f115f203b75bf9a129d5daa8ba6a13e2cc8a1da0806388a8') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
# php composer-setup.php
# php -r "unlink('composer-setup.php');"
# sudo mv composer.phar /usr/local/bin/composer

You can check if composer installed successfully by running the command to check the version of composer.

# composer -v

Installing and Setting up PyroCMS

To install PyroCMS, you will need to follow the steps.

Navigate to /var/www/html using the command.

# cd /var/www/html

Change ownership of /var/www/html directory to aareez.

# sudo chown -R aareez:aareez /var/www/html

Remove index.html file using the command below.

# sudo rm index.html

Download the latest stable release of PyroCMS by running the command below.

# composer create-project pyrocms/pyrocms

Provide ownership of /var/www/html to www-data so that apache server can access the required files.

# sudo chown -R www-data:www-data /var/www/html

Configuring the Apache Server

Create virtual host configuration file for PyroCMS by running the following command. Afterwards, a file will be opened in nano text editor.

# sudo nano /etc/apache2/sites-available/pyro.conf

Copy and PyroCMS the following code and save the file.

<VirtualHost *:80> 
ServerAdmin admin@xyz.com
ServerName softpedia.xyz
DocumentRoot /var/www/html/pyrocms/public
DirectoryIndex index.php index.htm index.html
<Directory /var/www/html>
Options +FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/PyroCMS_error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/PyroCMS_access.log combined
</VirtualHost>

Run the command below to disable default site.

# sudo a2dissite 000-default.conf

You will need to enable the newly created virtual host. To do so, run the command below.

# sudo a2ensite pyro

Now you will need to enable rewrite mod. You can do so by editing configuration file in apache2 directory or you can simply run the command below.

# sudo a2enmod rewrite

Now you will need to enable SSL engine. You can do so by editing configuration file in apache2 directory or you can simply run the command below.

# sudo a2enmod ssl

Now you will have to restart apache server to apply the changes and load the settings by running command below.

# sudo service apache2 restart

Now you can access PyroCMS via your domain name or ECS IP address. In my case, I have accessed via http://softpedia.xyz .

Check the checkbox shown below to indicate that you agree with these terms.

Configuring the Database

Now enter your information in the following form for configuring database.

Configuring the Admin Account

To access admin panel of PyroCMS, you will need administrator’s account. To create admin account, enter your information into the following form.

Configuring the Basic Settings

You will need to set name, primary domain name, language and timezone for PyroCMS. To do this, enter this information into the form given below and click the install button to continue.

You will see the following screen during installation. It may take a few minutes for it to install.

After completion of successful installation, you may click login to access admin panel and view site to navigate to your website.

On clicking login, you will see the following screen.

After successful login to your admin panel, you will see the following dashboard.

Installing the SSL Certificate

We will install SSL certificate using Let’s Encrypt with Certbot. To do so, execute the following steps.

Update the package.

# sudo apt-get update

Install software-properties-common.

# sudo apt-get install software-properties-common

Add the certbot repository by running the command below.

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

Update the package to load the added certbot repository.

# sudo apt-get update

Stop apache before issuance of SSL certificate.

# sudo systemctl stop apache2

Install python-certbot-apache by running the command below.

# sudo apt-get install python-certbot-apache

Execute the following command to get Let’s Encrypt SSL issued.

# sudo certbot --apache -d softpedia.xyz

Select the option 2 to redirect the link to https and update virtual host settings for SSL. Restart apache server.

# sudo systemctl start apache2

You can access your website at https<span>://your_domain_name</span>.tld

Setting up Firewalls and Ports

If you have activated firewalls, you will have to define a rule in Alibaba Cloud security group for your cloud server to add exception for port 80/tcp and 443/tcp. You can enable these ports while creating ECS instance, but in case if you forgot to unblock these ports, you can follow the procedure in this guide: Setting security group rules.

Original Source

Written by

Follow me to keep abreast with the latest technology news, industry insights, and developer trends.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store