How to Install WordPress Alongside LAMP on Debian 10

First released in 2003, WordPress has grown to become one of the leading CMS systems in the internet, accounting for over 30% of the market share. WordPress is a free and opensource CMS that is written using PHP and uses MySQL as its database.

In this tutorial, you will learn how to install WordPress on Debian 10 Buster.


Before we begin, perform a flight check and ensure that you have the following installed.

  1. Install LAMP on Debian 10 Server.
  2. A regular user with sudo privileges.

Step 1: Creating a Database for WordPress

To start off, we shall begin by creating a MySQL database for WordPress, which comes with numerous files which require a database to accommodate them.

$ sudo mysql -u root -p

This prompts you to type the root Password that you specified when securing the MySQL database server during installation. Type the correct password and press ENTER to access the MySQL shell.

Next, we are going to create a database called wordpress_db. Feel free to play around with any name. To create the database run:

mysql> CREATE DATABASE wordpress_db;

Next, create a database user and grant him all the permissions to the database as follows.

mysql> GRANT ALL ON wordpress_db.* TO 'wordpress_user'@'localhost' IDENTIFIED BY 'password';

Remember to replace the ‘password‘ string with your own strong password. To save the changes, issue the command.


Finally, exit MySQL by executing the command.

mysql> EXIT;

A summary of the command is as shown.

Create WordPress Database on Debian
Create WordPress Database on Debian

Step 2: Installing Additional PHP Extensions

WordPress requires a pack of additional plugins to function without any problems. With that in mind, proceed and install the extra PHP extensions as shown.

$ sudo apt update
$ sudo apt install php php-mysql php-curl php-gd php-mbstring php-xml php-xmlrpc php-soap php-intl php-zip
Install PHP Extensions for WordPress
Install PHP Extensions for WordPress

To effect the changes, restart the Apache web server as shown below.

$ sudo systemctl restart apache2

Step 3: Install WordPress on Debian 10

With the database fully configured, we are now going to download and install the WordPress on the Apache web root directory.

$ sudo cd /var/www/html/

Using curl command, proceed and download the WordPress tarball file.

$ sudo curl -O
Download WordPress on Debian
Download WordPress on Debian

Next, proceed and extract the WordPress tarball file as shown.

$ sudo tar -xvf latest.tar.gz

This will yield a folder labelled wordpress. This folder contains all the WordPress configuration files. Once extracted, it is safe to delete the WordPress tarball file.

$ sudo rm latest.tar.gz

Step 4: Configure WordPress on Debian 10

In this step, we are going to modify the WordPress folder in the web root folder. But before we do so, we need to modify file ownership and permissions. We are going to assign file ownership to all the files in the wordpress directory using the command.

$ sudo chown -R www-data:www-data /var/www/html/wordpress

Next, assign the correct permissions as shown in the commands below.

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

Additionally, you also need to rename the sample configuration file in wordpress directory to a filename it can read from.

$ cd wordpress
$ sudo mv wp-config-sample.php wp-config.php

Next, using your favorite text editor, open the wp-config.php file. In this case, I will use the vim text editor.

$ sudo vim wp-config.php

Scroll down and locate the MySQL settings section and be sure to fill with the corresponding database details a specified when creating the WordPress database as shown below.

Set MySQL Settings for WordPress
Set MySQL Settings for WordPress

Save and exit the configuration file.

Step 5: Securing WordPress Installation on Debian 10

Moreover, we need to generate security keys to provide additional security to our WordPress installation. WordPress provides an automatic generator for these keys to eliminate the need of generating them by ourselves.

To generate these values from WordPress secret generator, run the command.

$ sudo curl -s

The command generates output as shown. Note that in your case, this code will be different.

define('AUTH_KEY',         'fmY^b9+HF@oF;R|+=F P:+NZx@k{+,;dA3lOa>8x{nU29TWw5bP12-q><`/');
define('SECURE_AUTH_KEY',  'j5vk0)3K[G$%uXFv5-03/?E~[X01zeS3CR(nCs5|ocD_?DAURG?pWxn,w<04:J)p'); define('LOGGED_IN_KEY', 'KQZQd|T9d9~#/]7b(k^F|4/N2QR!hUkR[mg?ll^F4~l:FOBhiN_t)3nktX/J+{s['); define('NONCE_KEY', 'Pg8V&/}?D@OiTW_RZ><W3c6JFvad|0>R.i$42]-Wj-HH_?^[1t0@ZK?8U5<ec:q%'); define('AUTH_SALT', '*i>O[(Dc*8Pzi%E=,`kN$b>%?UTJR==YmGN4VUx7Ys:$tb<PiScNy{#@x0h*HZ[|'); define('SECURE_AUTH_SALT', '}=5l/6$d [s-NNXgjiQ*u!2Y7z+^Q^cHAW*_Z+}8SBWE$wcaZ+; 9a>W7w!^NN}d');
define('LOGGED_IN_SALT',   '%:brh7H5#od-^E5#?^[b<=lY#>I9-Tg-C45FdepyZ-UpJ-]yjMa{R(E`=2_:U+yP');
define('NONCE_SALT',       '-ZVuC_W[;ML;vUW-B-7i}sw@f~+JUW|o]-&k+D &+-@btd1n+ddGjr:~C_E^!od[');

