How to Install WordPress on Debian 10

Updating the system

We first update the system to make sure that all our installed packages are upto date. Your Debian system can be updated easily with the following command.

 apt update

apt upgrade

Installing Nginx

We will start by installing the Nginx web server. To complete the installation, use the following command.

apt-get install nginx

Once the installation is complete, enable Nginx (to start automatically upon system boot), start the web server and verify the status using the commands below.

systemctl start nginx

systemctl enable nginx

systemctl status nginx

Output:

root@vps:~# systemctl status nginx
● nginx.service - A high performance web server and a reverse proxy server
   Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: en
   Active: active (running) since Fri 2021-06-04 09:58:47 EDT; 30s ago
     Docs: man:nginx(8)
 Main PID: 27179 (nginx)
    Tasks: 3 (limit: 2359)
   Memory: 8.2M
   CGroup: /system.slice/nginx.service
           ├─27179 nginx: master process /usr/sbin/nginx -g daemon on; master_pr
           ├─27180 nginx: worker process
           └─27181 nginx: worker process

Installing PHP and MariaDB Server

Install PHP, PHP-FPM, and MariaDB packages by running the following command.

apt-get install php php-mysql php-fpm php-curl php-gd php-intl php-mbstring php-soap php-xml php-xmlrpc php-zip mariadb-server mariadb-client

Once the installation is complete, enable MariaDB (to start automatically upon system boot), start the mariaDB and verify the status using the commands below.

systemctl start mariadb

systemctl enable mariadb

systemctl status mariadb

Output:

root@vps:~# systemctl status mariadb
● mariadb.service - MariaDB 10.3.27 database server
   Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset:
   Active: active (running) since Fri 2021-06-04 10:00:25 EDT; 8s ago
     Docs: man:mysqld(8)
           https://mariadb.com/kb/en/library/systemd/
 Main PID: 5291 (mysqld)
   Status: "Taking your SQL requests now..."
    Tasks: 31 (limit: 2359)
   Memory: 69.8M
   CGroup: /system.slice/mariadb.service
           └─5291 /usr/sbin/mysqld

Enable PHP-FPM service, start the PHP-FPM service and verify the status using the commands below.

systemctl start php7.3-fpm

systemctl enable php7.3-fpm

systemctl status php7.3-fpm

Output:

root@vps:~# systemctl status php7.3-fpm
● php7.3-fpm.service - The PHP 7.3 FastCGI Process Manager
   Loaded: loaded (/lib/systemd/system/php7.3-fpm.service; enabled; vendor prese
   Active: active (running) since Fri 2021-06-04 10:00:28 EDT; 42min ago
     Docs: man:php-fpm7.3(8)
 Main PID: 6676 (php-fpm7.3)
   Status: "Processes active: 0, idle: 2, Requests: 0, slow: 0, Traffic: 0req/se
    Tasks: 3 (limit: 2359)
   Memory: 17.0M
   CGroup: /system.slice/php7.3-fpm.service
           ├─6676 php-fpm: master process (/etc/php/7.3/fpm/php-fpm.conf)
           ├─6677 php-fpm: pool www

Finally, you will want to secure your MariaDB installation by issuing the following command.

mysql_secure_installation

Output:

root@vps:~# mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
 ... Success!

Creating Database

Log into MySQL with the following command.

mysql

First, we'll create a new database.

MariaDB [(none)]> CREATE DATABASE wordpress_db;

Next, create a new MySQL user account that we will use to operate on WordPress's new database, with username "wordpress_user".

MariaDB [(none)]> CREATE USER 'wordpress_user'@'localhost' IDENTIFIED BY 'password';

Link the user and DB together by granting our user access to the database.

MariaDB [(none)]> GRANT ALL PRIVILEGES ON wordpress_db.* to wordpress_user@'localhost';

Flush the privileges so that MySQL knows about the user permissions we just added.

MariaDB [(none)]> FLUSH PRIVILEGES;

Exit out of the MySQL command prompt by typing.

MariaDB [(none)]> exit   

Output:

root@vps:~# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 67
Server version: 10.3.27-MariaDB-0+deb10u1 Debian 10

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> CREATE DATABASE wordpress_db;
Query OK, 1 row affected (0.003 sec)

MariaDB [(none)]> CREATE USER 'wordpress_user'@'localhost' IDENTIFIED BY 'password';
Query OK, 0 rows affected (0.005 sec)

MariaDB [(none)]> GRANT ALL PRIVILEGES ON wordpress_db.* to wordpress_user@'localhost';
Query OK, 0 rows affected (0.003 sec)

MariaDB [(none)]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.003 sec)

MariaDB [(none)]> exit
Bye

Download and Install WordPress

Download Wordpress.

wget -O /tmp/wordpress.tar.gz https://wordpress.org/latest.tar.gz

Unzip the downloaded WordPress file.

tar -xzvf /tmp/wordpress.tar.gz -C /var/www/html

Change the permission of the site directory and revert changes after installing WordPress.

chown -R www-data.www-data /var/www/html/wordpress

chmod -R 755 /var/www/html/wordpress

Creating an NGINX Virtual Host

Ceate a Virtual Host for WordPress website on the Nginx server by running the following command.

nano /etc/nginx/conf.d/wordpress.conf

Add the content to file.

server {
        listen 80;
        listen [::]:80;
        root /var/www/html/wordpress;
        index index.php index.html index.htm;
        error_log /var/log/nginx/wordpress_error.log;
        access_log /var/log/nginx/wordpres_access.log;
        client_max_body_size 100M;
        location / {
                try_files $uri $uri/ /index.php?$args;
        }
        location ~ \.php$ {
                include snippets/fastcgi-php.conf;
                fastcgi_pass unix:/run/php/php7.3-fpm.sock;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        }
}

Remove the default server block to enable your WordPress website.

rm /etc/nginx/sites-enabled/default

rm /etc/nginx/sites-available/default

Next, test to make sure that there are no syntax errors in any of your Nginx files.

nginx -t

If there aren’t any problems, restart Nginx to enable your changes.

systemctl reload nginx

Navigate to your browser.

http://IP_ADDRESS

images

Provide the requested information.

images

Start a WordPress installation by clicking on the Run the installation button.

images

Once the Wordpress is installed login with your new user credentials.

images

images

Done!!


CrownCloud - Get a SSD powered KVM VPS at $4.5/month!
Use the code WELCOME for 10% off!

1 GB RAM / 25 GB SSD / 1 CPU Core / 1 TB Bandwidth per month

Available Locations: LAX | MIA | ATL | FRA | AMS