How to Install WordPress with LEMP Stack on Ubuntu 26.04
WordPress is one of the most popular website-building tools available. It provides a simple way to build and manage websites without needing advanced coding knowledge.
Prerequisites
- Root access to your Ubuntu 26.04 server.
- LEMP Stack installed and running. Learn how to setup LEMP Stack.
Creating Database
Log into MariaDB/MySQL:
mysql -u root -p
Inside the MySQL shell, run:
CREATE DATABASE wordpress_db;
CREATE USER 'wordpress_user'@'localhost' IDENTIFIED BY 'password';
Note: Replace username and password with secure values.
Grant permissions:
GRANT ALL PRIVILEGES ON wordpress_db.* TO 'wordpress_user'@'localhost';
FLUSH PRIVILEGES;
Exit:
exit
Output:
root@vps:~# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor.
MariaDB [(none)]> CREATE DATABASE wordpress_db;
Query OK, 1 row affected
MariaDB [(none)]> CREATE USER 'wordpress_user'@'localhost' IDENTIFIED BY 'password';
Query OK, 0 rows affected
MariaDB [(none)]> GRANT ALL PRIVILEGES ON wordpress_db.* TO 'wordpress_user'@'localhost';
Query OK, 0 rows affected
MariaDB [(none)]> FLUSH PRIVILEGES;
Query OK, 0 rows affected
MariaDB [(none)]> exit
Bye
Download and Install WordPress
Download latest WordPress:
wget -O /tmp/wordpress.tar.gz https://wordpress.org/latest.tar.gz
Extract files:
tar -xzvf /tmp/wordpress.tar.gz -C /var/www/
Set correct permissions:
chown -R www-data:www-data /var/www/wordpress
Configure Nginx for WordPress
Create a new server block:
nano /etc/nginx/conf.d/wordpress.conf
Add:
server {
listen 80;
listen [::]:80;
server_name _;
root /var/www/wordpress;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php8.4-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
Test and reload Nginx:
nginx -t
systemctl reload nginx
Configure WordPress
Open browser:
http://IP_ADDRESS
Replace IP_ADDRESS with your server IP.
Follow setup:
- Select language
- Click "Let's go"
- Enter database details:
- Database Name: wordpress_db
- Username: wordpress_user
- Password: password
- Host: localhost
Click Run the Installation
Enter site details and create admin user.
After installation, login to dashboard:
http://IP_ADDRESS/wp-admin
🎉 WordPress is now successfully installed on Ubuntu 26.04 using LEMP Stack.
CrownCloud - Get a SSD powered KVM VPS at $4.5/month!
Use the code WELCOME for 10% off!
1 GB RAM / 25 GB SSD / 1 CPU Core / 1 TB Bandwidth per month
Available Locations: LAX | MIA | ATL | FRA | AMS