Install Concrete CMS using Apache or NGinx
published onThere are a large number of content management systems on the internet today and this article will show you how to install another of them. This one is called ConcreteCMS. You may not of heard of it in the same way as others such as Wordpress as it is more aimed at larger enterprises and tends to require experienced developers to get the most from it.
ConcreteCMS claim that the user can edit their website as easily as they edit a document and they do have a large amount of documentation on their site if you get stuck or just want to learn more.
ConcreteCMS can be installed on Apache or NGinx and this post will show you how to do both.
Initial setup
To begin with I install some basic packages which can be necessary later on.
sudo apt install lsb-release ca-certificates apt-transport-https software-properties-common language-pack-en-base zip unzip
sudo locale-gen en_US.UTF-8
Install PHP 7.4
Next I will install PHP by running the following commands
sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt install openssl php7.4-{common, cli, bz2, zip, curl, intl, mysql, snmp, memcached, imagick, gd, fileinfo, imap, ldap, soap, tidy, xml, gd, gmp, pspell, mbstring, opcache, fpm, ssh2, imap, redis, apcu, mcrypt}
sudo apt ghostscript imagemagick
To configure PHP I run sudo nano /etc/php/7.4/fpm/pool.d/www.conf
and add, or edit, the following lines to look like the ones below
listen = /run/php/php7.4-fpm.sock
listen.owner = www-data
listen.mode = 0660
I then make similar edits to the php.ini file by running sudo nano /etc/php/7.4/fpm/php.ini
and adding, editing or uncommenting the following lines to look like the ones below
output_buffering = Off
expose_php = off
max_execution_time = 240
max_input_time = 60
max_input_vars = 1500
memory_limit = 512M
post_max_size = 10M
upload_max_filesize = 10M
date.timezone = Europe/London
opcache.enable=1
opcache.memory_consumption=128
opcache.max_accelerated_files=10000
opcache.revalidate_freq=200
extension=fileinfo.so
extension=openssl.so
Now install the MariaDB database
The following two commands will install MariaDB and tools necessary for backing databases up. The second of the commands will secure the MariaDB installation.
sudo apt-get install mariadb-server mariadb-backup
sudo mysql_secure_installation
There are two other changes which I will make to a configuration file by running sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf
and making sure the two lines below appear as shown here.
bind-address = 127.0.0.1
local-infile = 0
Set up the ConcreteCMS database
Enter sudo mysql -u root -p
at the command line and type the following commands at the MariaDB command prompt.
CREATE DATABASE [con_db] charset=utf8mb4;
CREATE USER 'con_user'@'localhost' IDENTIFIED BY 'my_password';
GRANT ALL PRIVILEGES ON con_db.* to 'con_user'@'localhost';
FLUSH PRIVILEGES;
exit
Make sure to change the database name, user name and password to something more secure.
If you are going to use the Apache web server
If you choose to use Apache the enter the following commands at the prompt.
sudo add-apt-repository -y ppa:ondrej/apache2
sudo apt update && sudo apt upgrade
sudo apt-get install apache2 apache2-utils
sudo a2enmod mime http2 rewrite deflate expires headers ssl
sudo apt-get install libapache2-mod-fcgid
sudo a2enmod proxy_fcgi setenvif
sudo a2enconf php7.4-fpm
sudo systemctl restart php7.4-fpm
sudo a2dissite 000-default.conf
sudo systemctl restart apache2
Once Apache is installed create the virtual host file for Typo3 by running sudo nano /etc/apache2/sites-available/concrete.conf
and adding the following lines
<VirtualHost *:80>
ServerAdmin [email address]
ServerName [domain]
ServerAlias www.[domain]
DocumentRoot /var/www/[domain]/concrete
Protocols h2 http/1.1
DirectoryIndex index.php index.html
<Directory /var/www/[domain]/concrete>
Options +SymLinksIfOwnerMatch -MultiViews -Indexes -Includes -ExecCGI
AllowOverride All
Require all granted
</Directory>
<FilesMatch "\.php$">
SetHandler "proxy:unix:/run/php/php7.4-fpm.sock|fcgi://localhost"
</FilesMatch>
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/css text/javascript application/javascript
</IfModule>
SetEnv TZ Europe/London
AddDefaultCharset UTF-8
DefaultLanguage en
FileETag none
###Header set Strict-Transport-Security "max-age=31536000; includeSubdomains;" env=HTTPS
Header set X-XSS-Protection "1; mode=block"
Header set X-Content-Type-Options nosniff
Header set X-Frame-Options SAMEORIGIN
Header set Referrer-Policy: no-referrer-when-downgrade
###Header set Content-Security-Policy "default-src 'self';"
###Header set X-Permitted-Cross-Domain-Policies "none"
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Once you have created the Apache virtual host you will want to run the following two commands to activate it.
sudo a2ensite concrete.conf
sudo systemctl restart apache2
If you are going to use the NGinx web server
sudo add-apt-repository -y ppa:ondrej/nginx-mainline
sudo apt update && sudo apt upgrade
sudo apt install nginx-core nginx-common nginx nginx-full libgeoip-dev libpcre3-dev
Once NGinx has been installed you will want to run sudo nano /etc/nginx/sites-available/concrete.conf
and add the following lines to create the NGinx server block.
map $sent_http_content_type $expires {
default off;
text/html epoch;
text/css max;
application/javascript max;
~image/ max;
}
server {
listen 80;
listen [::]:80;
root /var/www/[domain]/concrete;
index index.php index.html index.htm;
server_name example.com www.example.com;
expires $expires;
location / {
try_files $uri $uri/ /index.php$request_uri /index.php;
}
location ~ \.php($|/) {
try_files $uri =404;
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
include /etc/nginx/fastcgi_params;
fastcgi_index index.php;
set $script $uri;
set $path_info "";
if ($uri ~ "^(.+\.php)(/.+)") {
set $script $1;
set $path_info $2;
}
fastcgi_param URI $uri;
fastcgi_param PATH_INFO $path_info;
fastcgi_param SCRIPT_NAME $script;
fastcgi_param SCRIPT_FILENAME $document_root$script;
#browser caching of static assets
location ~* \.(jpg|jpeg|png|gif|ico|woff2)$ {
expires 365d;
}
#browser caching of css and js
location ~* \.(css|js)$ {
expires 7d;
}
}
}
Once the server block has been created you can run the following commands to disable the default server block and activate the one above.
sudo unlink /etc/nginx/sites-enabled/default
sudo ln -s /etc/nginx/sites-available/concrete.conf /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl restart nginx
Now install ConcreteCMS
Regardless of whether you chose to use Apache or NGinx you can install ConcreteCMS on your server by running the following commands.
cd ~
wget -c https://www.concretecms.com/download_file/c8c925b8-9a63-4b23-aff3-cb0e76a0e168/ -O concrete.zip
unzip concrete-cms-9.1.1.zip
sudo mkdir -p /var/www/[domain]/concrete
sudo mv concrete-cms-9.1.1 /var/www/[domain]/concrete
sudo chown -R www-data:www-data /var/www/[domain]/concrete
sudo chmod -R 755 /var/www/[domain]/concrete
Remember that the [domain]
above needs to be the same one you would use in the document root of your virtual host or server block above.
Secure your Concrete CMS install with an SSL / TLS certificate
First install Certbot by running the following commands
sudo apt-get install snapd
sudo snap install core; sudo snap refresh core
sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/bin/certbot
If you installed Apache run sudo certbot -d [domain] -d www.[domain] --apache
to get your certificate and, if you installed NGinx, run sudo certbot -d [domain] -d www.[domain] --nginx
instead.
Setup ConcreteCMS
Visit [domain]
in your browser and work your way through the setup guide in order to finish off creating your new ConcreteCMS content management system.
Final thoughts
This guide, like the others, explains how to get your content management system installed on your server. However, you may want to make a number of changes to your virtual host file or server block to suit your own preferences and needs.
The hard work will obviously be in using ConcreteCMS to set up your site the way you want it. To help you along the way ConcreteCMS provide training videos which can be found at https://documentation.concretecms.org/videos and documentation for their system can be found at https://documentation.concretecms.org/.