How to Install WordPress on Debian 10

This guide on how to install WordPress on Debian 10 uses the LAMP (Linux, Apache, MariaDB, PHP) stack and is intended for VPS or dedicated servers without using any control panel.

Prerequisites for Installing WordPress on Debian 10

  • VPS or dedicated server with Debian 10 OS
  • 512MB RAM
  • 10GB Storage
  • Internet connection
  • VPS account with root access
  • Fresh server install (to reduce the possibility of conflicts with other applications)
  • Domain already pointed to the server IP via DNS

How to Install WordPress on Debian 10

1. SSH/Console Login

The first step you need to take is to log in to SSH using an application like PuTTY, CMD, or Console (Console is usually provided by your VPS service provider).

If you are using CMD or Terminal, you can use the following command

ssh username@IP_Address
  • Change the username with your SSH account username, for example Root
  • Change IP_Address with your server IP address, for example 127.0.0.1

2. Create a Database for WordPress

Next, you need to create a database for the WordPress you are going to install.

If you have not installed MariaDB, you can install it with this command

sudo apt install mariadb-server php-mysql

After MariaDB is installed, you can then create a database for WordPress by following these steps.

A. Open the MySQL console using this command

sudo mysql

If you performed a secure installation in MySQL, you can use this command

sudo mysql -u root -p

B. Create the database name you will use, for example here nasikindata

CREATE DATABASE nasikindata;

C. Grant permissions so the user can manage the database. Here the user is nasikinuser and the password is nasikinpass, for your database you can adjust it as you like

CREATE USER 'nasikinuser'@'localhost' IDENTIFIED BY 'nasikinpass';GRANT ALL PRIVILEGES ON nasikindata.* TO 'nasikinuser'@'localhost';FLUSH PRIVILEGES;

D. Exit the MySQL console with the quit command

quit;

3. Install PHP and Its Extensions

Before installing PHP extensions, you need to install Apache and PHP first, then set up the firewall. To install Apache, you can use this command

sudo apt install apache2

After Apache is installed, make sure you allow all www connections to your server with this command

sudo ufw allow in "WWW Full"

If the command ufw is not found, you need to install it first.

sudo apt install ufw

For your WordPress to run smoothly, you need to install PHP and the necessary extensions. If your plugins or themes require other extensions later, you can install them as well.

To install PHP, you can use this command

sudo apt install php libapache2-mod-php php-mysql

Then to add extensions, you can use this command

sudo apt install php-curl php-gd php-mbstring php-xml php-xmlrpc php-soap php-intl php-zip

Next, you need to change the PHP configuration with this command

sudo nano /etc/apache2/mods-enabled/dir.conf

Inside that configuration, change the contents to

<IfModule mod_dir.c>    DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm</IfModule>

After everything is added, restart Apache with this command

sudo systemctl restart apache2

4. Create a Virtual Host

So that it does not display the default Apache page when visited, you need to create a virtual host first. Here, for example, the virtual host name used is nasikin

sudo mkdir /var/www/nasikin

Next, create the configuration for the virtual host that will be used.

sudo nano /etc/apache2/sites-available/nasikin.conf

Add the following code inside the virtual host config file

<VirtualHost *:80>    ServerName nasikin.web.id    ServerAlias www.nasikin.web.id    ServerAdmin [email protected]    DocumentRoot /var/www/nasikin    ErrorLog ${APACHE_LOG_DIR}/error.log    CustomLog ${APACHE_LOG_DIR}/access.log combined</VirtualHost>

Next, you need to enable the virtual host you created and disable the default Apache page

sudo a2ensite nasikinsudo a2dissite 000-default

5. Allow Apache to Modify and Edit .htaccess

By default, Apache cannot yet modify the .htaccessfile, so here we need to grant permission to Apache to manage that file with this command (change nasikin according to the folder you will use)

sudo nano /etc/apache2/sites-available/nasikin.conf

Then on the edit or add file page, add the following code, then save by pressing the CTRL+X

<Directory /var/www/nasikin/>	AllowOverride All</Directory>

keys. Next, you need to allow Apache to perform rewrites with the command

sudo a2enmod rewrite

To check if there are no errors in your Apache, you can check with this command

sudo apache2ctl configtest

If successful, you will get output like this

OutputSyntax OK

Finished with the Apache configuration, now you need to restart Apache first

sudo systemctl restart apache2

6. Download WordPress

Because the database and PHP configuration are finished, you can now download the latest version of WordPress and extract it. To download the latest WordPress, you can use this command

cd /tmpcurl -O https://wordpress.org/latest.tar.gztar xzvf latest.tar.gz

Before moving the WordPress files to the installation folder, you need to create an .htaccess file first, which will be used by WordPress later.

touch /tmp/wordpress/.htaccess

