WordPress is a popular Content Management System (CMS) that allows users to create and manage websites without any coding knowledge. In this guide, we will walk you through the process of installing WordPress on Rocky Linux 9 using the LEMP (Linux, Nginx, MySQL, PHP) stack. By following these steps, you will be able to set up a fully functional WordPress website and start creating content in no time.
Step 1: Creating the Database
The first step in installing WordPress is to create a database and a user that will interact with the database. This database will be used to store all the data for your WordPress website. To create the database, follow these steps:
- Log in to your MariaDB database server using the following command:
mysql -u root -p
- Once you are logged in, create a new database called ‘wordpress’ by running the following command:
CREATE DATABASE wordpress;
- Next, create a new MySQL user account that will be used to operate on the WordPress database. Replace
<Enter Strong Password here>
with a strong password of your choice:
CREATE USER 'admin'@'localhost' IDENTIFIED BY '<Enter Strong Password here>';
- Link the user and the database together by granting the user access to the database:
GRANT ALL ON wordpress.* TO 'admin'@'localhost';
- Flush the privileges so that MySQL knows about the user permissions:
FLUSH PRIVILEGES;
- Exit out of the MySQL command prompt by typing:
exit
Step 2: Configuring Nginx
In this step, we will configure the Nginx server to host the WordPress website. We will create a root directory and provide the necessary information to the Nginx server block. If you have a domain that you want to use for your WordPress website, make sure to include it in the server block as well. Follow these steps to configure Nginx:
- Create a directory to store your WordPress files. Replace ‘example.com’ with your preferred domain name:
mkdir -p /var/www/html/example.com/public_html
- Create an Nginx configuration file for your website. The file name should have a ‘.conf’ extension. Replace ‘example.com’ with your preferred domain name:
nano /etc/nginx/conf.d/example.com.conf
- Inside 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 index.html index.htm; 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; } }
- Save the file and exit the editor.
- Test the Nginx configuration for any errors:
nginx -t
- If there are no errors, restart Nginx for the changes to take effect:
systemctl restart nginx
Step 3: Downloading and Extracting WordPress
Now that we have the database and Nginx configured, we can proceed to download and extract the WordPress files. Follow these steps:
- Download the latest version of WordPress using the curl command:
curl -L -O http://wordpress.org/latest.tar.gz
- Extract the downloaded file:
tar xf latest.tar.gz
- Move the extracted WordPress files to the root directory of your website:
mv wordpress/* /var/www/html/example.com/public_html/
Step 4: Configuring wp-config.php
In this step, we will configure the wp-config.php file, which contains the necessary settings for WordPress to connect to the database. Follow these steps:
- Change to the WordPress directory:
cd /var/www/html/example.com/public_html/
- Make a copy of the wp-config-sample.php file and rename it to wp-config.php:
cp wp-config-sample.php wp-config.php
- Open the wp-config.php file in your favorite editor:
nano wp-config.php
- Replace 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' );
- Save the file and exit the editor.
Step 5: Updating File Permissions
To ensure that WordPress can read and write files, we need to update the file permissions. Follow these steps:
- Set the ownership of the WordPress files to the Nginx user:
chown -R nginx:nginx /var/www/html/example.com/public_html
- Set the SELinux security context for the WordPress files:
chcon -R -t httpd_sys_content_t /var/www/html/example.com/public_html
Step 6: Starting WordPress Installation
Now that we have completed the installation and configuration steps, we can start the WordPress installation process. Follow these steps:
- Open your web browser and navigate to your server’s IP address or your domain name (e.g., http://server_IP/ or http://example.com).
- You will see the WordPress installation page. Click on the “Run the installation” button to start the installation process.
- On the next page, provide the requested information, including the site title, username, password, and email address. Make sure to choose a strong password for the admin user.
- Once you have filled in the details, click on the “Install WordPress” button to complete the installation.
- After the installation is complete, you can log in to your WordPress dashboard using the username and password you provided during the installation process.
Congratulations! You have successfully installed WordPress on Rocky Linux 9 using the LEMP stack. You can now start customizing your website, installing themes and plugins, and creating content.
Conclusion
Installing WordPress on Rocky Linux 9 with the LEMP stack is a straightforward process that allows you to create and manage your website without any coding knowledge. By following the steps outlined in this guide, you can set up a fully functional WordPress website and start building your online presence.
If you’re looking for reliable and scalable hosting solutions for your WordPress website, consider Shape.host. With their Linux SSD VPS plans, you can enjoy high performance and excellent support for your website. Shape.host provides reliable cloud hosting services that are tailored to meet the needs of businesses of all sizes.