• Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate
TecNStuff
Menu
  • Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate

How to Install WordPress with Apache on Debian 10

Written by Admin, Updated On August 27, 2019
apache, cms, debian, mariadb, mysql, wordpress
How to Install WordPress with Apache on Debian

WordPress is the most popular and widely used blogging and content management system in the world. PHP processing and MySQL/MariaDB database are used as a backend in WordPress. It is simplest way to create a Blog, Portfolio Website, webshop etc. In this tutorial, we will show you how to install WordPress with Apache on Debian 10 Buster.

Prerequisites#

We are going to use LAMP (Linux, Apache, MariaDB, and PHP) stack with Apache as web server. Make sure that you met the following prerequisites before start installation process:

  • Debian 10 server with a non-root user with sudo privileges.
  • Apache must installed and configured, as shown in this tutorial.
  • Your domain name should pointing to your server IP address.
  • An SSL certificate installed for your domain. You can install a free Let’s Encrypt SSL certificate as shown in this tutorial.

Create MariaDB database and Grant Permissions#

As we discussed previously WordPress is using MySQL-based database to store the data. So first of all we need to create a MariaDB database, MariaDB user and grant permission. If you system don’t have installed MariaDB, you can follow How to Install MariaDB on Debian 10 tutorial.

At first, log in to MariaDB shell using below command:

 mariadb -u root -p

It will prompt you to enter password for the root user. You will be logged in on entering correct password.

Type the below command to create a new MariaDB database for your WordPress:

CREATE DATABASE wordpress DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;

Now you have to create a new MariaDB user by issuing below command:

GRANT ALL ON wordpress.* TO 'wordpressuser'@'localhost' IDENTIFIED BY 'enter-strong-password';

Need to flush the database so changes can reflact in MySQL, type:

FLUSH PRIVILEGES;

Finally, exist from MySQL shell by typing:

EXIT;

Install PHP on Debian 10#

PHP 7.3 is the latest and default PHP version in Debian 10 system. You can also check the latest version for installation on PHP official website.

First of all you need to update the apt package manager index and upgrade the packages:

sudo apt update && sudo apt upgrade

Next, to install PHP and all the required modules run below command in the terminal:

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

Note: PHP packages set requirements depends on WordPress plugin. Some may require additional PHP packages to be installed. Check your plugin documentation to discover its PHP requirements.

You can verify the installation by typing below command:

php -v

You should restart the Apache service to load these new extensions in the next section by issuing below command:

sudo systemctl restart apache2

Downloading and Setup WordPress#

First, navigate to /tmp directory using below command:

cd /tmp

Now download the latest WordPress setup from the WordPress download page using using below wget command:

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

Once the download is completed, extract the downloaded files using below command:

tar xzvf latest.tar.gz

After that, create the configuration file for WordPress using below command:

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

Then copy all the files to example.com directory using below command:

sudo cp -a /tmp/wordpress/. /var/www/example.com

You need to set the correct permissions so web server can the site’s files and directories. To change the ownership of example.com directory use following chown command:

sudo chown -R www-data:www-data /var/www/example.com

Configure Apache#

You should have installed Apache with SSL certificate installed on your Debian machine. We will create a new virtual host for our WordPress instance.

Open your text editor and create the following file:

sudo nano /etc/apache2/sites-available/example.com.conf
<VirtualHost *:80>
  ServerName example.com
  ServerAlias www.example.com

  Redirect permanent / https://example.com/
</VirtualHost>

<VirtualHost *:443>
  ServerName example.com
  ServerAlias www.example.com

  Protocols h2 http:/1.1

  <If "%{HTTP_HOST} == 'www.example.com'">
    Redirect permanent / https://example.com/
  </If>

  DirectoryIndex index.html index.php
  DocumentRoot /var/www/example.com

  ErrorLog ${APACHE_LOG_DIR}/example.com-error.log
  CustomLog ${APACHE_LOG_DIR}/example.com-access.log combined

  SSLEngine On
  SSLCertificateFile /etc/letsencrypt/live/example.com/cert.pem
  SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
  SSLCertificateChainFile /etc/letsencrypt/live/example.com/chain.pem

  <Directory /var/www/example.com>
      Options FollowSymLinks
      AllowOverride All
      Require all granted
  </Directory>

</VirtualHost>

Note : You should replace your real domain name with example.com and set correct SSL certificates path.

Next, you should Enable the virtual host by creating a symbolic link to the sites-enabled directory:

sudo a2ensite example.com

After that restart the Apache service by below command:

sudo systemctl restart apache2

Complete the WordPress Installation#

Now WordPress is configuration is complete and we can finish remaining installation through web interface.

To do it open your browser and type your domain name and it should show page as following:

wordpress-language-selector

Select language which you would like to set and click on continue button to go ahead.

After that it will show below page you just have to click on Let’s Go! button to continue.

wordpress-install-information

On next page it will ask you to enter database connection details. Enter MySQL database and user details which you created previously.

wordpress-database-information

Next hit on the Run the installation button to start installation process.

wordpress-run-installation

