Author: Francis Ndungu
Last Updated: Tue, Sep 28, 2021Textpattern is an open-source Content Management System for LAMP and LEMP systems, written in PHP with a MySQL or MariaDB backend. This guide explains how to install Textpattern with a LAMP stack on Ubuntu 20.04 server.
To complete this Textpattern installation guide, you need:
Optionally, you could deploy a Vultr One-Click LAMP server.
Connect to your server via SSH.
Update the package information list.
$ sudo apt update
Install the PHP module for Apache.
$ sudo apt install -y libapache2-mod-php
Enable mod_rewrite module
, which Textpattern needs to make simplified URLs.
$ sudo a2enmod rewrite
Restart Apache to load the new modules.
$ sudo systemctl restart apache2
Install the unzip
package, which you need to extract the installation file.
$ sudo apt-get -y install unzip
Textpattern uses either MySQL or MariaDB as the database server.
Log in to your database server as root
.
$ sudo mysql -u root -p
Create a new database and user account. Replace EXAMPLE_PASSWORD
with a strong password.
If you use MySQL:
mysql> CREATE DATABASE text_pattern;
CREATE USER 'text_pattern_user'@'localhost' IDENTIFIED WITH mysql_native_password BY 'EXAMPLE_PASSWORD';
GRANT ALL PRIVILEGES ON text_pattern.* TO 'text_pattern_user'@'localhost';
FLUSH PRIVILEGES;
If you use MariaDB:
MariaDB> CREATE DATABASE text_pattern;
GRANT ALL PRIVILEGES on text_pattern.* TO 'text_pattern_user'@'localhost' identified by 'EXAMPLE_PASSWORD';
FLUSH PRIVILEGES;
Log out of the database server.
mysql> EXIT;
Create a new directory under the web root.
$ sudo mkdir -p /var/www/text_pattern
Take ownership of the new directory.
$ sudo chown -R $USER:$USER /var/www/text_pattern
Switch to the new directory.
$ cd /var/www/text_pattern
Visit the official Textpattern repository and copy the download link of the latest stable version.
Download the installation file.
$ sudo wget https://textpattern.com/file_download/113/textpattern-4.8.7.zip
Extract the file you've downloaded.
$ sudo unzip textpattern-4.8.7.zip
Move the files you've extracted to the /var/www/text_pattern
directory.
$ sudo mv textpattern-4.8.7/* /var/www/text_pattern
Give the Apache user ownership of the /var/www/text_pattern
directory.
$ sudo chown -R www-data:www-data /var/www/text_pattern
Apache maintains virtual hosts configurations under the /etc/apache2/sites-available
directory.
Disable the default virtual host configuration file.
$ sudo a2dissite 000-default.conf
Open a new text_pattern.conf
file.
$ sudo nano /etc/apache2/sites-available/text_pattern.conf
Copy and paste the following information into the text_pattern.conf
file. Replace example.com
with your server's domain name or public IP address.
<VirtualHost *:80>
ServerName example.com
DocumentRoot "/var/www/text_pattern"
<Directory "/var/www/text_pattern">
Require all granted
Options -Indexes +FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Save and close the file.
Enable the new configuration file.
$ sudo a2ensite text_pattern.conf
Restart Apache to load the new virtual host.
$ sudo systemctl restart apache2
In your web browser, visit your server's public IP address or domain name and append /textpattern/setup/
to the URL. For example, if your domain name is example.com
, visit the URL:
http://example.com/textpattern/setup/
Follow the browser-based wizard and enter your database credentials.
Create a base configuration file for the Textpattern package.
$ sudo nano /var/www/text_pattern/textpattern/config.php
Paste the following information into the file. Replace EXAMPLE_PASSWORD
with the strong password you created for text_pattern_user
.
<?php
$txpcfg['db'] = 'text_pattern';
$txpcfg['user'] = 'text_pattern_user';
$txpcfg['pass'] = 'EXAMPLE_PASSWORD';
$txpcfg['host'] = 'localhost';
$txpcfg['table_prefix'] = '';
$txpcfg['txpath'] = '/var/www/text_pattern/textpattern';
$txpcfg['dbcharset'] = 'utf8mb4';
Save and close the file.
Delete the setup
directory for security purposes.
$ sudo rm -rf /var/www/text_pattern/textpattern/setup
Visit http://example.com/textpattern/index.php
to access your Textpattern dashboard. Replace example.com
with your domain name or server's public IP address.
See "Get started with Textpattern" for more information.