How to Install WordPress On Debian 9 Stretch Linux
Nick Congleton Debian 30 June 2017 Contents
- 1. Objective
- 2. Distributions
- 3. Requirements
- 4. Difficulty
- 5. Conventions
- 6. Introduction
- 7. Set Up A LAMP Or LEMP Stack
- 8. Create Your Database
- 9. Download And Unpack WordPress
- 10. WordPress Setup
- 11. Closing Thoughts
Objective
Install WordPress on Debian 9 Stretch
Distributions
Debian 9 Stretch
Requirements
A working install of Debian Stretch with root privileges
Difficulty
Easy
Conventions
- # – requires given command to be executed with root
privileges either directly as a root user or by use of
sudo
command - $ – given command to be executed as a regular non-privileged user
Introduction
WordPress is easily the most popular content management system available. It’s probably also the most popular platform on the web altogether. Whether you’re hosting a small blog of a large online publication, WordPress is an excellent option. Since Debian is ultra-stable and has massive package repositories, it’s a great distribution to host WordPress on. You can get WordPress running on Debian Stretch very easily, and get your website started fast.
Set Up A LAMP Or LEMP Stack
Before you can install WordPress, you’re going to need to set up your server to serve PHP web applications. You can either follow our LAMP Guide or our LEMP Guide to get set up.
Create Your Database
Once your server is ready, 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
Once you’re signed in, create a regular user for WordPress.
MariaDB [(none)]> CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'userpassword';
Now, create your WordPress database.
MariaDB [(none)]> CREATE DATABASE wp_database;
Finally, grand your user all permissions on the database.
MariaDB [(none)]> GRANT ALL ON `wp_database`.* TO `wpuser`@`localhost`;
Flush your privileges and exit.
MariaDB [(none)]> FLUSH PRIVILEGES; MariaDB [(none)]> exit;
Download And Unpack WordPress
Here’s where WordPress makes its entrance. You can either head
over to the https://wordpress.org
and download it
that way, or just use wget
. The URL never changes,
so wget
will always work.
$ cd Downloads $ wget https://wordpress.org/latest.tar.gz
Unpack WordPress using tar
.
$ 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.
The example provided covers the most basic possible install on
Apache.
# rm -rf /var/www/html # cp -r wordpress /var/www/html
If you’re using Nginx, you probably just want to place the folder
in /var/www/
as it is, and point your configuration
at it. When WordPress is where you want it, 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 {} \;
Certainly, if your webserver is configured to run under a different user, change the ownership to that one.
WordPress Setup

WordPress’s web-based installer handles the rest of the process.
So, open up a web browser and navigate to the domain name or IP
address of your server.

The first screen that you’ll see will just greet you. When you
click through to the next screen, WordPress will prompt you for
your database information. Enter everything that you set up.

The final screen will ask you for information about your site. Enter everything as it pertains to the website that you’re setting up. After that screen, the WordPress installer will run and set up everything. When it finishes, it will present you with the WordPress login screen. You can then log in and gain access to your admin interface.
Closing Thoughts
Congratulations! You have a working WordPress installation on Debian Stretch. If you’re running this server in production, make sure that you properly secure it, and that includes WordPress itself.