Install WordPress on AlmaLinux 9 with Nginx

Install WordPress on AlmaLinux 9 with Nginx

WordPress remains one of the most popular content management systems globally, enabling users to create dynamic websites and blogs with ease. Installing WordPress on AlmaLinux 9, powered by Nginx, provides a robust foundation for web development and content creation. This tutorial will guide you through the process of setting up WordPress on AlmaLinux 9, utilizing Nginx as the web server.

Tutorial Environment

In this tutorial, we will work with the following server, operating system, and software:

  • Vultr Cloud Server: 1 CPU, 1 GB RAM, 32 GB Storage
  • Operating System: AlmaLinux 9
  • Domain: aminlabs.my.id
  • SSL: Let’s Encrypt
  • Web Server: Nginx v1.20
  • PHP: PHP v8.2
  • Database: MariaDB v10.5
  • WordPress: WordPress v6.4.3

Note: Register here to get $100 free credit from Vultr.

Step 1: Update system packages

Connect to your server and ensure your system packages are up-to-date:

Note: This tutorial uses the root user.

Step 2: Install Nginx web server

Execute the following command to install the Nginx web server on AlmaLinux:

After the installation is complete, start the Nginx service and enable it to start on boot:

You can verify the Nginx service status to ensure it’s running without any issues:

Open HTTP and HTTPS ports in firewall, execute the following commands:

Step 3: Install MariaDB database

Install MariaDB server using the following command:

Start the MariaDB service and enable it to start on boot:

Step 4: Create a Database

Log in to MariaDB server:

Create a MariaDB database for WordPress:

Step 5: Install PHP 8.2

To install PHP 8.2 on AlmaLinux 9, you need to add the EPEL repository and the REMI repository to your system. These repositories provide additional packages, including newer versions of PHP that are not available in the default AlmaLinux repositories.

EPEL (Extra Packages for Enterprise Linux) repository provides additional packages for CentOS and its derivatives like AlmaLinux. Install the EPEL repository using the following command:

REMI repository provides updated versions of various software packages, including PHP, that are not available in the default repositories. Install the REMI repository by executing the following commands:

Once you have installed the REMI repository, enable the PHP 8.2 repository:

Now, you can install PHP 8.2 and the required PHP modules:

Create a symbolic link for php82:

Open PHP-FPM pool configuration file:

Adjust the configuration as below:

Start the PHP-FPM service and enable it to start on boot:

Step 6: Configure Server Block

Create the directory for aminlabs.my.id:

Create a server block configuration for the domain aminlabs.my.id:

Insert the following virtual host configuration:

Restart the Nginx service to reload configuration:

Step 7: Install SSL from Let’s Encrypt

Let’s Encrypt is a free, automated, and open certificate authority that provides digital certificates for enabling HTTPS (SSL/TLS) on websites. It was launched in 2015 by the Internet Security Research Group (ISRG) with the aim of making it easier for website owners to secure their websites with HTTPS. Let’s Encrypt certificates are trusted by all major browsers and are valid for 90 days, after which they can be renewed automatically.

Install Certbot and the Nginx web server plugin:

Request an SSL certificate for aminlabs.my.id and www.aminlabs.my.id. The email address is used to send notifications when the SSL certificate is about to expire.

Example message displayed when the SSL certificate request is successful:

Step 8: Install WordPress via WP-CLI

WP-CLI (WordPress Command Line Interface) is a powerful tool for managing WordPress installations from the command line. It provides a convenient and efficient way to perform various tasks such as installing, updating, and managing WordPress sites without needing to use a web browser.

With WP-CLI, you can automate WordPress tasks, script complex operations, and interact with your WordPress site’s database directly from the command line interface. This makes it an indispensable tool for developers, system administrators, and anyone who manages multiple WordPress sites.

Begin by installing WP-CLI on your server. You can download the Phar file and make it executable for global use:

Navigate to document root directory:

Download the latest WordPress core files using WP-CLI:

Generate the wp-config.php file using WP-CLI and provide the necessary database information:

Install WordPress and create an admin account:

The message displayed when WordPress installation is successful:

Change the user and group of the WordPress files to the user and group of the Nginx web server:

The WordPress installation process has been completed. Browse the domain to try the installation result.

Leave a Reply

Your email address will not be published. Required fields are marked *