Setting up WordPress on a LEMP stack (Linux, Nginx, MySQL/MariaDB, PHP) on Ubuntu 22.04 is a popular and powerful way to create a dynamic website. This guide will take you through the steps to get your WordPress site up and running smoothly.
Step 1: Deploying a Cloud Instance on Shape.host
- Log in to Shape.host Dashboard:
- Navigate to the Shape.host website and log in to your account.
- Create a New Instance:
- Click on the “Create” button located at the top right corner of the dashboard.
- From the dropdown menu, select “Instances”.

- Select Instance Location:
- Choose the desired location for your server. For this tutorial, we’ll select “New York, USA”.
Before starting, ensure you have:

- Choose a Plan:
- Select a plan that fits your requirements. For example, you might choose a plan with 2 cores CPU, 2 GB Memory, and 50 GB SSD disk space.
- Select an Operating System:
- Scroll down to the “Choose an image” section and select “Ubuntu 22.04”.

- Configure Additional Options:
- (Optional) You can configure additional options like User Data Configuration and IPv6 Networking.
- Enter a hostname for your instance, e.g., “Tutorial Ubuntu”.
- Click on the “Create instance” button to deploy the instance.
- Step 2: Connecting to Your Instance
- Retrieve SSH Credentials:
- Note the IP address of your newly created instance from the Shape.host dashboard.
- Connect via SSH:
- Open a terminal on your local machine.
- Use the following command to connect to your instance:
sh ssh root@your_instance_ip
- Replace
your_instance_ip
with the actual IP address of your instance.
Step 1: Update Your System
First, update your package lists and upgrade the installed packages to their latest versions.
apt update && sudo apt upgrade -y

Step 2: Install Nginx
Install the Nginx web server.
apt install nginx -y

Start and enable Nginx to run on startup.
systemctl start nginx
systemctl enable nginx

Verify that Nginx is running.
systemctl status nginx

Step 3: Install MySQL
Install the MySQL server package.
apt install mysql-server -y

Secure the MySQL installation.
mysql_secure_installation

During this process, you’ll be prompted to set a root password and make other security-related choices.
Step 4: Create a MySQL Database and User
Log in to the MySQL shell.
mysql

Create a new database and user for WordPress. Replace your_database_name
, your_database_user
, and your_database_password
with your preferred values.
CREATE DATABASE your_database_name;
CREATE USER 'your_database_user'@'localhost' IDENTIFIED BY 'your_database_password';
GRANT ALL PRIVILEGES ON your_database_name.* TO 'your_database_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Explanation:
your_database_name
: Your chosen name for the WordPress database (e.g.,wordpress
).your_database_user
: The username for the WordPress database (e.g.,wpuser
).your_database_password
: A strong password for the MySQL user.
Step 5: Install PHP
Install PHP and the necessary extensions.
apt install php-fpm php-mysql -y

Check the PHP version to confirm the installation.
php -v

Step 6: Configure Nginx for WordPress
Create a new server block file for your domain.
nano /etc/nginx/sites-available/your_domain

Add the following configuration, replacing your_domain
with your actual domain name.
server {
listen 80;
server_name your_domain www.your_domain;
root /var/www/your_domain;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}

Explanation:
your_domain
: Replace with your actual domain name (e.g.,example.com
).root /var/www/your_domain
: Replace with your actual domain name.
Enable the server block by creating a symbolic link in the sites-enabled directory.
ln -s /etc/nginx/sites-available/your_domain /etc/nginx/sites-enabled/

Test the Nginx configuration for syntax errors.
nginx -t

Reload Nginx to apply the changes.
systemctl reload nginx

Step 7: Download and Configure WordPress
Navigate to the web root directory and download the latest version of WordPress.
cd /var/www
wget https://wordpress.org/latest.tar.gz
tar -xvzf latest.tar.gz
mv wordpress your_domain
chown -R www-data:www-data /var/www/your_domain
chmod -R 755 /var/www/your_domain

Explanation:
your_domain
: Replace with your actual domain name (e.g.,example.com
).
Step 8: Complete the Installation Through the Web Interface
Open your web browser and go to http://your_domain
. You should see the WordPress setup page.

- Select your preferred language and click Continue.
- On the database configuration page, enter the database name, username, and password you created earlier.
- Database Name:
your_database_name
- Username:
your_database_user
- Password:
your_database_password

- Click Submit and then Run the installation.
- Fill out the site information and create an admin account.

After completing these steps, your WordPress site should be fully operational on a LEMP stack with Ubuntu 22.04.

For an effortless hosting experience, consider using Shape.host services. Shape.host offers a range of Cloud VPS options that are ideal for hosting your WordPress site, ensuring high performance, security, and support to keep your site running smoothly.