How to Install WordPress on AlmaLinux 10

How to Install WordPress on AlmaLinux 10

WordPress is a powerful, open-source content management system (CMS) that allows you to easily create and manage websites. It gives you complete control over your content, design, and functionality, whether you’re building a personal blog, a business site, or an online store. This guide will walk you through the steps on how to install WordPress on AlmaLinux 10.

Prerequisites:

  • An Alma Linux 10 VPS
  • At least 2 GB of RAM
  • SSH root access or a system user with sudo privileges

Step 1. Update System Packages

To start, log in to your Alma Linux 10 VPS using SSH:

ssh root@IP_Address -p Port_number

Replace ‘IP_Address’ and ‘Port_number’ with your server’s IP address and SSH port number. If needed, replace ‘root’ with the username of your sudo account.

Once logged in, you must ensure that all AlmaLinux OS packages installed on the server are up to date. You can do this by running the following commands:

dnf update -y && dnf upgrade -y

Step 2. Install LEMP Server:

Afterwards, install the Nginx web server, MySQL server, and PHP using the following command:

dnf install nginx mysql mysql-server php php-{json,mysqlnd,curl,dom,exif,fileinfo,hash,intl,mbstring,openssl,pcre,xml,zip,fpm} python3 augeas-libs

After installing all packages, start the Nginx and MySQL services and enable them to start automatically at system boot by running the following commands:

systemctl start nginx
systemctl enable nginx
systemctl start mysqld
systemctl enable mysqld

Step 3. Create WordPress Database:

Next, you must create a database and a user for WordPress.

First, log in to MySQL with the following command:

mysql

Once you log in, run the following commands to create the database and user:

CREATE DATABASE wordpress_db;
CREATE USER 'wordpress_user'@'localhost' IDENTIFIED BY 'Str0ngP4ssword';
GRANT ALL PRIVILEGES ON wordpress_db.* TO 'wordpress_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;

This will create the database and user needed for the WordPress installation and grant the necessary permissions.

Be sure to update ‘Str0ngP4ssword’ with a more secure password.

Step 4. Create Nginx Server Block File

Next, create a new Nginx server block for your WordPress website.

You can do this by creating a new configuration file in the /etc/nginx/sites-available/ directory:

nano /etc/nginx/conf.d/wordpress.conf

Paste the following into the new file.

server {

    listen 80;

    server_name wordpress.yourdomain.com;
    root /var/www/wordpress;
    index index.php index.html index.htm;

    location / {
        try_files $uri $uri/ /index.php?$args;
    }

    location ~ \.php$ {
        include fastcgi_params;
        fastcgi_pass unix:/run/php-fpm/www.sock;
        fastcgi_intercept_errors on;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }

    location ~ /\.ht {
        deny all;
    }

    access_log /var/log/nginx/wordpress.yourdomain.com_access.log;
    error_log /var/log/nginx/wordpress.yourdomain.com_error.log;

}

Save and close the file.

Finally, test the Nginx configuration for syntax errors and reload:

nginx -t
systemctl reload nginx

Step 5: Install SSL Certificate

In this article, WordPress will be installed using the secure protocol (HTTPS). Therefore, we must install an SSL certificate before proceeding with the remaining steps.

Before generating a new SSL certificate for your wordpress.yourdomain.com, ensure the domain/subdomain’s DNS A record already points to your server’s IP address. If Certbot cannot generate a free SSL certificate, the DNS update has likely not fully propagated yet.

First, you need to install certbot from the source code using the following commands:

sudo python3 -m venv /opt/certbot/
sudo /opt/certbot/bin/pip install --upgrade pip
sudo /opt/certbot/bin/pip install certbot certbot-nginx
sudo ln -s /opt/certbot/bin/certbot /usr/bin/certbot

To run certbot with the Nginx plugin, specifying the name of your domain, execute the following command:

certbot --nginx -d wordpress.yourdomain.com

After executing this command, you must fill in a few entries, such as your email address, agreement to the terms and conditions, whether you want to share your email address, and your preferred redirect options.

[root@wordpress ~]# certbot --nginx -d wordpress.yourdomain.com
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Enter email address or hit Enter to skip.
 (Enter 'c' to cancel): admin@wordpress.yourdomain.com

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at:
https://letsencrypt.org/documents/LE-SA-v1.5-February-24-2025.pdf
You must agree in order to register with the ACME server. Do you agree?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: y

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing, once your first certificate is successfully issued, to
share your email address with the Electronic Frontier Foundation, a founding
partner of the Let's Encrypt project and the non-profit organization that
develops Certbot? We'd like to send you email about our work encrypting the web,
EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: n
Account registered.
Requesting a certificate for wordpress.yourdomain.com

Successfully received certificate.
Certificate is saved at: /etc/letsencrypt/live/wordpress.yourdomain.com/fullchain.pem
Key is saved at:         /etc/letsencrypt/live/wordpress.yourdomain.com/privkey.pem
This certificate expires on 2025-07-15.
These files will be updated when the certificate renews.

Deploying certificate
Successfully deployed certificate for malves.rosehostingtest.com to /etc/nginx/conf.d/wordpress.conf
Congratulations! You have successfully enabled HTTPS on https://wordpress.yourdomain.com

