How to Install SilverStripe CMS on a CentOS 7 LAMP VPS
SilverStripe is a flexible and extensible free and open source enterprise-grade Content Management System (CMS) written in PHP. It is easy to use and learn, very robust and secure, has excellent reusable well-optimised and readable code, and includes a powerful templating engine that makes creating websites easy and fast.
Prerequisites
- A clean Vultr CentOS 7 server instance with SSH access
- A non-root sudo user
Step 1: Update CentOS System
Before installing any packages on the CentOS server instance, we will first update the system.
Log in to the server using a non-root sudo
user and run the following command.
sudo yum -y update
Step 2: Install Apache Web Server
Install the Apache web server.
sudo yum -y install httpd
Then use the systemctl
command to start and enable Apache to execute automatically at boot time.
sudo systemctl enable httpd
sudo systemctl start httpd
Now we need to make sure that the mod_rewrite
Apache module is loaded. We can do this by searching the CentOS Apache base modules configuration file for the term "mod_rewrite
". You can use any terminal editor for this, in this tutorial, we will use vi
as it's so widely available.
sudo vi /etc/httpd/conf.modules.d/00-base.conf
Search for the term mod_rewrite
in vi
by typing /mod_rewrite
in command-mode (after pressing the "escape
" key).
If the mod_rewrite
Apache module is loaded, the configuration line should look like this.
LoadModule rewrite_module modules/mod_rewrite.so
If the above line starts with a semi-colon, you will need to remove the semi-colon to uncomment the line and load the module. This, of course, applies to any other required Apache modules too.
If you're using the vi
editor you can save the file by pressing the "Escape
" key (to enter command mode) and then type :wq
to write any changes to the file and quit the editor.
We now need to edit Apache's default configuration file so that mod_rewrite
will work correctly with SilverStripe.
sudo vi /etc/httpd/conf/httpd.conf
Find the section that starts with <Directory "/var/www/html">
and change AllowOverride none
to AllowOverride All
. The end result (with all comments removed) should look something like this.
<Directory "/var/www/html">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
Also, ensure that your DocumentRoot
directive points to the correct directory. The configuration option should look like this.
DocumentRoot "/var/www/html"
You can now save and close the Apache configuration file.
We now need to open the default HTTP
and HTTPS
ports as they will be blocked by firewalld
by default.
sudo firewall-cmd --permanent --add-port=80/tcp
sudo firewall-cmd --permanent --add-port=443/tcp
Reload the firewall to apply the changes.
sudo firewall-cmd --reload
Restarting Apache after any configuration change is certainly a good habit, so let's do it now.
sudo systemctl restart httpd
Step 3: Disable SELinux (if enabled)
SELinux stands for "Security Enhanced Linux". It is a security enhancement to Linux which allows users and administrators more control over access control. It is disabled by default on Vultr CentOS 7 instances, but we will cover the steps to disable it, just in case you are not starting from a clean install and it was previously enabled.
To avoid file permission problems with SilverStripe CMS we need to ensure that SELinux is disabled.
First, let's check whether SELinux is enabled or disabled with the sestatus
command.
sudo sestatus
If you see something like: SELinux status: disabled
then it is definitely disabled and you can skip straight to Step 4. If you see any other message then you will need to complete this section.
Open the SELinux configuration file with your favourite terminal editor.
sudo vi /etc/selinux/config
And change SELINUX=enforcing
to SELINUX=disabled
, then save the file.
To apply the configuration change, SELinux requires a server reboot, so you can either restart the server using the Vultr control panel or you can simply use the shutdown
command.
sudo shutdown -r now
When the server reboots your SSH session will get disconnected and you may see a message complaining about a 'broken pipe'
or informing you 'Connection closed by remote host'
. This is nothing to worry about, simply wait for 20 seconds or so and then SSH back in again (with your own username and domain).
ssh example_sudo_user@example.net
Or (with your own username and IP address).
ssh example_sudo_user@203.0.113.1
Once you have logged back in, you should check the status of SELinux again with the sestatus
command to make sure it is properly disabled.
sudo sestatus
You should see a message saying SELinux status: disabled
. If you see a message saying SELinux status: enabled
(or something similar) you will need to repeat the steps above and ensure that you properly restart your server.
Step 4: Install PHP 7.1
CentOS 7 requires us to add an external repo in order to install PHP 7.1.
sudo rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
We can now install the latest version of PHP 7.1 along with the necessary PHP modules required by SilverStripe.
sudo yum -y install php71w php71w-gd php71w-mbstring php71w-mysql php71w-xml php71w-common php71w-tidy
Please note: If you are using a later version of PHP such as PHP 7.2, you may need to alter the version numbers of the above PHP modules to match your version of PHP. So, for example, if you are using PHP 7.2 you would probably change the module php71w-xml
to php72w-xml
. Please note that sometimes module names do change between versions, so if you experience any problems, simply visit the excellent PHP documentation site for guidance, or, alternatively, use the yum search
command to search for equivalent PHP modules.
The date.timezone
configuration option in php.ini
must be set correctly. So open your php.ini
file with your favourite terminal editor.
sudo vi /etc/php.ini
Set the date.timezone
option to your preferred timezone. For example, a London instance should look like this.
date.timezone = Europe/London
Step 5: Install MariaDB (MySQL) Server
CentOS 7 defaults to using MariaDB database, which is an enhanced, fully open source, community developed, drop-in replacement for MySQL.
Install MariaDB database.
sudo yum -y install mariadb-server
Start and enable MariaDB to execute automatically at boot time.
sudo systemctl enable mariadb
sudo systemctl start mariadb
Secure your MariaDB installation.
sudo mysql_secure_installation
The root
password will be blank, so simply hit "Enter
" when prompted for the root
password.
When prompted to create a MariaDB/MySQL root
user select "Y
" (for yes) and then enter a secure root
password. Simply answer "Y
" to all of the other yes/no questions as the default suggestions are the most secure options.
Step 6: Create a Database for SilverStripe
Log into the MariaDB shell as the MariaDB root
user.
sudo mysql -u root -p
To access the MariaDB command prompt, simply enter the MariaDB root
password when prompted.
Run the following queries to create a MariaDB database and database user for SilverStripe.
CREATE DATABASE ss_data CHARACTER SET utf8 COLLATE utf8_general_ci;
CREATE USER 'ss_user'@'localhost' IDENTIFIED BY 'UltraSecurePassword';
GRANT ALL PRIVILEGES ON ss_data.* TO 'ss_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;
You can replace the database name ss_data
and username ss_user
with something more to your liking, if you prefer. (Please note that the default maximum length for usernames in MariaDB on CentOS 7 is 16 characters). Also, make sure that you change "UltraSecurePassword" to an actually secure password.
Step 7: Install Silverstripe CMS Files
Change your current working directory to the default web directory.
cd /var/www/html/
If you get an error message saying something like 'No such file or directory'
then try the following command.
cd /var/www/ ; sudo mkdir html ; cd html
Your current working directory should now be /var/www/html/
. You can check this with the pwd
(print working directory) command.
pwd
Now use wget
to download the SilverStripe CMS tarball.
sudo wget https://silverstripe-ssorg-releases.s3.amazonaws.com/sssites-ssorg-prod/assets/releases/SilverStripe-cms-v3.6.2.tar.gz
Please note: You should check for the most recent version by checking the SilverStripe download page. Simply right-click on the download button on the page and copy the URL. You can then paste the most up to date tarball URL into the wget
command shown above.
List the current directory to check we have successfully downloaded the file.
ls -la
Now uncompress the tarball.
sudo tar xvzf SilverStripe-cms-v3.6.2.tar.gz
And change ownership of the web files to avoid permissions problems.
sudo chown -R apache:apache * .htaccess
Restart Apache again.
sudo systemctl restart httpd
And now we're ready to move on to the final step.
Step 8: Complete SilverStripe CMS Installation
It's time to visit the IP address of your CentOS server instance in your browser. Or, if you've already configured your Vultr DNS settings (and given it enough time to propagate) you can simply visit your domain instead.
Simply input the following database details (or your equivalent choices) into the SilverStripe installation page.
Database server: localhost
Database username: ss_user
Database password: UltraSecurePassword
Database name: ss_data
Now fill in your email and password (to access the SilverStripe admin section), and set your default language.
Email: my_email@example.net
Password: AnotherUltraSecurePassword
Default language: English UK
Once you have filled in all of the necessary details, you can simply click on the Install SilverStripe
button and your new SilverStripe CMS will successfully install.
Now you can start adding your content and configure the look of your site. Be sure to check out the SilverStripe CMS User Help Guide for more guidance on how to build and configure your site.