In this guide, we will show you how to install Bolt CMS on a CentOS 7 VPS with MariaDB, PHP 7 and Nginx as web server. Bolt CMS is a lightweight open source Content Management Tool, written in PHP and it’s built upon the Silex framework. This guide should work on other Linux VPS systems as well but was tested and written for an CentOS 7.
Table of Contents
1. Login to your VPS via SSH
ssh user@vps_IP
Update the system
yum update
2. Install MariaDB 10.2
Centos 7 comes with MariaDB 5.5 and in this guide we will use the latest version of MariaDB, version 10.2. To install the package from the official MariaDB repository open your editor of choice and create the following file:
nano /etc/yum.repos.d/MariaDB.repo
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.2/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
Once the repo is added, you can install the MariaDB packages with the following command:
yum install MariaDB-server MariaDB-client
When the installation is complete, start the MariaDB database server and enable it to start at boot time:
systemctl start mariadb
systemctl enable mariadb
run the following command to secure your installation:
mysql_secure_installation
Next, we need to create a database for our Bolt CMS installation.
mysql -uroot -p
MariaDB [(none)]> CREATE DATABASE bolt;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON bolt.* TO 'bolt'@'localhost' IDENTIFIED BY 'your_bolt_password';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> \q
3. Install Nginx, PHP and Composer
Nginx is not available in the official CentOS repositories so first we need to add the EPEL repository and then install the package:
yum install epel-release
yum install nginx
Same as with the mariaDB service, start the nginx server and enable it to start at boot time:
systemctl start nginx
systemctl enable nginx
CentOS 7 ships with PHP version 5.4 and Bolt CMS requres PHP 5.5.9 or higher. We will install PHP 7.0 using the Webtatic repository. To enable the Webtatic repository run the following command:
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
Install PHP 7.0 and all necessary extensions:
yum install php70w-cli php70w-intl php70w-gd php70w-fileinfo php70w-mcrypt php70w-mbstring php70w-common php70w-fpm php70w-xml php70w-opcache php70w-pdo php70w-posix php70w-mysqlnd
By default, PHP-FPM will run as the Apache user. Since we are using Nginx, we need to change the user from apache to nginx. To make the change we can use the sed command as follows:
sed -i 's/apache/nginx/g' /etc/php-fpm.d/www.conf
Finally re-start the php-fpm service and enable it to start at boot time:
systemctl restart php-fpm
systemctl enable php-fpm
Composer is a dependency manager for PHP with which you can install packages. Composer will pull in all the required libraries and dependencies you need for your project.
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
4. Install Bolt CMS
We will install Bolt CMS using the “composer create-project” command:
composer create-project bolt/composer-install:^3.3 /var/www/MYBOLTAPP --prefer-dist
The installer will ask you if you want to use Bolt’s standard folder structure. Choose “yes” and proceed with the installation.
Do you want to use Bolt's standard folder structure? (yes/no) [yes]:
> yes
By default, Bolt is configured to use an SQLite database, since we will be using a MySQL database we need to change the settings in app/config/config.yml
file and enter the details of the database we created previously:
nano /var/www/MYBOLTAPP/app/config/config.yml
# database:
# driver: sqlite
# databasename: bolt
database:
driver: mysql
username: bolt
password: your_bolt_password
databasename: bolt
Set the correct ownership and permissions with the following commands:
chown -R nginx: /var/www/MYBOLTAPP
find /var/www/MYBOLTAPP -type d -exec chmod 755 {} \;
find /var/www/MYBOLTAPP -type f -exec chmod 644 {} \;
5. Configure Nginx
Create a new Nginx server block:
nano /etc/nginx/conf.d/MYBOLTAPP.conf
server {
listen 80;
server_name MYBOLTAPP;
root /var/www/MYBOLTAPP/public;
index index.php;
access_log /var/log/nginx/MYBOLTAPP.access.log;
error_log /var/log/nginx/MYBOLTAPP.error.log;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /bolt {
try_files $uri /index.php?$query_string;
}
location ^~ /bolt/ {
try_files $uri /index.php?$query_string;
}
location ^~ /thumbs {
try_files $uri /index.php; #?$query_string;
access_log off;
log_not_found off;
expires max;
add_header Pragma public;
add_header Cache-Control "public, mustrevalidate, proxy-revalidate";
add_header X-Koala-Status sleeping;
}
location ~* ^.+\.(?:atom|bmp|bz2|css|doc|eot|exe|gif|gz|ico|jpe?g|jpeg|jpg|js|map|mid|midi|mp4|ogg|ogv|otf|png|ppt|rar|rtf|svg|svgz|tar|tgz|ttf|wav|woff|xls|zip)$ {
access_log off;
log_not_found off;
expires max;
add_header Pragma public;
add_header Cache-Control "public, mustrevalidate, proxy-revalidate";
add_header X-Koala-Status eating;
}
location = /(?:favicon.ico|robots.txt) {
log_not_found off;
access_log off;
}
location ~ /index.php/(.*) {
rewrite ^/index.php/(.*) /$1 permanent;
}
location ~ /\. {
deny all;
}
location ~ /\.(htaccess|htpasswd)$ {
deny all;
}
location ~ /\.(?:db)$ {
deny all;
}
location ~* /(.*)\.(?:markdown|md|twig|yaml|yml)$ {
deny all;
}
location ~ [^/]\.php(/|$) {
try_files /index.php =404;
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param HTTP_PROXY "";
fastcgi_param HTTPS $https if_not_empty;
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
}
}
Test the Nginx configuration and restart nginx:
nginx -t
service nginx restart
6. Create your Bolt CMS admin user
Once the installation is complete, go to http://MYBOLTAPP and register your first user. Administrative access is automatically granted to the first registered user.
That’s it. You have successfully installed Bolt CMS on your CentOS 7 VPS. For more information about how to manage your Bolt CMS installation, please refer to the official Bolt CMS documentation.
Of course you don’t have to Install Bolt CMS on Centos 7 if you use one of our CentOS Powered Linux VPS Hosting services, in which case you can simply ask our expert Linux admins to Install Bolt CMS on Centos 7 for you. They are available 24×7 and will take care of your request immediately.
PS. If you liked this post on how to install Bolt CMS on Centos 7please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.