Install WordPress on Debian Buster

WordPress is an open-source content management system (CMS), which was first released on May 27, 2003. The CMS is used to create as well as publish web pages and it is based on PHP/MySQL. The ease of use has given it the highest market share among its peers. Even those who don’t have prior programming experience can manage their websites with ease. In this article, we would discuss how to install WordPress on Debian Buster through command-line interface.

Install WordPress in Debian Buster

1. Firstly, you need to have superuser privileges. Run the following and provide the password.

su -l

2. Update the Debian’s standard repository to get the most updated version of packages.

apt update

3. Install the WordPress and other related packages.

apt install wordpress curl mariadb-server apache2 php-curl php-mbstring php-xml

4. Next, you will have to secure MySQL installation.

mysql_secure_installation

Then, provide password for root. If you want to change it then press Y in next step. Otherwise, it is best to leave as it is and Press N. For all the other options like anonymous users, disallow remote login, remove test database, and reload privilege tables, Press Y.

5. Now, we will create a configuration file – wp.conf in the directory /etc/apache2/sites-available/ to provide custom settings for our website. And, add the following entries. Also, You need to provide your domain name in place of localhost in ServerName and ServerAdmin. If you are planning to host your website locally for some reason then it is best to leave the entries as it is.

<VirtualHost *:80>
ServerName localhost

ServerAdmin localhost@localhost
DocumentRoot /usr/share/wordpress

Alias /wp-content /var/lib/wordpress/wp-content

<Directory /usr/share/wordpress>
           Options FollowSymLinks
           AllowOverride Limit Options FileInfo
           DirectoryIndex index.php
           Require all granted
</Directory>

<Directory /var/lib/wordpress/wp-content>
           Options FollowSymLinks
           Require all granted
</Directory>

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

</VirtualHost>

6. Run the following commands to disable default virtual host and enable your website.

a2dissite 000-default
a2ensite wp

7. We will now have to reload our web server.

systemctl reload apache2

8. Next, we will have to create a configuration file for WordPress database,

nano /etc/wordpress/config-<ServerName>.php

If in Step -5 your ServerName is localhost then,

nano /etc/wordpress/config-localhost.php

Otherwise, if your ServerName in Step-5 is example.com then,

nano /etc/wordpress/config-example.com.php

Add the following entries in the config-<ServerName>.php

<?php
define('DB_NAME', 'wp_database');
define('DB_USER', 'user');
define('DB_PASSWORD', 'password');
define('DB_HOST', 'localhost');
define('WP_CONTENT_DIR', '/var/lib/wordpress/wp-content');
?>

In the above code, you need to edit following entries as per your convenience – DB_NAME, DB_USER, DB_PASSWORD and DB_HOST.

9. For making themes and plugins editable by WordPress, there are two methods available to us –

9.(i). You need to provide ownership of themes and plugins to your web server user (i.e. www-data). So, run the following next –

chown -R www-data /var/lib/wordpress/wp-content

9.(ii). Once you have finished the installation process and still can’t update or edit themes and plugins, then you need to append the following entry in /etc/wordpress/config-<domain-name>.php file as mentioned in Step -8;

define( 'FS_METHOD', 'direct' );

10. We will also create a file that will have database related instructions –

nano ~/wp.sql

and add the following in the wp.sql file –

CREATE DATABASE wp_database;
GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER
ON wp_database.*
TO user@localhost
IDENTIFIED BY 'password';
FLUSH PRIVILEGES;

Update the above code with relevant data which you have already provided in Step – 8.

11. Lastly, we will create the database by running the following command –

cat ~/wp.sql | mysql --defaults-extra-file=/etc/mysql/debian.cnf

In addition to the above, if we want to enable permalink feature in WordPress, then run –

a2enmod rewrite

Once the installation process is completed, open your web browser and type your website’s address. For example, http://localhost/ it will take you to WordPress installation page, fill in the relevant details. The username and password that you will provide at this stage would be used to login to WordPress CMS.

Thereafter, always use http://localhost/wp-admin in your web browser to login to your WordPress CMS.

In conclusion, We have discussed how to install WordPress on Debian Buster. Web Content Management Systems like WordPress are easy to use and do not require the user to have programming background. But, it needs to be updated regularly to ward off any potential security threats. If you have installed WordPress through Debian’s standard repository then you need to update/upgrade your Debian installation for updating WordPress to latest available version.

Similar Posts