On next screen, You should enter name of WordPress site and set username and password for your site. Also, enter your email address and select whether you want to discourage search engines from indexing the site (It’s not recommended).

wordpress-install-welcome

Finally, click on the Install WordPress button and once the installation is finished you will see the below screen:

wordress-install-completed

Hit on Login button you will be redirected to WordPress login page. Now use the username and password which you set in previous step.

wordpress-login

After successful login you will be redirected to the WordPress administration dashboard as following:

wordpress-dashboard

That’s it. You did and now you can customize your WordPress installation by installing new themes and plugins.

Conclusion#

You have successfully installed WordPress with Apache on your Debian 10.

If you have questions feel free to leave a comment below.

If our content helps you, please consider buying us a coffee

Thank you for your support.

Share On
Share on Facebook
Share on Twitter
Share on Reddit
Share on Tumblr
 Previous Article How to Install WordPress with Nginx on Ubuntu 18.04
Next Article   How to Install Composer on Debian 10

Related Posts

  • How to Change Hostname Debian 11

    How to Change Hostname on Debian 11

    February 3, 2023
  • How to Install Python 3.11 on Debian 11

    How to Install Python on Debian 11

    January 25, 2023
  • How to Install Mongodb on Debian 11

    How to Install MongoDB on Debian 11 Linux

    January 11, 2023

7 Comments

  1. spence Reply
    February 3, 2020 at 2:14 pm

    The url domain redirect to our first document we have created (“Success! xxx set up completed!”), with your other tutorial…
    I think it’s the index files ’cause pb….

  2. spence Reply
    February 4, 2020 at 7:02 pm

    Or, it’s a pb with virtualhost…
    I don’t find help on this pb, i’m stuck.

    I delete all the /var/www/sub.domain.ex
    I cp again all wordpress to this path, but, not work…

    • Admin Reply
      February 16, 2020 at 10:34 am

      Can you please elaborate more what you are trying to do and what is exact issue? What do you mean by pb?

      • Spence Reply
        February 17, 2020 at 3:18 am

        I want use wordpress for a project (I need render it tomorrow, monday 17th).
        I heard debian is the most light system for that, so I choose it.
        And your work add ssl with it.

        I follow ALL your linked tutorials, and when I arriving to the wordpress installation, when I go to my the url, there is nothing, worpress installation not lunch.
        When I go my.domain.fr, I have “Success! xxx set up completed!” (you ask for created it for certbot with virtualhost).
        It’s the index.html in public_html.
        So i use rm to destroy this file, and rm -r for the folder “public_html”.
        But, now, i have an error 404…

        And to add some missing :
        I must install :
        php (for use “php -v”)
        ufw
        wget
        sudo

        I think all configuration is good, but not the setting of the wordpress installation.
        Or maybe for the mariadb database settings :
        you put :
        GRANT ALL ON wordpress.* TO ‘wordpress’@’localhost’ IDENTIFIED BY ‘(chossen password)’;
        But we never creat “wordpress” user for example.
        I try with adding the same lane with my ID too, but no change…

  3. spence Reply
    February 17, 2020 at 2:02 pm

    Ok, i find :
    When we creat the ssl let’s encrypt system, we use “public_html”.
    The /etc/apache2/sites-available/your-site-name.dom.le-ssl.conf contains the documentroot of public_html…

    Now, I have a begin of advancement.
    But, I have :
    “Your PHP installation appears to be missing the MySQL extension which is required by WordPress.”
    I’m going find a solution

    • spence Reply
      February 17, 2020 at 2:15 pm

      The problem was php was not install with correct system :
      $ sudo apt install php7.3-mysql

      Reboot.

      Now, new pb :
      “Error establishing a database connection”
      I investigate, but maybe pre-set the config?

  4. spence Reply
    February 17, 2020 at 2:31 pm

    WordPress Lunching…

    So I need to modify :
    $ sudo nano /var/www/my.site.dom/wp-config.php

    For example : (fasle information)

    My database name is : mydatabase
    My database user is : cocoricot
    My password is : warISover

    And manually modify values :

    define( ‘DB_NAME’, ‘mydatabase’ );

    /** MySQL database username */
    define( ‘DB_USER’, ‘cocoricot’ );

    /** MySQL database password */ define( ‘DB_PASSWORD’, ‘warISover’ );

Leave a Reply Cancel reply

DigitalOcean Referral Badge

Popular Posts

  • How to Install SSH Keys on Ubuntu 22.04
    How to Set up SSH Keys on Ubuntu 22.04 January 7, 2023
  • How to Install Mongodb on Debian 11
    How to Install MongoDB on Debian 11 Linux January 11, 2023
  • How to Install Puppet Agent on Ubuntu 22.04
    How to Install Puppet Agent on Ubuntu 22.04 January 22, 2023
  • How to Install Jenkins on Debian 11
    How to Install Jenkins on Debian 11 January 5, 2023
  • How to Change-Hostname Ubuntu 22.04
    How to Change Hostname on Ubuntu 22.04 January 19, 2023
© 2020 TecNStuff All rights reserved. This website is using and storing cookies on your browser. By using this website you agree our Privacy Policy.  Follow us -  Twitter | Facebook