Menu

How to Install WordPress on Ubuntu Complete

How to Install WordPress on Ubuntu Complete

Complete Guide on How to Install WordPress on Ubuntu 20.04 – Packages that must be installed first are the Nginx HTTP Server, PHP and MariaDB Database. Because wordpress requires it to run.

WordPress is one of the most popular CMS in the world and is open source. The advantage of wordpress is that it is easy to manage. We don’t need any coding skills to edit it. WordPress can be installed on various servers such as ubuntu 20.04.

Before using wordpress, you should understand how to install wordpress on ubuntu. So that when there is trouble you know what to do

To start installing wordpress on ubuntu, follow the steps below:

Install the Nginx HTTP Server

WordPress requires a web server to function, and Nginx is one of the most popular open source web servers available today.

To install Nginx on Ubuntu, run the command below:

sudo apt update
sudo apt install nginx

After installing Nginx, the commands below can be used to stop, start and enable the Nginx service to always run when the server boots.

sudo systemctl stop nginx.service
systemctl start nginx.service
sudo systemctl enable nginx.service

To test if Nginx is installed and working, open your web browser and type in the ip address. If successful, a page will appear as shown below.

Install MariaDB Database Server

You will also need a database server to run WordPress. A database is a repository for WordPress content.

The database server that is usually used for wordpress is MariaDB. Besides that, it has the advantage of being fast, safe and lightweight to run on linux.

To install MariaDB, run the command below:

sudo apt-get install mariadb-server mariadb-client

After installing MariaDB, the commands below can be used to stop, start and activate the MariaDB service.

sudo systemctl stop mariadb.service
systemctl start mariadb.service
sudo systemctl enable mariadb.service

Next, run the command below to secure the
database server . You can use the root password.

sudo mysql_secure_installation

When you have questions, answer as the guide below.

  • Enter current password for root (enter for none): Press Enter
  • Set root password? [Y / n]: Y
  • New password: Enter a Password
  • Re-enter new password: Repeat Password
  • Remove anonymous users? [Y / n]: Y
  • Disallow root login remotely? [Y / n]: Y
  • Remove test database and access to it? [Y / n]: Y
  • Reload privileged tables now? [Y / n]: Y

To verify and validate that MariaDB is installed and working, log in to the database console using the commands below:

sudo mysql -u root –p

Enter the root password when prompted. If successful, it will enter the database as shown above.

Install PHP 7.4 and related modules

WordPress is a PHP based application, and PHP is required to run it. Since some versions of Ubuntu don’t have the latest version of PHP, you can add third-party PPA repositories to install PHP.

sudo apt-get install software-properties-common
sudo add-apt-repository ppa: ondrej / php

Then update and upgrade to PHP 7.4

sudo apt update

Next, run the commands below to install PHP 7.4 and related modules.

sudo apt install php7.4-fpm php7.4-common php7.4-mysql php7.4-gmp php7.4-curl php7.4-intl php7.4-mbstring php7.4-xmlrpc php7.4-gd php7. 4-xml php7.4-cli php7.4-zip

After installing PHP 7.4, open it and configure some basic settings for WordPress to function properly.

Run the command below to open PHP.

sudo nano /etc/php/7.4/fpm/php.ini

Below are good settings to configure for a WordPress website.

file_uploads = On
allow_url_fopen = On
short_open_tag = On
memory_limit = 256M
cgi.fix_pathinfo = 0
upload_max_filesize = 100M
max_execution_time = 360
date.timezone = india

Creating a WordPress Database

When all the necessary tools have been installed, it is time to create a database for wordpress. First, run the steps below to create a blank database.

Log into the MariaDB database console using the command below:

sudo mysql -u root –p

Then create a database with the name wpdp

CREATE DATABASE wpdb ;

Next create a user database with the name wpdbuser and setting a password

CREATE USER ‘ wpdbuser ‘ @ ‘localhost’ IDENTIFIED BY ‘ enter new_password ‘;

Then give the user full access to the database.

GRANT ALL ON wpdb . * TO ‘ wpdbuser ‘ @ ‘localhost’ WITH GRANT OPTION;

Finally, save changes and exit.

FLUSH PRIVILEGES;
EXIT;

Download WordPress

At this point, WordPress is ready to be downloaded and installed. Use the command below to download the latest version of WordPress.

cd / tmp
wget https://wordpress.org/latest.tar.gz
tar -xvzf latest.tar.gz
sudo mv wordpress / var / www / wordpress

Then run the command below to allow the www-data user to own a WordPress directory.

sudo chown -R www-data: www-data / var / www / wordpress /
sudo chmod -R 755 / var / www / wordpress /

Configure Nginx

Below is where you configure the Nginx VirtualHost file for the WordPress site you are creating. This file contains configuration for wordpress directory and url.

Run the command below to create a new VirtualHost file with the name wordpress in the / etc / nginx / sites-available / directory.

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

Copy the configuration below and save it into the file that was created earlier.

server {
listen 80;
listen [::]: 80;
root / var / www / wordpress;
index index.php index.html index.htm;
server_name domain_or_ip_communication;
client_max_body_size 100M;
autoindex off;
location / {
try_files $ uri $ uri / /index.php?$args;
}
location ~ .php $ {
include snippets / fastcgi-php.conf;
fastcgi_pass unix: /var/run/php/php7.4-fpm.sock;
fastcgi_param SCRIPT_FILENAME $ document_root $ fastcgi_script_name;
include fastcgi_params;
}
}

Save the file and exit.

After saving the above file, run the command below to activate the new site, then restart the Nginx server.

sudo ln -s / etc / nginx / sites-available / wordpress / etc / nginx / sites-enabled /
sudo systemctl restart nginx.service

Yey, wordpress is ready to be accessed, try to access it using your ip in the browser.

Then you just have to continue by filling in the database name,
username, password, website information and others.

If you have tried logging into your wordpress dashboard.

Hopefully it can be useful :). If you have questions or criticisms and suggestions, please write in the comments column.

Leave a Reply

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