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

output:

root@vps:~# 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';

output:

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;

output:

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`;

output:

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

Flush your privileges and exit.

FLUSH PRIVILEGES;
exit;

output:

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

Download And Unpack WordPress

You can either head over to the https://wordpress.org and download it that way, or just use wget.

cd Downloads
wget https://wordpress.org/latest.tar.gz

output:

root@vps:~/Downloads# wget https://wordpress.org/latest.tar.gz
--2019-01-10 11:08:46--  https://wordpress.org/latest.tar.gz
Resolving wordpress.org (wordpress.org)... 198.143.164.252
Connecting to wordpress.org (wordpress.org)|198.143.164.252|:443... connected.

Unpack WordPress using tar.

tar xpf latest.tar.gz

output:

root@vps:~/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

output:

root@vps:~# rm -rf /var/www/html

root@vps:~/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 {} \;

output:

root@vps:~# chown -R www-data:www-data /var/www/html
drwxr-xr-x  5 www-data www-data 4096 Jan 10 11:17 html

root@vps:/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

root@vps:/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