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:
- An Ubuntu 22.04 server or desktop environment
- Root access or sudo privileges
Steps to Install WordPress with LEMP
- Install Nginx: Install Nginx web server:
sudo apt update
sudo apt install nginx
- Install MySQL: Install MySQL database server:
sudo apt install mysql-server
- Install PHP: Install PHP and required extensions:
sudo apt install php php-fpm php-mysql
- 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;
}
}
- 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
- 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/
- 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;
- 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.