Installing WordPress on Debian 🌱

  1. Log into the Debian device
  2. Run the following commands in a terminal:
    # update repositories and install any available software updates
    sudo apt update
    sudo apt upgrade -y
    # install Apache HTTPD and MySQL
    sudo apt-get install apache2 mariadb-server mariadb-client curl
    # install PHP components
    sudo apt install php php-mysql php-curl php-gd php-mbstring php-xml php-xmlrpc php-soap php-intl php-zip
    # configure the MySQL database
    sudo su
  3. Press Enter to login as root
  4. Type Y and press Enter to set a root password, type the password twice to confirm
  5. Type Y and press Enter to remove anonymous users
  6. Type Y and press Enter to disallow root login remotely
  7. Type Y and press Enter to remove the test database
  8. Type Y and press Enter to reload privilege tables
  9. Run the following command to login into MySQL:
    mysql -u root -p
  10. Authenticate with the root password set earlier
  11. Run the following commands to create the WordPress database and database user
    CREATE DATABASE wordpress DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
    GRANT ALL ON wordpress.* TO 'wordpress_user'@'localhost' IDENTIFIED BY 'W0rdPr3ss!!';
  12. Continue with the following commands to download and extract WordPress in the Apache webroot
    # download latest wordpress version
    sudo wget
    # extract latest.tar.gz
    sudo mkdir /var/www/wordpress
    sudo tar xzvf latest.tar.gz --directory /var/www
    # create a new wordpress.conf file to configure the site
    sudo nano /etc/apache2/sites-available/wordpress.conf
  13. Paste the following configuration into wordpress.conf

    Alias /wordpress "/var/www/wordpress/"
    <Directory /var/www/wordpress/>
        AllowOverride All

  14. Press CTRL+O, Enter, CTRL+X to write the changes to wordpress.conf
  15. Continue with the following commands to enable the site and restart Apache:
    # enable the Wordpress site and required PHP modules
    sudo a2ensite wordpress
    sudo a2enmod rewrite
    # create a .htaccess file
    sudo touch /var/www/wordpress/.htaccess
    # copy the sample wordpress config
    sudo cp /var/www/wordpress/wp-config-sample.php /var/www/wordpress/wp-config.php
    # create an upgrade directory
    sudo mkdir /var/www/wordpress/wp-content/upgrade
    # set the owner of the new wordpress directory to www-data
    sudo chown -R www-data:www-data /var/www/wordpress
    # change additional permissions
    sudo find /var/www/wordpress/ -type d -exec chmod 750 {} \;
    sudo find /var/www/wordpress/ -type f -exec chmod 640 {} \;
    # generate secure secret keys, copy the output for use shortly
    curl -s
    # edit wp-config.conf
    sudo nano /var/www/wordpress/wp-config.php
  16. Press CTRL+W and search for define('AUTH_KEY'
  17. Paste the secure secret keys generated earlier, overwriting the template
  18. Press CTRL+W and search for define('DB_NAME'
  19. Update the database name, username and password
  20. Press CTRL+W and search for define('FS_METHOD'
  21. Set the value to 'direct'
  22. Press CTRL+O, Enter, CTRL+X to write the changes to wp-config.conf
  23. Continue the setup by running the following commands in terminal
    # restart apache2 service
    sudo systemctl restart apache2
  24. Open a web browser and navigate to http://DNSorIP/wordpress
  25. The Wordpress setup screen should be displayed
  26. Select a language > Click Continue
  27. Create a site title and WordPress login > Click Install WordPress
  28. When the installation completes, login with the WordPress credentials created in the previous step
  29. Welcome to your very own, self-hosted WordPress installation