Learn How To Install SilverStripe CMS on a Debian 9 LAMP VPS

March 31, 2019

Table of Contents

If you are using a different system, please check our other tutorials.

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 IT Web Services Debian 9 server instance with SSH access
  • A sudo user

Step 1: Update Debian System

Before installing any packages on the Debian server instance, we will first update the system. Log in to the server using a non-root sudo user and run the following commands.

sudo apt-get update
sudo apt-get -y upgrade

Step 2: Install Apache Web Server

Install the Apache2 web server.

sudo apt-get -y install apache2

Then use the systemctl command to start and enable Apache to execute automatically at boot time.

sudo systemctl enable apache2
sudo systemctl start apache2

Now enable the mod_rewrite Apache module.

    sudo a2enmod rewrite 

We now need to edit Apache’s default site file so that mod_rewrite will work correctly with SilverStripe. You can use any terminal editor for this.

sudo vi /etc/apache2/sites-enabled/000-default.conf

Now add the following Directory Apache directives just before the closing </VirtualHost> tag, so the end of your configuration file should look like this.

    <Directory /var/www/html/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
    </Directory>
</VirtualHost>

The most important directive shown above is AllowOverride All.

Also, make sure that your DocumentRoot directive (which should be near the top of the file) looks like this.

DocumentRoot /var/www/html

We will restart Apache at the end of this tutorial, but restarting Apache after any configuration change is certainly a good habit, so let’s do it now.

sudo service apache2 restart

Step 3: Install PHP 7.0

Install the latest version of PHP along with the PHP modules required by SilverStripe.

sudo apt-get -y install php php7.0-gd php7.0-mbstring php7.0-mysql libapache2-mod-php php7.0-xml php7.0-curl php7.0-tidy

Please note: If you are using a later version of PHP such as PHP 7.1, 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.1 you would change the module php7.0-gd to php7.1-gd. 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.

The date.timezone configuration option in php.ini must be set correctly. So open your php.ini file with your favorite terminal editor.

sudo vi /etc/php/7.0/apache2/php.ini

Set the date.timezone option to your preferred timezone. The correct setting for a London server instance looks like this.

date.timezone = Europe/London

Step 4: Install MariaDB (MySQL) Server

Debian 9 defaults to using MariaDB database server, which is an enhanced, fully open source, drop-in replacement for MySQL server.

Install MariaDB database server.

sudo apt-get -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 server installation.

sudo mysql_secure_installation

When prompted, make sure you enter a password for the MariaDB/MySQL root user, and then simply answer “Y” to all of the yes/no questions.

Step 5: Create a Database for SilverStripe

Log into the MariaDB shell as the MariaDB root user by running the following command.

sudo mariadb -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 silverstripe_data CHARACTER SET utf8 COLLATE utf8_general_ci;
CREATE USER 'silverstripe_user'@'localhost' IDENTIFIED BY 'UltraSecurePassword';
GRANT ALL PRIVILEGES ON silverstripe_data.* TO 'silverstripe_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;

You can replace the database name silverstripe_data and username silverstripe_user with something more to your liking, if you prefer. Be sure to change “UltraSecurePassword” to an actually secure password.

Step 6: 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 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

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

Change ownership of the files to avoid permissions problems.

sudo chown -R www-data:www-data * .htaccess

Restart Apache again.

sudo service apache2 restart

Now we’re ready to move on to the final step.

Step 7: Complete SilverStripe CMS Installation

It’s time to visit the IP address of your Debian server instance in your browser. Or, if you’ve already configured your IT Web Services DNS settings (and given it enough time to propagate) you can simply visit your domain instead.

Input the following database details (or your equivalent choices) into the SilverStripe installation page.

Database server: localhost
Database username: silverstripe_user
Database password: UltraSecurePassword
Database name: silverstripe_data

Now fill in your email, 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 the necessary details, you can simply click on the Install SilverStripe button and your new SilverStripe CMS will successfully install.

If you haven’t already set up your IT Web Services DNS, then that should probably be your next step.

You can now 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.

Need help?

Do you need help setting up this on your own service?
Please contact us and we’ll provide you the best possible quote!