Install WordPress On Nginx Ubuntu


Install WordPress On Nginx Ubuntu

Introduction

WordPress is a popular open-source blogging platform and content management system (CMS). It is made to be used on the internet, and it is the most widely used blogging platform. It is easy to install, and there are many options available for users to customize their sites. In this tutorial, we will show you how to install WordPress on an Ubuntu system running the Nginx web server.

Prerequisites

Before you begin, you will need to have the following:

  • Ubuntu 18.04 server with a non-root user with sudo privileges.
  • Nginx web server.
  • MySQL or MariaDB to store the WordPress data.
  • PHP installed and configured.

Installing Nginx

The first step is to install Nginx. Nginx is a popular web server that is fast and reliable. To install Nginx, open a terminal and type the following command:

sudo apt-get install nginx

Once the installation is complete, start the Nginx service with the command:

sudo systemctl start nginx

You can also enable the Nginx service so that it starts automatically when the system boots:

sudo systemctl enable nginx

Installing MySQL/MariaDB

Next, we need to install MySQL or MariaDB. These two database systems are compatible with WordPress and will work perfectly. To install MySQL/MariaDB, type the following command:

sudo apt-get install mysql-server

You will be asked to enter a password for the MySQL root user. Enter a secure password, confirm it, and execute the command.

Once the installation is complete, start the database server with the command:

sudo systemctl start mysql

Installing PHP

Once the database server is up and running, we need to install PHP. WordPress requires a few PHP plugins in order to work, so we will install all required plugins. To do this, execute the following command:

sudo apt-get install php-fpm php-mysql

This command will install all the necessary plugins for WordPress. Once the installation is complete, you can check if it was successful by typing the following command:

php -v

This command will output the PHP version number. If you get a version number, then PHP was installed successfully.

We also need to configure Nginx to use PHP. To do this, edit the Nginx configuration file with the command:

sudo nano /etc/nginx/sites-available/default

In this file, replace the line:

index index.html index.htm

With the following line:

index index.php index.html index.htm

And then add the following lines at the end of the file:

location ~ .php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
}

Save and close the file, then restart Nginx with the command:

sudo systemctl restart nginx

Download and Install WordPress

Now, we are ready to install WordPress. We will download the latest version of WordPress from the official website. To do this, open a terminal and type the following command:

curl -O https://wordpress.org/latest.tar.gz

This will download WordPress in the current directory. Next, extract the contents of the archive with the command:

tar xzvf latest.tar.gz

This will extract the contents of the archive into a directory called ‘wordpress’.

We need to configure the WordPress directory so that the web server can access it. To do this, move the contents of the WordPress directory to the web server’s document root directory. To do this, type the following command:

sudo mv worpdpress/ /var/www/html/

The final step in the installation process is to create a MySQL database for WordPress. To do this, log in to the MySQL console with the following command:

sudo mysql -u root -p

Enter the MySQL root password when prompted. Once you are logged in, type the following command to create the WordPress database:

CREATE DATABASE wordpress DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;

Next, create a MySQL user that will be used by WordPress with the command:

CREATE USER 'wordpressuser'@'localhost' IDENTIFIED BY 'password';

Replace ‘wordpressuser’ and ‘password’ with different values. Next, grant the user permissions with the command:

GRANT ALL ON wordpress.* TO 'wordpressuser'@'localhost';

Finally, flush the privileges with the command:

FLUSH PRIVILEGES;

Exit the MySQL console with the command:

EXIT;

Running the WordPress Installation Script

Now, we are ready to run the WordPress installation script. To do this, open your web browser and go to:

http://your_ip_address/wordpress/wp-admin/install.php

You will be taken to the WordPress installation page. Enter your site title, username, password, and email address. When you are finished, click the Install WordPress button at the bottom of the page.

When the installation is complete, log in to the WordPress dashboard with the username and password you specified. You can now start setting up your website and adding content.

Conclusion

In this tutorial, we have shown you how to install WordPress on an Ubuntu system running the Nginx web server. We have also shown you how to set up the MySQL/MariaDB database and configure Nginx to use PHP. We hope you have found this tutorial useful.

Thank you for reading this article. Please read other articles on our website.

Leave a Reply

Your email address will not be published. Required fields are marked *