In this tutorial you’ll learn to set up WordPress the most popular CMS (content management system) on ubuntu 18.04.
Please Note :
In order to complete this tutorial, You probably have installed Nginx, MySQL, and PHP already on your Ubuntu 18.04.
If you haven’t installed them already then refer Install PHP, MYSQL and PHPMyAdmin to configure them before installing WordPress.
Configure Nginx
Open up the Nginx configuration file using the following command.
Add the following lines of code inside the server block to avoid log requests for favicon.ico
, robots.txt
and the regular expression location to match any requests for static files (.css, .gif, .ico, .jpeg, .jpg, .js, .png)
Change the existing try_files
under location blocks to index.php
file with the request arguments as shown below.
Check the configuration file for syntax errors by typing
Now, restart your Nginx Server using the following command
Creating a MySQL database along with a User for WordPress
Log into the MySQL account by the following command.
Now, We’ll create the database known as ‘wordpress’ by typing:
Next, we will be creating a separate MySQL user account with password that we will grant access to the newly created ‘wordpress’ database by typing the following command:
Note :
I have created the user with the name bishrulhaq and you can change as you like by specifiying any name you want.
Now it’s time to flush the privileges so that the current instance of MySQL knows about the recent changes we’ve made by entering the following command:
To check the databases type the following command :
Exit out of MySQL by typing the command below which will exit from the MySQL session and return to the regular Linux shell.
Download and install WordPress
Now that we have configured the database and user, It’s time to install the latest WordPress from their site.
Go to WordPress Download and you’ll see an option to download the .tar
file. copy the download link of .tar
file and extract the compressed file by using the following commands.
Copy the sample configuration file to the wp-config.php
file by typing the following command:
Now, move the entire contents of the directory into the html directory by typing the following command.
Next, assign ownership to html directory by the www-data
user and group
Configure WordPress
Open the WordPress configuration file and alter the database values and add the define('FS_METHOD', 'direct')
method which allows the ‘direct‘ method to install wordpress plugins, themes, or updates.
Now grab the secure values from the WordPress secret key generator to set the keys at configuration file to provide extra layer of security to the cookies and passwords.
Grab the secret keys by entering the following command:
Alter the values in the configuration file by copying the generated secret keys.
Save and close the configuration file when you are finished editing.
Now, navigate to your browser and complete the installing through the web interface.
Hope this article helped you 😊. If you like this please share with others and drop your ideas and suggestions at the comment section.