Then you also need to add the wp-config.php file by copying the wp-config-sample.php file

cp /tmp/wordpress/wp-config-sample.php /tmp/wordpress/wp-config.php

Also make sure you create an upgrade folder so your WordPress can be upgraded without experiencing problems later.

mkdir /tmp/wordpress/wp-content/upgrade

If everything has been added, now you just need to move the files and folders inside the /tmp/ folder to your WordPress installation folder. Change nasikin with the folder you created in step number 5.

sudo cp -a /tmp/wordpress/. /var/www/nasikin

7. Change File Permissions for Files and Folders

So that WordPress can be accessed, you need to change the file permissions to 750 for folders and 640 for files. However, before that, you need to update the ownership using chown

sudo chown -R www-data:www-data /var/www/nasikin

After the ownership is updated, now you just need to change the permissions

sudo find /var/www/nasikin/ -type d -exec chmod 750 {} \;sudo find /var/www/nasikin/ -type f -exec chmod 640 {} \;

8. Configure wp-config.php

The last step before your WordPress can run is to update your wp-config.php file.

First, you need to add a Secret Key by creating one using the Secret Key Generator

curl -s https://api.wordpress.org/secret-key/1.1/salt/

A secret key will appear that you can use. Copy the secret key and save it in notepad or somewhere else. Example secret key:

define('AUTH_KEY',         'NgL g5K!X{JBg1(aoB+vs[(^]X<[%1,I4S]!9|L^45N56<:PC|&Nq~g66|V?#$]H');define('SECURE_AUTH_KEY',  '$(G6h!UYY:_e#-^G0Mb4vt_<>2sh15B6NL_YR78(/agtQsZms(u,}z|rZC^~24ed');define('LOGGED_IN_KEY',    'AzGgH&h|@Sn-]YB|VOxuZ-:|&*t)5niu7-~lH~lhiCgK]V?3bHh&zg|XF-By|QV*');define('NONCE_KEY',        '+mUy.9V,72FGQ/O)eD}|i!S[(RF#+$Miu?Eyk.V25_&C,Lo5;&V#|+M7x0-2RSs+');define('AUTH_SALT',        '+!Y0%+pqayDeMC5a0uBR|lEv`s}y sl*/aLQnb:1~RY0g+YQoc2M{*B:e$XM]fj0');define('SECURE_AUTH_SALT', '%P@@xg@#G^,p+ s%w>Gcp#Q7hv>=K6rSutPd>Q(CcU4*|tUWdbf)->[bvog[Sr7N');define('LOGGED_IN_SALT',   ':JfhUa+f6ZR]q^KZ}aV).Wg~iDl[kL|jL[w(wv/Mo!,c3[k] Lz-Ci]I&.2Yi:u ');define('NONCE_SALT',       'VCCkm8-5,|PC1d{u+QSd;SD;@%!~j$>j}^ P331c1<}_0%Kao7y6T$)jub,(O =x');

After getting the secret key, you now need to update wp-config.php

sudo nano /var/www/nasikin/wp-config.php

Inside the wp-config.php file, find the code below, then delete it and replace it with the secret key you obtained.

define( 'AUTH_KEY',         'put your unique phrase here' );define( 'SECURE_AUTH_KEY',  'put your unique phrase here' );define( 'LOGGED_IN_KEY',    'put your unique phrase here' );define( 'NONCE_KEY',        'put your unique phrase here' );define( 'AUTH_SALT',        'put your unique phrase here' );define( 'SECURE_AUTH_SALT', 'put your unique phrase here' );define( 'LOGGED_IN_SALT',   'put your unique phrase here' );define( 'NONCE_SALT',       'put your unique phrase here' );

Next, add the database you created earlier by changing the following code:

/** The name of the database for WordPress */define( 'DB_NAME', 'database_name_here' );
/** Database username */define( 'DB_USER', 'username_here' );
/** Database password */define( 'DB_PASSWORD', 'password_here' );

After it is changed, it will become

/** The name of the database for WordPress */define( 'DB_NAME', 'nasikindata' );
/** Database username */define( 'DB_USER', 'nasikinuser' );
/** Database password */define( 'DB_PASSWORD', 'nasikinpass' );

After finishing, save the file by pressing the CTRL+X

keys. 9. Customize Your WordPress

If all steps from number 1 to 8 are finished, you can then visit your website via the IP or the domain that has been pointed to that IP. For example http://127.0.0.1 and you will be able to start configuring and customizing your website.

Cara Install WordPress di Debian 10

Written by

Muhammad Khoirun Nasikin

I enjoy tinkering with WordPress, hosting, VPS, web development, and various small experiments related to websites. I have over 3 years of experience in the web hosting industry.

COMMENTS

Loading...