How to Install the October CMS on CentOS 7

Published on: Wed, Aug 17, 2016 at 11:30 am EST
CentOS Web Servers

October is an open source content management system which is based on the Laravel PHP Framework. With an elegant interface and a concise modular architecture, October takes the user experience on CMS to the next level.

This article will guide you through the process of installing the October CMS on a Vultr CentOS 7 server instance.

Prerequisites

  • A newly deployed Vultr CentOS 7 server instance.
  • A sudo user. You can learn more about a sudo user in this Vultr article.

Step 1: Update the system

Log in as a sudo user from your SSH terminal, and then update the system to the latest stable status:

sudo yum install epel-release -y
sudo yum update -y && sudo shutdown -r now

After the reboot, use the same sudo user to log in again.

Step 2: Install Apache

Install Apache using YUM:

sudo yum install httpd

On a production machine, you will want to remove Apache's default welcome page:

sudo sed -i 's/^/#&/g' /etc/httpd/conf.d/welcome.conf

For security purposes, you need to prevent Apache from displaying files in the "/var/www/html" directory:

sudo sed -i "s/Options Indexes FollowSymLinks/Options FollowSymLinks/" /etc/httpd/conf/httpd.conf

Start Apache:

sudo systemctl start httpd.service
sudo systemctl enable httpd.service

Step 3: Install PHP and necessary extensions

October requires PHP version 5.5.9 or greater. Here, you can install PHP 5.6 and necessary extensions using the IUS YUM repository.

Install the IUS YUM repo:

cd
wget https://centos7.iuscommunity.org/ius-release.rpm
sudo rpm -Uvh ius-release.rpm

Install PHP 5.6 and necessary extensions using the IUS YUM repo:

sudo yum install php56u.x86_64 php56u-pdo.x86_64 php56u-common.x86_64 php56u-mbstring.x86_64 php56u-gd.x86_64 php56u-mysqlnd.x86_64

After the installation, restart Apache to load new modules:

sudo systemctl restart httpd.service

Step 4: Install MariaDB and create a database for October

Install MariaDB using YUM:

sudo yum install mariadb mariadb-server

Start MariaDB:

sudo systemctl start mariadb.service
sudo systemctl enable mariadb.service

Secure the installation of MariaDB:

sudo /usr/bin/mysql_secure_installation

Go through the process in accordance with the following instructions:

Enter current password for root (enter for none): Enter
Set root password? [Y/n]: Y
New password: <your-password>
Re-enter new password: <your-password>
Remove anonymous users? [Y/n]: Y
Disallow root login remotely? [Y/n]: Y
Remove test database and access to it? [Y/n]: Y
Reload privilege tables now? [Y/n]: Y

In order to create a database for October, you need to log into the MySQL shell:

mysql -u root -p

Input the MariaDB root password you set earlier to log in.

In the MySQL shell, use the following commands to create a database and grant privileges to a database user. Be sure to replace the database name "octobercms", the database username "octoberuser", and the database user password "yourpassword" in each and every command with your own ones.

CREATE DATABASE octobercms;
CREATE USER 'octoberuser'@'localhost' IDENTIFIED BY 'yourpassword';
GRANT ALL PRIVILEGES ON octobercms.* TO 'octoberuser'@'localhost' IDENTIFIED BY 'yourpassword' WITH GRANT OPTION;
FLUSH PRIVILEGES;
EXIT;

Step 5: Install the October CMS

Download and prepare October installation files:

cd
wget http://octobercms.com/download -O octobercms.zip
sudo yum install unzip
unzip octobercms.zip
sudo mv install-master/* /var/www/html
sudo chown apache:apache -R /var/www/html

Modify firewall rules in order to allow web access:

sudo firewall-cmd --zone=public --permanent --add-service=http
sudo firewall-cmd --reload

Now, point your web browser to the following URL:

http://<your-server-ip>/install.php

1) First of all, the October installation wizard will perform a system check. If everything goes well, click the "Agree & Continue" button to go to the next step.

2) In the step of Database, input the MySQL database name, MySQL username, and MySQL password you setup earlier, leave other fields untouched, and then click the "Administrator >" button to move on.

3) In the step of Administrator, input the username and the password for the administrator, then click the "Advanced >" button to continue.

4) In the step of Advanced, you need to take some measures to enhance security:

  • Specify the backend URL: a hard to guess URL, like /rfgtgkef.
  • Provide an encryption code: a 32-bit alphanumeric string, like uhgXsJhk7LYYu4mjZbybwHY95G2wjsfR.
  • setup permission masks for folders and files during installation and updates: For now, both of them can use the default value 777.

Click the "Continue" button to go to the last step.

5) In the step of Getting started, you need to choose how to setup your site. For a beginner, it is recommended to choose "Start from a theme", and then install a theme as you wish.

Congratulations! Now you can visit your October site using the following URL:

http://<your-server-ip>

And the URL of October administration area is:

http://<your-server-ip>/rfgtgkef

After the installation

1) For security purposes, you should delete all of the installation files after the installation:

sudo rm -rf /var/www/html/install.php /var/www/html/install_files

2) If the URL of October administration area takes you to a 404 page, you need to modify the configuration of Apache:

sudo vi /etc/httpd/conf/httpd.conf

Find the following segment:

<Directory "/var/www/html">

In this segment, modify the line:

AllowOverride None

To:

AllowOverride All

Save and quit:

:wq!

Restart Apache to put your changes into effect:

sudo systemctl restart httpd.service

3) In production environments, you may want to enable the CSRF protection:

sudo vi /var/www/html/config/cms.php

Find the line:

'enableCsrfProtection' => false,

Replace it with:

'enableCsrfProtection' => true,

Save and quit:

:wq!

Restart Apache:

sudo systemctl restart httpd.service

4) Disable the debug mode:

In production environments, it's important to disable the debug mode:

sudo vi /var/www/html/config/app.php

Find the line:

'debug' => true,

Replace it with:

'debug' => false,

Save and quit:

:wq!

Restart Apache:

sudo systemctl restart httpd.service

5) Setup the scheduler

Use the crontab command to setup the scheduler:

sudo crontab -e

Input the following entry:

* * * * * php /var/www/html/artisan schedule:run >> /dev/null 2>&1

Save and quit:

:wq!

That's it. Thank you for reading.

Want to contribute ?

You could earn up to $300 by adding new articles