WordPress is a popular Content Management System (CMS) that allows users to easily create and manage websites. NGINX is a high-performance web server that is often used to serve WordPress sites due to its speed and reliability. In this article, we will walk through the steps of installing WordPress on a Fedora Linux system using NGINX.
Prerequisites:
- A Fedora Linux system with root access
- A non-root user with sudo privileges
Step 1: Install NGINX and MariaDB The first step is to install NGINX and MariaDB, a popular open-source database that is often used with WordPress. Run the following command to install both:
sudo dnf install nginx mariadb mariadb-server -y
Step 2: Start and enable NGINX and MariaDB services Once NGINX and MariaDB are installed, start and enable their services by running the following commands:
sudo systemctl start nginx
sudo systemctl enable nginx
sudo systemctl start mariadb
sudo systemctl enable mariadb
Step 3: Secure MariaDB Before we proceed with the installation of WordPress, we need to secure the MariaDB installation. Run the following command to do so:
sudo mysql_secure_installation
Follow the prompts to set a root password, remove anonymous users, disallow root login remotely, and remove test databases.
Step 4: Create a new database and user for WordPress Next, we need to create a new database and user for WordPress. Log into the MariaDB command line using the root password you set in Step 3:
sudo mysql -u root -p
Once logged in, run the following commands to create a new database and user for WordPress:
CREATE DATABASE wordpress;
GRANT ALL ON wordpress.* TO 'wordpressuser'@'localhost' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
EXIT;
Make sure to replace “password” with a secure password of your choice.
Step 5: Download and configure WordPress Download the latest version of WordPress by running the following command:
sudo curl -O https://wordpress.org/latest.tar.gz
Extract the downloaded file by running:
sudo tar xzvf latest.tar.gz
Move the extracted files to the NGINX web root directory:
sudo mv wordpress /usr/share/nginx/html/
Next, change the ownership of the WordPress files to the nginx user:
sudo chown -R nginx:nginx /usr/share/nginx/html/wordpress
Step 6: Create an NGINX virtual host for WordPress Create a new virtual host file for WordPress by running the following command:
sudo nano /etc/nginx/conf.d/wordpress.conf
Add the following configuration to the file:
server {
listen 80;
server_name example.com;
root /usr/share/nginx/html/wordpress;
index index.php;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php-fpm/www.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
Make sure to replace “example.com” with your own domain name.
Save and close the file.
Step 7: Install and configure PHP-FPM Install PHP-FPM and the necessary PHP extensions by running the following command:
sudo dnf install php php-fpm php-mysqlnd -y
Once installed, open the PHP-FPM configuration file by running the following
command:
sudo nano /etc/php-fpm.d/www.conf
Change the following values in the file:
user = nginx
group = nginx
listen = /run/php-fpm/www.sock
listen.owner = nginx
listen.group = nginx
listen.mode = 0660
Save and close the file.
Step 8: Start and enable PHP-FPM service Start and enable the PHP-FPM service by running the following commands:
sudo systemctl start php-fpm
sudo systemctl enable php-fpm
Step 9: Test the configuration Test the configuration by restarting NGINX and PHP-FPM services:
sudo systemctl restart nginx
sudo systemctl restart php-fpm
Next, open a web browser and navigate to your server’s domain name or IP address. You should see the WordPress installation page.
Follow the prompts to configure WordPress with the database and user you created in Step 4.
Step 10: Complete the installation Once you have completed the WordPress installation, you can remove the installation files by running the following command:
sudo rm -rf /usr/share/nginx/html/wordpress/wp-admin/install.php
Congratulations! You have successfully installed WordPress using NGINX on a Fedora Linux system.