WordPress is an extremely popular content management system (CMS) for websites. Its popularity and ubiquity really cannot be overstated, as it powers a staggering 35% of websites. It’s an easy way to get a website online, and it offers a lot in the way of customization.
Let’s start by configuring our database server:
sudo mysql
From the mariadb cli prompt execute the following:
create database wordpress_db;
create user 'wordpress_user'@'localhost' identified by 'my_password';
grant all privileges on wordpress_db.* to wordpress_user@'localhost';
flush privileges;
exit
Now let’s setup the nginx config file:
sudo nano /etc/nginx/sites-available/wordpress
server {
listen 80;
server_name _;
root /var/www/wordpress;
index index.php;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
}
}
Now let’s delete the default site and enable the new site in nginx:
sudo rm /etc/nginx/sites-enabled/default
sudo ln -s /etc/nginx/sites-available/wordpress /etc/nginx/sites-enabled/wordpress
sudo systemctl restart nginx
We are now ready to download the latest version of wordpress:
wget -O /tmp/wordpress.tar.gz https://wordpress.org/latest.tar.gz
sudo tar -xzvf /tmp/wordpress.tar.gz -C /var/www
sudo chown -R www-data.www-data /var/www/wordpress
Now our WordPress instance has been extracted into ‘/var/www/wordpress’ and our permissions set and we can browse to the installation page of WordPress at http://127.0.0.1.
You’ll need to enter the following:
- Database name
- Database username
- Database password
- Database host
- Database table prefix
Once thats complete you will setup your admin account and have a working wordpress install.