Techflubber Guides and Tips (A Super Simple Blog)

Set up a WordPress site using the LEMP stack

Quick Navigation


Step 1: Install PHP and Nginx

First, we need to update our repositories and install the web server and PHP processor.

sudo apt update
sudo apt install nginx php-fpm php-mysql -y
Note: Ensure your firewall allows HTTP (Port 80) and HTTPS (Port 443) traffic.

Step 2: Configure the Database

WordPress needs a MySQL database to store your posts and settings. Enter your MySQL prompt and run the following:

CREATE DATABASE wordpress_db;
CREATE USER 'wp_user'@'localhost' IDENTIFIED BY 'your_strong_password';
GRANT ALL PRIVILEGES ON wordpress_db.* TO 'wp_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Step 3: Nginx Configuration

Create a new configuration file for your site (e.g., /etc/nginx/sites-available/wordpress).


server {
listen 80;
server_name yourdomain.com;
root /var/www/wordpress;

index index.php index.html;

location / {
try_files $uri $uri/ /index.php?$args;
}

location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php8.3-fpm.sock;
}
}
Check your PHP version: If you are on an older Ubuntu version, change 8.3 to 8.1 or 7.4.

Summary

You have successfully installed the foundation for WordPress. Next, visit your domain in a browser to finish the "Famous 5-Minute Install." Be sure to set your folder permissions so WordPress can upload files:

sudo chown -R www-data:www-data /var/www/wordpress