WordPress is a popular Content Management System (CMS) that allows you to build and manage websites without any coding knowledge. In this step-by-step guide, we will walk you through the process of installing WordPress on AlmaLinux 9 with a LEMP (Linux, Nginx, MariaDB, PHP) stack. By following these instructions, you’ll have your WordPress website up and running in no time.
Prerequisites
Before we begin the installation process, there are a few prerequisites that need to be met. Firstly, you need to have the LEMP stack installed and running on your AlmaLinux 9 server. If you haven’t done this already, you can refer to the official documentation on how to install the LEMP stack.
Once the LEMP stack is installed, you need to update the firewall settings to allow HTTP and HTTPS traffic. Run the following commands to update the firewall settings:
firewall-cmd --permanent --zone=public --add-service=http firewall-cmd --permanent --zone=public --add-service=https firewall-cmd --reload
Secure MariaDB Installation
Next, we need to secure the MariaDB installation and set a root password. Run the following command to start the secure installation process:
mysql_secure_installation
This command will prompt you to enter the current password for the root user. Since we are setting up a new installation, simply press Enter. You will then be asked if you want to set a root password. Type “Y” and follow the prompts to set a strong password.
Creating the Database
Now that MariaDB is secured, we can create a new database for WordPress. Log into MySQL with the following command:
mysql -u root -p
Once you are logged in, run the following commands to create a new database, user, and grant privileges:
CREATE DATABASE wordpress; CREATE USER 'admin'@'localhost' IDENTIFIED BY '<Enter Strong Password here>'; GRANT ALL ON wordpress.* TO 'admin'@'localhost'; FLUSH PRIVILEGES;
Make sure to replace <Enter Strong Password here>
with a strong password for your MySQL user.
Configure Nginx
Now, let’s configure Nginx to serve our WordPress website. Start by creating a directory to store your website files:
mkdir -p /var/www/html/example.com/public_html
Replace example.com
with your preferred domain name.
Next, create an Nginx configuration file for your website:
nano /etc/nginx/conf.d/example.com.conf
In the configuration file, add the following code:
server { listen 80; listen [::]:80; server_name example.com www.example.com; root /var/www/html/example.com/public_html; index index.php; location / { index index.php index.html index.htm; try_files $uri $uri/ =404; } location ~* \.php$ { fastcgi_pass unix:/run/php-fpm/www.sock; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param SCRIPT_NAME $fastcgi_script_name; } }
Make sure to replace example.com
with your preferred domain name.
To test the Nginx configuration for any errors, run the following command:
nginx -t
If there are no errors, restart Nginx to apply the changes:
systemctl restart nginx
Download and Extract WordPress
Now, let’s download and extract the latest version of WordPress. Run the following commands:
curl -L -O http://wordpress.org/latest.tar.gz tar xf latest.tar.gz mv wordpress/* /var/www/html/example.com/public_html/
Make sure to replace example.com
with your preferred domain name.
Next, we need to configure the wp-config.php
file. Change to the WordPress directory:
cd /var/www/html/example.com/public_html/
Make a copy of the sample configuration file:
cp wp-config-sample.php wp-config.php
Open the wp-config.php
file in your favorite editor and update the following lines with the correct values:
/** The name of the database for WordPress */
define( 'DB_NAME', 'wordpress' );
/** Database username */
define( 'DB_USER', 'admin' );
/** Database password */
define( 'DB_PASSWORD', 'password_here' );
/** Database hostname */
define( 'DB_HOST', 'localhost' );
Replace password_here
with the password you set for the MySQL user earlier.
Update File Permissions
To ensure proper file permissions, run the following commands:
chown -R nginx:nginx /var/www/html/example.com/public_html chcon -R -t httpd_sys_content_t /var/www/html/example.com/public_html
Start WordPress Installation
You’re now ready to start the WordPress installation process. Open your web browser and navigate to http://server_IP/
or http://example.com/
. You should see the WordPress installation page.
Click on the “Run the installation” button to begin. You will be prompted to provide the following information:
- Site Title: Enter the title for your website.
- Username: Choose a username for the admin account.
- Password: Set a strong password for the admin account.
- Your Email: Enter your email address.
Click on the “Install WordPress” button to complete the installation. Once the installation is finished, you can log in to your WordPress admin dashboard using the username and password you set.
Congratulations! You have successfully installed WordPress on AlmaLinux 9 with a LEMP stack. You can now start customizing your website and publishing content.
For reliable and scalable cloud hosting solutions, consider Shape.host’s Cloud VPS services. With Shape.host, you can confidently host your WordPress websites and enjoy top-notch performance and security.