NEXT STEPS:
- The certificate will need to be renewed before it expires. Certbot can automatically renew the certificate in the background, but you may need to take steps to enable that functionality. See https://certbot.org/renewal-setup for instructions.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
If you like Certbot, please consider supporting our work by:
 * Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
 * Donating to EFF:                    https://eff.org/donate-le
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

If everything is set up correctly, the certificate will be installed, and you can access your website securely at https://wordpress.yourdomain.com.

Step 6. Install WordPress:

Next, you will also need to install WordPress on your system.

Method 1. Install WordPress with WP-CLI

You can download the latest version of the WP-CLI binary package to the /usr/local/bin directory with the following command:

wget https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar -O /usr/local/bin/wp

The command above will download the wp-cli.phar file and save it as /usr/local/bin/wp, allowing you to run the wp command from anywhere in your terminal.

But first, let’s make the file executable with the following command:

chmod +x /usr/local/bin/wp

Now, you should be able to run ‘wp’, for example

wp --info

You should see the following output:

# wp --info
OS:     Linux 6.11.0-0.rc5.23.el10.x86_64_v2 #1 SMP PREEMPT_DYNAMIC Mon Nov 25 15:41:36 UTC 2024 x86_64
Shell:  /bin/bash
PHP binary:     /usr/bin/php
PHP version:    8.3.10
php.ini used:   /etc/php.ini
MySQL binary:   /usr/bin/mysql
MySQL version:  mysql  Ver 8.4.2 for Linux on x86_64 (Source distribution)
SQL modes:      ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
WP-CLI root dir:        phar://wp-cli.phar/vendor/wp-cli/wp-cli
WP-CLI vendor dir:      phar://wp-cli.phar/vendor
WP_CLI phar path:       /root
WP-CLI packages dir:
WP-CLI cache dir:       /root/.wp-cli/cache
WP-CLI global config:
WP-CLI project config:
WP-CLI version: 2.11.0

Next, let’s create a directory for our WordPress website’s document root, then download the latest version of WordPress.

mkdir /var/www/wordpress 
cd /var/www/wordpress 
chown -R nginx: /var/www/wordpress
sudo -u nginx wp core download

This will create the folder and download the latest WordPress files into it. Once downloaded, you can proceed with the configuration and installation steps.

Let’s proceed with creating the wp-config.php file. Before running the command below, make sure to replace ‘wordpress_db’, ‘wordpress_user’, and ‘Str0ngP4ssword’ with your actual database details:

sudo -u nginx wp core config --dbhost=localhost --dbname=wordpress_db --dbuser=wordpress_user --dbpass=Str0ngP4ssword

You will see a message that the wp-config.php file is generated.

Now that we have the wp-config.php file, we can install WordPress.

Run the following command to install WordPress. Make sure to modify the site URL, title, admin username, password, and email before executing:

sudo -u nginx wp core install --url=https://malves.rosehostingtest.com/ --title="New WordPress Website" --admin_name=MyWordPressAdminUser --admin_password=Str0ngP4ssword --admin_email=youremail@yourdomain.com

Be sure to update ‘Str0ngP4ssword’ with a more secure password.

You will see a successful message like this:

Success: WordPress installed successfully.

Method 2. Download and install WordPress files

Download the latest version of WordPress with the following command:

cd /tmp/ && wget https://wordpress.org/latest.zip

unzip latest.zip -d /var/www

chown -R nginx: /var/www/wordpress/

Now, create the wp-config.php file by copying the sample file and then editing it to include your database credentials:

mv /var/www/wordpress/wp-config-sample.php /var/www/wordpress/wp-config.php

Then, open the wp-config.php file in your preferred text editor:

nano /var/www/wordpress/wp-config.php

Find the following lines and update them with your actual database name, username, and password:

define( 'DB_NAME', wordpress_db);

define( 'DB_USER', wordpress_user);

define( 'DB_PASSWORD', Str0ngP4ssword);

define( 'DB_HOST', 'localhost' );

After making the changes, save the file (CTRL+O and Enter) and exit (CTRL+X).

Now that we have the wp-config.php file, we can install WordPress.

Now, open your web browser and go to https://wordpress.yourdomain.com.

Select your preferred language and click the “Continue” button.

On the next screen, fill in the required details such as:

  • Site Title
  • Username
  • Password
  • Your Email Address

Then click “Install WordPress”.

After a few moments, you’ll see a success message.

You have successfully learned how to install WordPress on AlmaLinux 10

That’s it! You have successfully installed WordPress at https://wordpress.yourdomain.com/. You can now open it in any web browser to start building and customizing your site. For more information about WordPress, its features, and configuration, consult the official documentation.

Of course, you don’t have to install WordPress on Alma Linux 10 if you use one of our AlmaLinux VPS Hosting services, in which case you can ask our expert Linux admins to install and configure WordPress on Alma Linux 10 for you. They are available 24×7 and will take care of your request immediately.

If you liked this post on how to install WordPress on Alma Linux 10, please share it with your friends or leave a comment below. Thanks

Leave a Comment