Introduction

WordPress is a popular content management system (CMS), and LEMP stack consists of Linux, Nginx, MySQL, and PHP, which are commonly used to host WordPress sites. In this guide, we'll walk through the steps to install WordPress with LEMP on Ubuntu 22.04.

Prerequisites

Before proceeding, ensure you have:

  1. An Ubuntu 22.04 server or desktop environment
  2. Root access or sudo privileges

Steps to Install WordPress with LEMP

    1. Install Nginx: Install Nginx web server:
sudo apt update
sudo apt install nginx
    1. Install MySQL: Install MySQL database server:
sudo apt install mysql-server
    1. Install PHP: Install PHP and required extensions:
sudo apt install php php-fpm php-mysql
    1. Configure Nginx: Configure Nginx server block for WordPress:
sudo nano /etc/nginx/sites-available/example.com
server {
    listen 80;
    server_name example.com www.example.com;
    root /var/www/html;
    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:/var/run/php/php7.4-fpm.sock;
    }
    location ~ /\.ht {
        deny all;
    }
}
    1. Enable Nginx Server Block: Enable the Nginx server block:
sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/
sudo systemctl restart nginx
    1. Install WordPress: Download and install WordPress:
cd /tmp
wget https://wordpress.org/latest.tar.gz
tar -xvzf latest.tar.gz
sudo mv wordpress /var/www/html/
    1. Configure MySQL: Create a MySQL database and user for WordPress:
sudo mysql -u root -p
CREATE DATABASE wordpress;
CREATE USER 'wordpressuser'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpressuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;
  1. Complete WordPress Installation: Complete the WordPress installation by visiting your domain in a web browser and following the on-screen instructions.

Conclusion

Congratulations! You have successfully installed WordPress with LEMP stack on your Ubuntu 22.04 server. You can now start building your website using WordPress.

Was this answer helpful? 0 Users Found This Useful (0 Votes)