For some reason, the Wordpress docs and instructions are really convoluted. So here’s the simple steps to get up and running on a headless Ubuntu server with SSH access.

I currently run The Intersection on Wordpress.com but I am pondering moving this to self-hosted for some flexibility reasons.

Note: as pointed out by a few people, there are packages like MAMP for local development and running on consumer platforms. And there are some pretty good instructions on DigitalOcean albeit with Apache which I do not run. I also did not want to install PHPmyadmin.

Installing Wordpress

I am assuming that NGINX is already in place. We need to add mariaDB/MySQL and PHP-FPM.

sudo apt install mariadb-server

sudo apt install php-fpm php-mysql

I am installing into /var/www folder, so change to that location, then download Wordpress.

cd /var/www
sudo wget https://wordpress.org/latest.tar.gz
sudo tar -xzvf latest.tar.gz
sudo chown -R www-data:www-data wordpress

At this point I renamed the wordpress folder to my website.

sudo mv wordpress [name]

Create NGINX conf:

upstream wp-php-handler {
        server unix:/var/run/php/php7.4-fpm.sock; #Check version path to match
}
server {
        listen 80; # HTTP
        server_name your.domain.name;
        root /var/www/[foldername]/;
        index index.php; # Location block for PHP files
        location / {
                try_files $uri $uri/ /index.php?$args;
        }
        location ~ \.php$ {
                include snippets/fastcgi-php.conf;  
                fastcgi_pass wp-php-handler;
        }
}

Create the database and user:

mysql

create database wordpress default character set utf8 collate utf8_unicode_ci;
create user '[username]'@'localhost' identified by '[password]';
grant all privileges on wordpress.* TO '[username]'@'localhost';
flush privileges;
exit

Time to install an SSL certificate:

sudo certbot --nginx --agree-tos --redirect --hsts --staple-ocsp --email you@example.com -d social.example.com

You can now connect to https://your.domain.name and enter the details you just created.

Database Name = wordpress
Username = the user you just created
Password = the password of the user you just created
Database Host = localhost

Side note: I had one instance where the wizard could not create the wp-config.php file, it gives you the content to copy/paste manually into the file.

Configuring Wordpress

Now you can configure, apply themes and install plugins :)