This is a How To describing the rational install process of WordPress on GNU/Linux in some detail
The official definitive How To install WordPress guide is at the codex. This post you are reading now complements it by documenting the installation and maintenance for me and also potential customers and giving useful tried-and-tested tips.
Let’s install WordPress!
- Get a GNU/Linux. I use Debian Stable for servers and Kubuntu18.04 (which is an LTS, yippee) for desktop. I also hear good people saying good things about Arch GNU/Linux.
- Get a domain name. These cost 10-20€ / year. I use https://gandi.net which is the latter but their palette is so large and their tek is so solid I don’t mind paying +100% extra compared to the price leader with crappy implementation, shady practices and Microsoft .asp crap like you can expect with GoDaddy.com or such. Marketing your WordPress will be much easier with a domain name of it’s own.
- Install the dependencies as explained here. If you don’t know what those are you can contact me for help and I will explain package management. If you need someone to (metaphorically) hold your hand while you do the installation or someone to explain to you what these instructions are and what they mean I can come over in the Helsinki area for gigs as short as 4 hrs work.
- Go to https://wordpress.org/download/ and right click on the “Download .tar.gz” and choose “Copy link location”
- Ssh in to your GNU/Linux and create a directory for your site e.g. /var/www/domain.tld , navigate there and write
ctrl-shift-vto paste the text ‘https://wordpress.org/latest.tar.gz‘.
- Unpack with
tar xvzf latest.tar.gz
- Make the newly created directory writable by the user that your webserver runs as e.g.
sudo chown -R www-data wordpress/. This allows the WordPress to update itself and the plugins.
- Create the log files access.log and error.log in a suitable place. I use /var/log/apache2/sites/domain.tld
- Instruct your web server in a VirtualHost directive that DocumentRoot is
/var/www/sitename.tld/wordpress. I use both Nginx (nicer conffing) and Apache2.4 as web server, VirtualHost and DocumentRoot are the valid names of the things in the /etc/apache2/sites-enabled/*.conf, the default place for placing the VirtualHost directives.
- Point your browser to your domain name and you should see the installation page. There you need to enter ‘database name’, ‘database user’ and ‘password’. Lets create those so we can proseed
- Start a MariaDB shell and add the database and user for it:
mysql -uroot -pand enter your MariaDB root password. The name of the shell wasn’t changed in order to not break things, this is why the command is still called ‘mysql’. If you get an error saying the login is not allowed this may be due to a security restriction that only the ‘root’-user can log into the ‘root’-account of MariaDB. In this case try with
sudo mysql -uroot -pand you’ll probably be granted access to the MariaDB shell.
- Now you should be in the MariaDB shell
- create a database with
create database mywordpress;in the MariaDB shell. Naturally replace ‘mywordpress’ with what you feel like naming your database
use mywordpress;to use the database
GRANT ALL ON mywordpress.* TO 'wordpressuser'@'localhost' IDENTIFIED BY 'passwordgoeshere';to give the user named wordpressuser all rights on the database mywordpress and all of it’s tables, but only when it is connecting from localhost and naturally has the right password.
- Enter the credentials to the WordPress installation page and follow the instructions and you should be done with installing your main WordPress.
- Once installation is ready you should enable the prettier URLs in Dashboard > Settings > Reading. This will write the necessary rules into your .htaccess file automatically. If you are getting a 404 Not Found error for your pages and posts you need to enable the use of .htaccess directives in your main web server configuration for this directory as follows:
Remember to reload your web server each time you want it to reread its changed configuration. I use
sudo service apache2 reload to do that.
After installation it is good time to take into good use some of the great WordPress plugins
- Akismet is an excellent anti-comment-spam tool. Get it and activate it for free but optional payment is in order if you can afford it. Follow the instructions. Get a free Akismet.com account which is needed to activate. A WordPress.com account is needed to get the API key to enable Akismet. Also many other plugins ask you for rights via the WordPress.com entity authentication so get a free WordPress.com account to enable lot of automation candy.
- JetPack by WordPress.com is an excellent automation tool. It has amples of features that can be enabled. It can for example automate pushing new posts to Facebook, twitter, Linkedin etc.
- UpdraftPlus by UpdraftPlus.com is a plugin to automate backups of your WordPress sites and to centrally keep up-to-date all the plugins of all your WordPress-sites by enabling UpdraftCentral. Free tier of UpdraftCentral allows you to keep up-to-5 WordPress-sites updated and back-upped to a number of cloud storage services.
- WordPress Importer by WordPress.org does what it says. The export is built-in into WordPress and gives you filtering to select posts. I imported a few entries from http://juboblo.gr that are of interest to my readers and future clients.
- Polylang is an easy-to-use plugin to enable a multilingual site
- TablePress by TablePress.org is an easy-to-use plugin to enable adding tables to your WordPress site.
- Easy Table of Contents is an easy-to-use plugin to easily include a TOC in a post or a page
- Yoast SEO by Yoast.com is an easy-to-use plugin to help you with SEO. Some of the features are not available in the free version