WordPress is the most popular CMS (content management system) in the world and it is used for the creation of over 30% of all websites in the world. There are different ways that you can install WordPress, but in the following article are going to show you how to install WordPress on Nginx, which is an alternative to the more famous Apache server, but it consumes fewer resources. Have in mind that this is a bit more advanced way of installation and non-geeks might experience difficulties in the process.
Also, Read Best Fixes for “ECONNREFUSED – Connection refused by server” Error in FileZilla
How To Install WordPress on Nginx CentOS 7
To Install WordPress on Nginx you should start with the creation of your virtual host, that is going to be used for your WordPress installation. The configuration for that host can be found in /etc/nginx/conf.d directory. What you will see in this file is the domain name, port, document root, log location, and some additional information.
If you assume that the domain name is: wordpress.isgeek.local,
port number: 80,
The document root: /usr/share/nginx/wordpress.isgeek.local
and logs: /user/share/nginx/wordpress.isgeek.local/logs you should first create your virtual post, which is achievable with the following code:
Then, you should create your root document directory and the directory for the logs.
To do that, write the following lines of code:
Then you should verify your configuration. To do that write the following line of code: nginex -t and you should see a message saying “syntax is OK, test is successful.”
This means that everything is running smoothly and then you should restart the services. What you have to do next is to type in:
systemctl restart nginx
systemctl restart php-fpm
The next step is to create the database for your WordPress website. To do that, log into your database, and create your database with the:
CREATE DATABASE WordPress; line of code, then, create your User, which can be done by typing:
CREATE USER ‘wpuser’@’localhost’ IDENTIFIED BY ‘wppassword’;
Change WPuser and WPpassword with your username and password.
Next, you have to add permissions to your newly created user, to do that write GRANT ALL PRIVILEGES ON wordpress.* TO ‘wpuser’@’localhost’; and then type exit to leave the shell.
After you’ve successfully completed the creation process of your database its time to configure your WordPress. To do that download the latest WordPress release, by typing:
cp /usr/share/nginx/wordpress.itzgeek.local/wp-config-sample.php /usr/share/nginx/wordpress.isgeek.local/wp-config.php
The next step is to edit your config file and add the database information, to do that type in vi /usr/share/nginx/wordpress.itzgeek.local/wp-config.php. When the file is opened, it should look as it follows:
What you should change are the values that we put in bold.
Then, make the Nginx user the admin or owner of the directory where WordPress will be installed. Use the following command:
chown -R nginx:nginx /usr/share/nginx/wordpress.itzgeek.local/
Now you have to open a browser tab and type in wordpress.isgeek.local to log into your website.
Here you will have to write down your site title, username, password, and your email. These are the details that you are going to use to log into your admin dashboard of WordPress. When you are ready click on the Install WordPress button, and then you will see a success message.
If you click on the login button you will be redirected to the admin login panel where you can log into your WordPress website. And you are done with the whole process.