Install Textpattern on Ubuntu 20.04

Updated on September 28, 2021
Install Textpattern on Ubuntu 20.04 header image

Introduction

Textpattern 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.

Prerequisites

To complete this Textpattern installation guide, you need:

Optionally, you could deploy a Vultr One-Click LAMP server.

1. Install Dependencies

  1. Connect to your server via SSH.

  2. Update the package information list.

     $ sudo apt update
  3. Install the PHP module for Apache.

     $ sudo apt install -y libapache2-mod-php
  4. Enable mod_rewrite module, which Textpattern needs to make simplified URLs.

     $ sudo a2enmod rewrite
  5. Restart Apache to load the new modules.

     $ sudo systemctl restart apache2
  6. Install the unzip package, which you need to extract the installation file.

     $ sudo apt-get -y install unzip

2. Set Up a Database and a User Account

Textpattern uses either MySQL or MariaDB as the database server.

  1. Log in to your database server as root.

     $ sudo mysql -u root -p
  2. 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;
  3. Log out of the database server.

     mysql> EXIT;

3. Download Textpattern

  1. Create a new directory under the web root.

     $ sudo mkdir -p /var/www/text_pattern
  2. Take ownership of the new directory.

     $ sudo chown -R $USER:$USER /var/www/text_pattern
  3. Switch to the new directory.

     $ cd /var/www/text_pattern
  4. Visit the official Textpattern repository and copy the download link of the latest stable version.

  5. Download the installation file.

     $ sudo wget https://textpattern.com/file_download/113/textpattern-4.8.7.zip
  6. Extract the file you've downloaded.

     $ sudo unzip textpattern-4.8.7.zip
  7. Move the files you've extracted to the /var/www/text_pattern directory.

     $ sudo mv textpattern-4.8.7/* /var/www/text_pattern
  8. Give the Apache user ownership of the /var/www/text_pattern directory.

     $ sudo chown -R www-data:www-data /var/www/text_pattern

4. Create a Virtual Host File

Apache maintains virtual hosts configurations under the /etc/apache2/sites-available directory.

  1. Disable the default virtual host configuration file.

     $ sudo a2dissite 000-default.conf
  2. Open a new text_pattern.conf file.

     $ sudo nano /etc/apache2/sites-available/text_pattern.conf
  3. 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>
  4. Save and close the file.

  5. Enable the new configuration file.

     $ sudo a2ensite text_pattern.conf
  6. Restart Apache to load the new virtual host.

     $ sudo systemctl restart apache2

5. Finish the Installation

  1. 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/
  2. Follow the browser-based wizard and enter your database credentials.

  3. Create a base configuration file for the Textpattern package.

     $ sudo nano /var/www/text_pattern/textpattern/config.php
  4. 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';
  5. Save and close the file.

  6. Delete the setup directory for security purposes.

     $ sudo rm -rf /var/www/text_pattern/textpattern/setup
  7. 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.

More Information

See "Get started with Textpattern" for more information.