21.7 C
Texas
angeloma
Senior Writer and partner

How to install WordPress with Nginx on Ubuntu 20.04?

Hi, folks. In this post, we will help you install WordPress with Nginx on Ubuntu 20.04. It’s a lot easier than you think. So let’s go for it.

What is WordPress?

WordPress is a CMS (content manager system) that is to say it is an application that allows you to create a blog of information. However, over time has evolved and not only provides services to create blogs but corporate websites or what you can imagine.

Thanks to WordPress and CMS, publish news and entries, do not require knowledge of HTML or PHP, but everything is visual.

So, if you want to have a personal blog or for educational purposes, WordPress is a pretty good solution.

Install WordPress with Nginx on Ubuntu 20.04

1.- Install LEMP on Ubuntu 20.04

- Advertisement -

WordPress is an application created with PHP. That is, we need a server like Apache or Nginx. In this post, we will choose the last one.

So, installing LEMP is the first step to do. You can read about it.

How to install LEMP on Ubuntu 20.04?

It is also important that you install these PHP modules:

php7.4-common php7.4-mbstring php7.4-xmlrpc php7.4-soap php7.4-gd php7.4-xml php7.4-intl php7.4-mysql php7.4-cli php7.4-ldap php7.4-zip php7.4-curl php-fpm

And now you can continue.

2.- Configuring MariaDB

WordPress requires a relational database manager like MariaDB. So the most convenient thing is to create a new database for WordPress.

So, access the MariaDB shell:

:~$ sudo mysql -u root -p

Now create the new database:

> CREATE DATABASE wordpress;

Then create and assign permissions to a new user dedicated to WordPress. This will avoid working with the root user.

> GRANT ALL PRIVILEGES on wordpress.* TO 'wordpress_user'@'localhost' IDENTIFIED BY 'wordpress_pss123';
> FLUSH PRIVILEGES;

Finally get out of MariaDB’s console.

> exit;
1.- Creating a new Database for WordPress
1.- Creating a new Database for WordPress

Now let’s continue.

3.- Downloading WordPress

Now we can get started with the WordPress download. To do this, we will do it from the /tmp/ folder and using the wget command.

:~$ cd /tmp/
:~$ wget -c https://wordpress.org/latest.tar.gz
--2020-04-30 15:41:25-- https://wordpress.org/latest.tar.gz
Resolving wordpress.org (wordpress.org)… 198.143.164.252
Connecting to wordpress.org (wordpress.org)|198.143.164.252|:443… connected.
HTTP request sent, awaiting response… 200 OK
Length: 12234700 (12M) [application/octet-stream]
Saving to: ‘latest.tar.gz’
latest.tar.gz 100%[=====================================================================================>] 11.67M 77.0KB/s in 67s
2020-04-30 15:42:34 (178 KB/s) - ‘latest.tar.gz’ saved [12234700/12234700]

Once you have downloaded the file. Decompress it.

:~$ tar -xvzf latest.tar.gz

Then, move it to Nginx’s root directory, assign the correct permissions to the folder and make Nginx the owner of it.

:~$ sudo mv wordpress/ /var/www/html/
:~$ sudo chown -R www-data:www-data /var/www/html/wordpress/
:~$ sudo chmod 755 -R /var/www/html/wordpress/

Next, we need to make a new Nginx Server Block for WordPress. To do this, create a new file in /etc/nginx/sites-available/ called wordpress.conf

:~$ sudo nano /etc/nginx/sites-available/wordpress.conf

And add the following content:

server {
listen 80;
server_name blog.osradar.test;
root /var/www/html/wordpress;
index index.php;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ .php$ {
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
fastcgi_index index.php;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_param SERVER_NAME $host;
}
location ~ /files{
deny all;
}
}
2.- Nginx server block for WordPress
2.- Nginx server block for WordPress

Of course, replace “your-domain” with yours. Save the changes and close the file.

Next, restart Nginx to enable the new server Block.

:~$ sudo systemctl restart nginx

So, you need to complete the installation using the web interface.

4.- Install WordPress with Nginx on Ubuntu 20.04

Now it is necessary to complete the installation of WordPress and for that there is the installation wizard.

So, open a web browser and go to http://your-server and you will see the following screen.

3.- Installing WordPress with Nginx on Ubuntu 20.04
3.- Installing WordPress with Nginx on Ubuntu 20.04

Once you have chosen the language of your preference. Continue the installation.

On the next screen, you will be informed that some information is needed from your database.

4.- WordPress installation
4.- WordPress installation

Then, enter the credentials from the database we created earlier.

5.- WordPress database credentials
5.- WordPress database credentials

Then, start the installation.

6.- Make the installation
6.- Make the installation

If everything went well, you will have to enter the information of the website you are creating. As well as the creation of the administrator account.

7.- Site information and admin account
7.- Site information and admin account

In the end, you will see that everything has been a success and you can log in.

8.- WordPress with Nginx installed
8.- WordPress with Nginx installed

Then, you will see the Log in screen.

9.- WordPress login screen
9.- WordPress login screen

When you log in you will see the dashboard.

10.- WordPress with Nginx on Ubuntu 20.04
10.- WordPress with Nginx on Ubuntu 20.04

And that’s it. WordPress is installed correctly.

Conclusion

WordPress is a fairly popular CMS. Thanks to this application, you can create your website in a short time and without great knowledge of HTML. Also, in this post, you have seen that installing it is not too complicated for the great advantages it provides.

Please share this post with your friends and join our Telegram channel.

- Advertisement -
Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

1 COMMENT

  1. This worked great!

    The only thing I had to do differently is the Nginx block for WordPress was not working for me. so I had to change the value in the Default file (the file in /etc/nginx/sites-available/) on line 41 that begins with “root /var/www/html” to “/var/www/html/wordpress” in order for me to launch WordPress directly to the domain. Without this change, I would see the Welcome to NGINX page; so to go to WordPress I would have to add /wordpress.

    I did follow the instructions from the LEMP page, but besides the change I made, would I run into any problems for my Developer Environment?

LEAVE A REPLY

Please enter your comment!
Please enter your name here



Latest article