WebOps Tutorial on Running and Upgrading a Concrete CMS Website

May 2, 2024
By myq for Developers

This tutorial assumes a basic understanding of running and managing a website (WebOps), Linux command line, MySQL, and web server configuration. The first section describes some techniques to deploy a new or existing website while the second section describes how to safely upgrade an existing website. The last section discusses some general ideas about sustainably managing a customized website. These instructions are overviews; more detailed information is linked within each section.

Prerequisites

  • A virtual private server (VPS or similar with SSH access) or a local development environment.
  • Apache or Nginx or other server.
  • PHP (version required by the Concrete CMS version you are deploying).
  • MySQL or MariaDB database.

Deploying a New Concrete CMS

Set Up a Server Environment

For more details about supported softare versions, PHP extensions, and other minutiae, see the System Requirements documentation. Further details on configuration best practices, see the Configuration Best Practices documentation.

Install a server stack: Usually this will be Linux as the OS, MySQL or MariaDB as the database, Apache or Nginx as the web server, and PHP as the code interpreter. The latter components are usually installed through a Linux distribution's package manager. For example:

# For Ubuntu with Apache
sudo apt update
sudo apt install apache2 mysql-server php libapache2-mod-php php-mysql
# For Ubuntu with Nginx
sudo apt update
sudo apt install nginx mysql-server php-fpm php-mysql

Configure the web server to handle PHP files and set up a virtual host to listen for requests. For example:

  • Apache Configuration Example:
<VirtualHost *:80>
    ServerName example.com
    DocumentRoot /var/www/html/concrete
    <Directory /var/www/html/concrete>
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>
  • Nginx Configuration Example:
server {
    listen 80;
    server_name example.com;

    root /var/www/html/concrete;
    index index.php;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
    }
}
  1. Prepare the database by creating a database and user with the appropriate permissions.
CREATE DATABASE concrete;
GRANT ALL PRIVILEGES ON concrete_cms.* TO 'concrete'@'localhost' IDENTIFIED BY '<password>';
FLUSH PRIVILEGES;

Instal Concrete CMS

More detailed steps for installing Concrete can be found in Installing Concrete CMS documentation.

Download the latest version of Concrete CMS from the official website or use wget or cURL directly on your server. For example:

wget https://www.concretecms.org/download/latest.zip -O concretecms.zip

Unzip the downloaded file into the webroot directory. For example:

unzip concretecms.zip -d /var/www/html/concrete

Set file permissions appropriate for the webserver software. For example, if using Apache, the following might be appropriate.

chown -R www-data:www-data /var/www/html/concrete
find /var/www/html/concrete -type d -exec chmod 755 {} \;
find /var/www/html/concrete -type f -exec chmod 644 {} \;

Complete the installation by navigating to your domain and folloing the installation instructions. Alternatively, use the command line tool to complete the installation. For example:

cd /var/www/html/concrete
./concrete/bin/concrete5 c5:install

and answer the questions to complete the installation.

Upgrading Concrete CMS

Before applying the upgrade, follow these steps in a staging environment or local copy. For additional options and considerations, see the Upgrading a Site documentation. Make note of any special steps or issues encountered when running the upgrade and conduct thorough testing. Check for any compatibility issues with plugins, themes, and custom code. After you are sure that the website is functioning as expected after upgrading, repeat the procedure in the production environment.

Preparation

Check system requirements and release notes to ensure your server meets the requirements of the new version and review the release notes for any critical changes or warnings.

Backup your files and database before starting an upgrade.

mysqldump -u concrete -p concrete > concrete_backup.sql
tar -czvf concrete_files_backup.tar.gz /var/www/html/concrete/public/{application/{config/generated_overrides,files},packages}/

Perform the Upgrade

Put your site in maintenance mode through the command line or through the dashboard when logged in as the superadmin. For example, using the command line:

cd /var/www/html/concrete
./concrete/bin/concrete5 c5:config set concrete.maintenance_mode true

Download and unzip the new version to the updates directory

wget https://www.concretecms.org/download_file/-/view/xxxxx/ -O new_concretecms.zip
unzip new_concretecms.zip  -d updates

Run the update command through the command line (preferred to avoid timeouts) or by visiting the site:

cd /var/www/html/concrete
./concrete/bin/concrete5 c5:update

Post-upgrade Steps

Check website functionality to ensure all features and pages are working as expected.

Disable maintenance mode to resume normal website functionality

./concrete/bin/concrete5 c5:config set concrete.maintenance_mode false

Long term

Adding custom blocks, themes, and features to Concrete can be done through the application/ or packages/ directories, not the concrete/ directory (for example, see Packaging a Theme documentation). In order to manage these customizations, some form of source control such as git is recommended. In addition to source control, deploy solutions such as CI/CD can be used to automate the update process.

Recent Tutorials
Customize locale icons
Oct 29, 2024
By myq.

How to customize locale (language region) flags

Concrete CMS Caching Guide
Oct 16, 2024

An overview of types of caching in Concrete and considerations when using them.

Redirect all requests to HTTPS
Oct 9, 2024
By myq.

How to follow best practices for a secure web

Upgrade Concrete versions 9.3.1 and 9.3.2
Sep 10, 2024
By myq.

How to get past a bug in versions 9.3.1 and 9.3.2 that prevents upgrading the Concrete core through the Dashboard

How to use Composer with Marketplace extensions
Aug 22, 2024

Composer can be used to manage third-party extensions from the marketplace

Controlling Google Tag Manager Tags Based on Concrete CMS Edit Toolbar Visibility
Aug 13, 2024

This document provides a step-by-step guide on how to control the firing of Google Tag Manager (GTM) tags based on the visibility of the Concrete CMS edit toolbar. It explains how to create a custom JavaScript variable in GTM to detect whether the edit toolbar is present on a page and how to set up a trigger that ensures GTM tags only fire when the toolbar is not visible. This setup is particularly useful for developers and marketers who want to ensure that tracking and analytics tags are not activated during content editing sessions, thereby preserving the accuracy of data collected.

Improvements?

Let us know by posting here.