How to Install WordPress On Debian 9 Stretch Linux

Set up LAMP server

To install WordPress in your server, you'll need to setup your server to serve PHP web applications. Please follow our guide to set it up LAMP installation .

Create Your Database

you can set up the database where you're going to store everything from WordPress. Log in to MariaDB as your root user.

mysql -u root -p


[email protected]:~# mysql -u root -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 15

Once you're signed in, create a regular user for WordPress.

CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'password';


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

Now, create your WordPress database.

CREATE DATABASE wp_database;


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

Finally, grand your user all permissions on the database.

GRANT ALL ON `wp_database`.* TO `wpuser`@`localhost`;


MariaDB [(none)]> GRANT ALL ON `wp_database`.* TO `wpuser`@`localhost`;
Query OK, 0 rows affected (0.00 sec)

Flush your privileges and exit.



Query OK, 0 rows affected (0.00 sec)

Download And Unpack WordPress

You can either head over to the and download it that way, or just use wget.

cd Downloads


[email protected]:~/Downloads# wget
--2019-01-10 11:08:46--
Resolving (
Connecting to (||:443... connected.

Unpack WordPress using tar.

tar xpf latest.tar.gz


[email protected]:~/Downloads# tar xpf latest.tar.gz

The resulting folder will be wordpress. It contains the entire WordPress install. How and where you copy it is entirely up to you and depends on your web server configuration

rm -rf /var/www/html

cp -r wordpress /var/www/html


[email protected]:~# rm -rf /var/www/html

[email protected]:~/Downloads# cp -r wordpress /var/www/html

change the permissions and ownership to improve security and grant your webserver proper access.

chown -R www-data:www-data /var/www/html

find /var/www/html -type d -exec chmod 755 {} \;

find /var/www/html -type f -exec chmod 644 {} \;


[email protected]:~# chown -R www-data:www-data /var/www/html
drwxr-xr-x  5 www-data www-data 4096 Jan 10 11:17 html

[email protected]:/var/www# find /var/www/html -type d -exec chmod 755 {} \;
drwxr-xr-x  4 www-data www-data    52 Jan 10 11:17 wp-content
drwxr-xr-x 19 www-data www-data  8192 Jan 10 11:17 wp-includes

[email protected]:/var/www/html# find /var/www/html -type f -exec chmod 644 {} \;
-rw-r--r--  1 www-data www-data   418 Jan 10 11:17 index.php
-rw-r--r--  1 www-data www-data 19935 Jan 10 11:17 license.txt
-rw-r--r--  1 www-data www-data  7415 Jan 10 11:17 readme.html

Open up a web browser and navigate to the domain name or IP address of your server, http://IP_address And complete the installation process by setting up your preferred language and username and password.

This concludes the installation of WordPress on Debian 9

Last Modified: January 10 2019 20:09:04