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”.
Shape.host Resources dashboard showing the Create menu and instance rebuild controls.
  • Select Instance Location:
  • Choose the desired location for your server. For this tutorial, we’ll select “New York, USA”.

Before starting, ensure you have:

Shape.host Create New Instance form with the available data center locations.
  • 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”.
Shape.host instance form with a server plan and Ubuntu image selected.
  • 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
Terminal showing APT package management commands and output.

Step 2: Install Nginx

Install the Nginx web server.

apt install nginx -y
Terminal showing APT package management commands and output.

Start and enable Nginx to run on startup.

systemctl start nginx
systemctl enable nginx
Terminal showing systemd service management commands or output.

Verify that Nginx is running.

systemctl status nginx
Terminal showing systemd service management commands or output.

Step 3: Install MySQL

Install the MySQL server package.

apt install mysql-server -y
Terminal showing systemd service management commands or output.

Secure the MySQL installation.

mysql_secure_installation
Terminal showing MariaDB/MySQL database security configuration prompts.

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
Terminal displaying a MySQL login attempt and access messages.

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;
Terminal showing SQL database and user configuration commands.

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
Terminal showing SQL database and user configuration commands.

Check the PHP version to confirm the installation.

php -v
Terminal showing php commands or output during Install PHP.

Step 6: Configure Nginx for WordPress

Create a new server block file for your domain.

nano /etc/nginx/sites-available/your_domain
Terminal showing php commands or output during Configure Nginx for WordPress.

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;
    }
}
Terminal showing the GNU nano editor and configuration text.

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/
Terminal showing php commands or output during Configure Nginx for WordPress.

Test the Nginx configuration for syntax errors.

nginx -t
Terminal showing Nginx configuration test output.

Reload Nginx to apply the changes.

systemctl reload nginx
Terminal showing systemd service management commands or output.

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
Terminal showing file download commands and transfer output.

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.

WordPress setup interface.
  1. Select your preferred language and click Continue.
  2. 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
WordPress installer database connection settings.
  1. Click Submit and then Run the installation.
  2. Fill out the site information and create an admin account.
WordPress installer form for site title and administrator account details.

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

WordPress installation success screen with a login link.

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.