Install Textpattern CMS using NGinx on Ubuntu
published on
Textpattern is another content management system that you might like to try in case Wordpress doesn't really meet your need and you want to look for an alternative.
To install it on your VPS follow thse instructions.
The initial setup
Make sure to run the following commands to install the necessary utility packages
sudo apt install lsb-release ca-certificates apt-transport-https software-properties-common language-pack-en-base unzip zip curlsudo locale-gen en_US.UTF-8sudo add-apt-repository ppa:ondrej/phpsudo add-apt-repository ppa:ondrej/nginx-mainline
You will also want to run sudo nano /etc/apt/sources.list.d/ondrej-ubuntu-nginx-mainline-*.list in order to uncomment the deb-src line before running sudo apt update.
Now install NGinx
This is done by running sudo apt install nginx-core nginx-common nginx nginx-full libgeoip-dev libpcre3-dev.
Next, install PHP 8.1
sudo apt install openssl php8.1-{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 install unzip ghostscript imagemagick
Edit the /etc/php/8.1/fpm/pool.d/www.conf file and add, or edit, lines to look like the ones below
listen = /run/php/php8.1-fpm.socklisten.owner = www-datalisten.mode = 0660
Now edit the /etc/php/8.1/fpm/php.ini file and add or edit the following lines
output_buffering = Offzlib.output_compression Onzlib.output_compression_level 5expose_php = offmax_execution_time = 120max_input_time = 60max_input_vars = 1000memory_limit = 512M display_errors = Offdisplay_startup_errors = Offlog_errors = Onhtml_errors = Onpost_max_size = 128Mupload_max_filesize = 128Mcgi.fix_pathinfo=0allow_url_fopen = Offextension=curl.dllextension=pdo_mysqldate.timezone = Europe/Londonopcache.enable=1opcache.jit_buffer_size=100Mopcache.jit=1255opcache.memory_consumption=128opcache.max_accelerated_files=10000opcache.revalidate_freq=200
Lastly run sudo systemctl restart php8.1-fpm to update the PHP settings.
Now install MariaDB
Run the following commands to install and secure MariaDB
sudo apt install mariadb-serversudo mysql_secure_installation
Now run sudo mysql -u root -p and enter the following commands to create the database that TextPattern will use
CREATE DATABASE tpdb charset=utf8;CREATE USER 'tpu'@'localhost' IDENTIFIED BY 'password';GRANT ALL PRIVILEGES ON tpdb.* TO 'tpu'@'localhost';FLUSH PRIVILEGES;exit
Next, create the NGinx server block
Run sudo nano /etc/nginx/sites-available/[domain] where [domain] is the domain name you are using to access your site and add the following lines
server { listen 80; listen [::]:80; server_name [domain] www.[domain]; root /var/www/[domain]; index index.php; charset uft-8; client_max_body_size 30M; location ~ /\.ht { deny all; } location / { index index.php; try_files $uri $uri/ /index.php?$args; } location ~ \.php$ { fastcgi_index index.php; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_pass unix:/run/php/php8.1-fpm.sock; } #Inhibits direct file downloads #location ^~ /files/\.*$ { # return 403; #} location ^~ /themes/\.txp$ { return 403; } types { image/svg+xml svg svgz; } gzip on; gzip_types image/svg+xml; access_log /var/log/nginx/[domain].access.log; error_log /var/log/nginx/[domain].error.log;}
Finally run the following commands to test and activate your configuration
sudo ln -s /etc/nginx/sites-available/[domain] /etc/nginx/sites-enabled/[domain]sudo nginx -tsudo systemctl restart nginx
Secure your site with a TLS certificate
sudo apt install snapdsudo snap install core; sudo snap refresh coresudo snap install --classic certbotsudo ln -s /snap/bin/certbot /usr/bin/certbotsudo certbot -d [domain] -d www.[domain] --nginx
Now it is time to install Textpattern
Run the following set of commands to download Textpattern and put it in your web directory
cd ~wget https://textpattern.com/file_download/118/textpattern-4.8.8.zipunzip textpattern-4.8.8.zipcd textpattern-4.8.8sudo mkdir /var/www/[domain]sudo cp -r * /var/www/[domain]cd ..rm -rf textpattern-4.8.8.zip textpattern-4.8.8sudo touch /var/www/[domain]/error.htmlsudo chown -R www-data:www-data /var/www/[domain]sudo chmod -R 755 /var/www/[domain]
Finish setting up Textpattern
Visit [domain]/textpattern/setup in your browser and answer all the questions.
After you have worked your way through the setup process run the following two commands and add all the values shown in your browser. Make sure to uncomment the protocol line at the end of the file too!
sudo mv /var/www/[domain]/textpattern/config-dist.php /var/www/[domain]/textpattern/config.phpsudo nano /var/www/[domain]/textpattern/config.php
Lastly, delete the setup directory and login to the Textpattern administrator panel. Now navigate to the Admin - Diagnostics section and check for errors.
Conclusion
You should now have a fully working copy of Textpattern. Have fun playing with it and learning how to create your next great site!