Copy the output that you have generated.

Once again, open the WordPress configuration file wp-config.php.

$ sudo vim wp-config.php 

Scroll and locate the section that contains the dummy values as shown below.

Default WordPress Values
Default WordPress Values

Delete those values and paste the values that you generated earlier on.

WordPress Secret Keys
WordPress Secret Keys

Save and exit the configuration file.

Step 6: Configure Apache for WordPress

Next, a few adjustments need to be made to the default Apache configuration file 000-default.conf located in the /etc/apache2/sites-available path.

Again, using your favorite text editor, open the default configuration file.

$ sudo vim  /etc/apache2/sites-available/000-default.conf 

Next, locate the DocumentRoot attribute and modify it from /var/www/html to /var/www/html/wordpress.

Still in the same file, copy and paste the following lines inside the Virtual Host block.

<Directory /var/www/html/wordpress/>
AllowOverride All
Configure Apache for WordPress
Configure Apache for WordPress

Save and exit the configuration file.

Next, enable the mod_rewrite so that we can use WordPress Permalink feature.

$ sudo a2enmod rewrite
Enable Mod_Rewrite in Apache
Enable Mod_Rewrite in Apache

To verify that all went well, issue the command.

$ sudo apache2ctl configtest
Verify Apache Configuration
Verify Apache Configuration

To implement the changes, restart Apache web server.

$ sudo systemctl restart apache2

Step 7: Run WordPress Installation Setup

At this point we are done with all the server configurations needed for WordPress installation. The final step is to complete the installation via a web browser.
To do this, launch your web browser and browser your server’s IP address or domain name

Select WordPress Language
Select WordPress Language

On the first page you will be required to select your preferred language. Click on your preferred Language and click on the ‘Continue‘ button.

In the next page, fill in the additional information required such as Site name, Username, Password, and Email address.

Add WordPress Site Details
Add WordPress Site Details

Once you have filled all the required fields, click on the ‘Install WordPress‘ button on the bottom left corner.

Install WordPress on Debian
Install WordPress on Debian

If all went well, you will get a ‘Success‘ confirmation.

WordPress Installation Success
WordPress Installation Success

Now, to log in to your WordPress CMS, click on the ‘Log In‘ button.

WordPress User Login
WordPress User Login

This will autofill the details you specified earlier. To access the dashboard, click on the ‘Log in‘ button

WordPress Dashboard
WordPress Dashboard

Congratulations! At this point you have successfully installed WordPress on Debian 10 buster Linux system. We have finally come to the end of this tutorial. We hope it was beneficial to you. Give it a shot and share your feedback. Thanks.

James Kiarie
This is James, a certified Linux administrator and a tech enthusiast who loves keeping in touch with emerging trends in the tech world. When I'm not running commands on the terminal, I'm taking listening to some cool music. taking a casual stroll or watching a nice movie.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.


Leave a Reply
  1. I have a small problem.

    After I punched in a2ensite 000-default.conf, I was able to access my Website with my local IP address but it opens right on the IP, it doesn’t redirect me to /wordpress, so I can’t access admin pages nor I see myself logged in. Also, other pages are 404.

    But if I type in a2dissite 000-default.conf and go directly to in my browser, it works fine. But it doesn’t redirect me from plain address It just shows the FTP index of the /html folder.

    • Okay. I’ve managed to make it work with a2ensite 000-default.conf, but still when I go to, I get to index of page /var/www/html/ folder where as my site is in /var/www/html/wordpress.

      I need to type the full address manually to get it to work –

      How do I fix this? Do I make it redirect somehow from to

  2. Great article! The best one is available!

    Two things appear to be missing:
    – in apache2 configuration file, under Directory directive: Require all granted.
    – enable new site with a2ensite.

    Thanks! Keep up the good work.

  3. These instructions are great, thank you, but one slight issue for me is they install WordPress onto, because the is a zipped up folder, which is annoying. Ideally, I’d like the WordPress site to be in the root, as the site homepage. What’s the easiest way to do this, leave out the WordPress folder and just have the site directly in the public HTML folder?

    • One other thing, using MySQL Monitor I had to create a user before I could grant all privileges, I’m pretty dumb so that stumped me for a good hour :D Here’s the command:

      CREATE USER IF NOT EXISTS 'put_a_username_here'@'localhost' IDENTIFIED BY 'your password here';
      GRANT ALL ON database_name.* TO 'put_the_same_username_here'@'localhost';

      The ‘if not exists probably’ isn’t necessary but if you have tried it a few times it might avoid confusion.

  4. omg thank you so much, after 3 types of installations and like 10 hours of trying and ending in nothing… you did it for me thanks a lot

  5. Typo on line:

    GRANT ALL ON wordpress.* TO 'wordpress_user'@'localhost' IDENTIFIED BY 'password';
    should be
    GRANT ALL ON wordpress_db.* TO 'wordpress_user'@'localhost' IDENTIFIED BY 'password';


Got Something to Say? Join the Discussion...

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.