4 Steps to Install WordPress on Debian and Ubuntu System


🖊 Written by Updated on

Debian and Ubuntu are both of the most popular Linux distributions. Those are used in various cloud platforms and also in local machines. Today in this article, I am going to explain the steps How you are going to install WordPress in these machines. These machines could be Virtual Machine or Local machines as computers. In this tutorial, we are going to use Debian 10 for WordPress installation, as I have mentioned in the title you can also use Ubuntu 16.04 or Ubuntu 18.04.

So, let’s get started!

Contents
  1. Install WordPress on Debian
    • STEP - 1. Install Apache Server with Latest PHP
    • STEP - 2. Installation of Database
    • STEP - 3. Install WordPress on Debian 10 or Ubuntu 18.04
    • STEP - 4. WordPress Configuration with Database.

Install WordPress on Debian

I am going to explain the simple four steps for the installation of WordPress on Debian 10. You can also use the same command lines for Ubuntu Distribution. Debian and Ubuntu are very similar in the case of their command line.

Installing WordPress CMS, some required programs are needed to Install before WordPress.

  1. Apache Server
  2. PHP
  3. Database (MySQL or MariaDB)
  4. phpMyAdmin (Optional)

STEP – 1. Install Apache Server with Latest PHP

WordPress is a web application, and of course, you need to have a running web server on your system (virtual machine or local computer). WordPress is also compatible with other servers like Nginx and LiteSpeed.

In the meantime, WordPress also can be installed in a Cluster Container like Docker or Kubernetes.

In this tutorial, we are going to use the Apache web server so, open Terminal or SSH session and type:

$ sudo apt-get update

Check PHP version or Installed in system or not.

$ php -v

If PHP is not found shows, then we are going to install the latest version of PHP 7.4

So first, we need to add the newest PHP repository key, and repository list, for this process follow these commands:


$ sudo apt -y install lsb-release apt-transport-https ca-certificates

$ sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
adding the newest PHP repository key, and repository list

Now, add repository list.

echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php.list
Adding PHP repository list

Now Install Latest PHP 7.4 version by using the following commands:

$ sudo apt update

$ sudo apt -y install php7.4
Installing Latest php version 7.4.9

Now check the PHP version; if installed, then it will look like as below in the image.

$ php -v
checking the PHP version

Now install Apace and latest PHP modules.

$ sudo apt install apache2 php7.4 libapache2-mod-php7.4 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
installing Apace and latest PHP modules.

Now enable PHP fpm for the Apache server.

$ sudo a2enmod proxy_fcgi setenvif

$ sudo a2enconf php7.4-fpm
enabling PHP fpm for the Apache server

Then restart Apache server using following command:

$ sudo systemctl restart apache2

After the successful installation of the Apache server and PHP, we need to test the programs it is installed or not.

$ sudo nano /var/www/html/test.php

Now copy these PHP lines and paste it in your terminal (as shown in the image below)

<?php
phpinfo();
?>

Now hit CTRL+X and enter “Y” and hit the Enter key for saving the file.

adding php info code in new test.php file

After saving the file, you need to open your IP address in this format https://your-ip-address/test.php

showing PHP version in browser tab

If your browser window looks like that and showing PHP version and other details, that means your installation is successful.

You can also use the command for checking that, is your Apache server is working or not?

$ sudo service apache2 status
Apache Server Status checking on terminal

STEP – 2. Installation of Database

WordPress requires a database in the backend for managing all the data in structural table format. In this case, MySQL or MariaDB is one of the best choices for the WordPress database.

To install the database, you need to run the following commands:

$ sudo apt install default-mysql-server
Installation of MySQL or MariaDB Database

After the successful installation of the Database, we need to secure it by password, for this step runs the following command.

 $ sudo mysql_secure_installation

This process will prompt five questions, and you need to enter “Y” for the answers. In the first question, enter “Y” and set a new password for the database.

Securing WordPress Database with password

Now, we have secured our Database, now need to create a new database with a new user for WordPress. So, run these following commands.

$ sudo mysql -u root -p
> CREATE DATABASE wordpress;

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

> FLUSH PRIVILEGES;

> EXIT;
create a new database with a new user for WordPress

Now check the databases list for confirmation, use the following commands:

$ mysql -u root -p

*enter your password

> SHOW DATABASES;
checking the databases list

Database creation is successful; next is the installation of WordPress.

STEP – 3. Install WordPress on Debian 10 or Ubuntu 18.04

Now in this step, I am going to Install WordPress CMS on our system. For this process, we need to use wget syntax for downloading the WordPress compressed file. So, run these commands for installing WordPress.

First, change the directory to /tmp folder.

$ cd /tmp/

Now run the following command for WordPress.

$ wget -c https://wordpress.org/latest.tar.gz
Install WordPress on Debian 10 or Ubuntu 18.04

When the download has been completed, we need to decompress the WordPress Source files and move to the /var/www/html/ directory. Next, we need to set write permission to the directory.

$ tar -xvzf latest.tar.gz

$ 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/
WordPress Source files and move to the /var/www/html/ directory

Now, create a new Virtualhost for WordPress, so whenever your type just your naked domain (exmaple.com; without www or http) it will open correctly with the right protocol in any browser.

Use the following command to create a new Virtualhost for WordPress.

$ sudo nano /etc/apache2/sites-available/wordpress.conf

And add these following lines:

<VirtualHost *:80>
    ServerName wpthemeinc.com
    ServerAlias www.wpthemeinc.com
    DocumentRoot /var/www/html/wordpress
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
    <Directory "/var/www/html/wordpress">
        Options FollowSymLinks
        AllowOverride all
        Options -MultiViews
        Require all granted
    </Directory>
</VirtualHost>

Note:- replace “yourdomain.com” to your actual domain name. Save to this file hit CTR+X enter Y and Enter.

When your new Virtualhost file creation is done, then we need to rewrite the Apache module and then reload or restart the Apache server. So, for this process, we need to follow these commands.

$ sudo ln -s /etc/apache2/sites-available/wordpress.conf /etc/apache2/sites-enabled/wordpress.conf

$ sudo a2enmod rewrite

$ sudo systemctl restart apache2
rewrite the Apache module and then reload or restart the Apache server

Now our server-side installations have been completed. Now, we need to configure WordPress.

STEP – 4. WordPress Configuration with Database.

Now, you need to open your domain name in the new browser tab as “example.com.” When you open your domain name, as shown in the picture, you will also be prompt to select your language.

 select your wordpress language

After selecting the language, you will prompt to configure your database with your WordPress CMS.

 configure your database with your WordPress CMS

Now fill all the credentials of the database, which was we have created in the second step.

filling all the credentials of the database

After filling the credentials of the database, WordPress will prompt you to run WordPress installations, so click on “Run the installation.”

Run the WordPress installation

Then configure WordPress Admin credentials and Website Name.

configure WordPress Admin credentials and Website Name

Now login to your WordPress Dashboard.

login to your WordPress Dashboard

Okay, guys, that’s it for today’s tutorial.

In the next tutorial, we are going to learn the step-by-step installation of phpMyAdmin. So stay tuned and if you have any questions and problems related to WordPress installation, Ask me on the comment box or mail me [email protected].

Checkout Other Article About WordPress:

  1. How to Install WordPress Ready to use containers?
  2. How to Get Free Cloud Hosting for 12 months?
  3. Get Namecheap Huge Discount up to 86% Off.

Leave a Comment

Join Our Facebook VIP Group

Share via
Copy link