How to Setup Textpattern CMS on CentOS 8

How to Setup Textpattern CMS on CentOS 8

Textpattern is a free and open-source PHP content management system. It is rather lightweight, fast, and easy to use while providing decent customizability through themes and plugins. In this guide, we will install Textpattern on a fresh CentOS 8 system.


  • A fresh CentOS 8 system on which you have access to the root user or any user with sudo privileges.
  • A registered domain name pointing to your server.

If logged in as a sudo user, switch to root for this setup:

sudo su -

Set the $VISUAL environment variable to a text editor of your preference. For example, to use nano:
echo "export VISUAL=nano" >> ~/.bash_profile
. ~/.bash_profile

Step 1: Installing Required Software

First, update your system:
dnf update -y

Then install wget, tar, Apache, PHP, the required PHP extensions, MariaDB and utilities for managing SELinux:
dnf install -y wget tar httpd mariadb-server php php-xml php-mysqli php-json php-mbstring php-zip php-zlib policycoreutils-python-utils

Ensure the Apache and MariaDB services are enabled and running:
systemctl enable --now httpd.service mariadb.service

As the CentOS 8 repositories do not include certbot, we will use a script, certbot-auto, to install it. Download and install certbot-auto as follows:
wget https://dl.eff.org/certbot-auto
mv certbot-auto /usr/local/bin/certbot-auto
chmod 0755 /usr/local/bin/certbot-auto

Then use the following command to install certbot:
certbot-auto --install-only

Enter ‘y’ when prompted by dnf to install dependencies.

Restart the Apache service:
systemctl restart httpd.service

Step 2: Textpattern CMS Installation

Copy the download link (in .tar.gz format) for the latest textpattern release from their Releases on Github and download it to your server with wget as follows:
wget https://github.com/textpattern/textpattern/releases/download/4.7.3/textpattern-4.7.3.tar.gz

Then unpack the archive and move its contents to the web root directory:
tar -xzf textpattern*.tar.gz
rm -f textpattern*.tar.gz
mv textpattern* /var/www/html/textpattern

In order for Textpattern to work properly, it requires write access to certain directories. To grant that access, give the Apache system user ownership of the whole directory:
chown -R apache:apache /var/www/html/textpattern

And use the following commands to label the directory structure with the proper SELinux contexts:
semanage fcontext -a -t httpd_sys_content_t "/var/www/html/textpattern(/.*)?"
semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/html/textpattern/themes(/.*)?"
semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/html/textpattern/images(/.*)?"
semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/html/textpattern/files(/.*)?"
restorecon -Rv /var/www/html

Step 3: Database Setup

Start by running the mysql_secure_installation script to perform basic security enhancements:

Answer the questions as shown below and make sure to choose a secure password for the root user:
Enter current password for root (enter for none):
Set root password? [Y/n] y
New password: your_password
Re-enter new password: your_password
Remove anonymous users? [Y/n] y
Disallow root login remotely? [Y/n] y
Remove test database and access to it? [Y/n] y
Reload privilege tables now? [Y/n] y

Next, we will create a database and user to be used by Textpattern. Login to the MySQL shell with:
mysql -u root -p

Enter your root password, then issue the following statements. Make sure to replace textpattern_user_password with a proper password.
MariaDB [(none)]> CREATE DATABASE textpattern_db;
MariaDB [(none)]> CREATE USER textpattern_user IDENTIFIED BY 'textpattern_user_password';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON textpattern_db.* TO textpattern_user;
MariaDB [(none)]> q

Step 4: Apache Configuration

First, enable HTTP and HTTPS traffic through the host firewall:
firewall-cmd --add-service http --add-service https --permanent
firewall-cmd --reload

Then create a new virtual host for your Textpattern site:
$VISUAL /etc/httpd/conf.d/textpattern.conf

And enter the following configuration, replacing your_domain with your domain name.
<VirtualHost *:80>
DocumentRoot "/var/www/html/textpattern"
ServerName your_domain
<Directory "/">
AllowOverride All

Save and exit, then load the new configuration:
systemctl reload httpd.service

To obtain an SSL certificate for your domain and configure Apache to use HTTPS, issue the following command:
certbot-auto --apache -d "your_domain" -m "[email protected]" --redirect

This command will accomplish a number of tasks:

  • Obtain a certificate for your domain (saved under /etc/letsencrypt/your_domain/).
  • Create an Apache configuration file named textpattern-le-ssl.conf.
  • Edit textpattern.conf to redirect all HTTP requests to HTTPS.

Step 5: Textpattern CMS Configuration

Your Textpattern installation should now be accessible but isn’t configured yet. Browse to https://your_domain/textpattern/setup/ to start the web installer. After choosing a language, enter database details:

  • MySQL user name: textpattern_user
  • MySQL password: Enter the password chosen for textpattern_user during step 2.
  • MySQL server: localhost
  • MySQL database: textpattern_db
  • Table prefix: leave this field blank

The installer will check the database credentials you’ve entered before generating the corresponding configuration. Create the required file:
$VISUAL /var/www/html/textpattern/textpattern/config.php

Paste the generated configuration, save the file and exit. Proceed to the next step in the web installer, where you’ll be asked to enter information for the CMS administrator account and site configuration. Once that is done, remove the setup directory:
rm -rf /var/www/html/textpattern/textpattern/setup

Your Textpattern site is now ready for use.

More Info

Đăng ký liền tay Nhận Ngay Bài Mới

Subscribe ngay

Cám ơn bạn đã đăng ký !

Lỗi đăng ký !

Add Comment

Click here to post a comment

Đăng ký liền tay
Nhận Ngay Bài Mới

Subscribe ngay

Cám ơn bạn đã đăng ký !

Lỗi đăng ký !