How To Set up WordPress on Debian 11

In this article, we want to teach you How To Set up or Install WordPress on Debian 11.

WordPress is a free, open-source website creation platform. It is a content management system (CMS) written in PHP that uses a MySQL database.

For more information about WordPress, you can follow the article Introduction to the WordPress System.

Steps To Set up WordPress on Debian 11

In this guide, you will learn to install WordPress on Debian 11 with LAMP stack.

To do this, you need some requirements.

Requirements

First, you need to log in to your server as a non-root user with sudo privileges and set up a basic firewall. To do this, you can follow our article the Initial Server Setup with Debian 11.

Then, you need to have the LAMP stack installed on your server. For this, you can check the article How To Install LAMP stack on Debian 11.

Also, you need to secure your site with SSL. To do this, you can visit our article How To Secure Apache with Let’s Encrypt on Debian 11.

When you are done with these requirements, follow the steps below to install WordPress on Debian 11.

Create WordPress Database on Debian 11

WordPress needs a database to store and manage site information. As you installed MariaDB from the LAMP installation, log in to your MariaDB console with the command below:

sudo mariadb

Then, you can create a WordPress database on Debian 11 by running the following command from your MariaDB console:

Here we named our database WordPress you can choose a different name.

CREATE DATABASE wordpress DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;

Now you can create a WordPress user with the command below, here we named it orca, just remember to replace the password with a strong password:

GRANT ALL ON wordpress.* TO 'orca'@'localhost' IDENTIFIED BY 'password';

Next, flush the privileges:

FLUSH PRIVILEGES;

Exit from your MariaDB console with the command below:

EXIT;

Install PHP extensions on Debian 11

At this point, you need to install some PHP exertions for your WordPress on Debian 11.

First, update your local package index with the following command:

sudo apt update

Then, install the PHP extensions with the following command:

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

Now you need to reload Apache to apply for the new extensions:

sudo systemctl restart apache2

Next, you need to make some configuration changes for Apache.

Configure Apache For WordPress on Debian 11

From the requirements, you should have a configuration file for your site in the /etc/apache2/sites-available/ directory.

Additionally, we will use /var/www/your-domain as the root directory of our WordPress install. You should use the webroot specified in your own configuration.

You need to open the Apache configuration file with your favorite text editor, here we use vi:

sudo vi /etc/apache2/sites-available/your-domain.conf

Add the following block inside the virtual host block in your configuration file:

Be sure to use the correct webroot directory.

<Directory /var/www/your-domain/>
AllowOverride All
</Directory>

When you are finished, save and close the file.

Now you need to enable the rewrite module with the following command:

sudo a2enmod rewrite

Make sure that you haven’t made any syntax errors:

sudo apache2ctl configtest

In your output you will see:

Output
Syntax OK

Then, restart Apache to apply the new changes:

sudo systemctl restart apache2

Install WordPress on Debian 11

At this point, once you have configured your server, you can download and install WordPress on Debian 11.

We will download WordPress from its official site in the latest version.

Download WordPress

First, switch to the /tmp directory:

cd /tmp

Then, use the curl command to download the WordPress on Debian 11:

curl -O https://wordpress.org/latest.tar.gz

Extract your downloaded file with the following command:

tar xzvf latest.tar.gz

Now you need to add a dummy “.htaccess” file, that will be available for WordPress to use later. To do this, run the following command:

touch /tmp/wordpress/.htaccess

Next, copy over the sample configuration file to the filename that WordPress actually reads:

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

Also, you need to create an “upgrade” directory for WordPress that doesn’t get into trouble with permissions issues when trying to do this on its own following an update to its software:

mkdir /tmp/wordpress/wp-content/upgrade

Here you should copy the entire contents of the directory into your document root with the following command:

sudo cp -a /tmp/wordpress/. /var/www/your-domain

Configure WordPress on Debian 11

At this point, that you have successfully installed WordPress onto your web server, you need to make some configuration changes in the WordPress directory.

First. update the ownership with the following command:

sudo chown -R www-data:www-data /var/www/your-domain

Then, you need to set the correct permissions on the WordPress directories and files on Debian 11:

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

Now you need to get secure values from the WordPress secret key generator with the following command:

curl -s https://api.wordpress.org/secret-key/1.1/salt/

In your output, you will get unique values similar to this:

Output
define('AUTH_KEY', 'uH:^{tLOd^.b5Y-|{VMi{gjzN|VEWt9l%O2[0ijcOr`:A|Q^RDZICw$|hBz_p+{E');
define('SECURE_AUTH_KEY', 'm!))-*!g(Vi9;_HqeA`u-H2lXqN(/$04&FSy+)bJ-bG@F,6Feme:/;z4U}N$Qgxs');
define('LOGGED_IN_KEY', '*,o+p/1wW{- |g%n|g@o,oUllpAgkl+DpXb!/>8m.qitM4h[U0U%,.=$,-G<d,HH');
define('NONCE_KEY', '$T3]/kZLQm#wBO*7DPP`fq,=^RxWCsG-,M$ {c-R^00HpnVhD5Ws]xHgur4&q(%U');
define('AUTH_SALT', 'oDJSYq~:M03sp) Z!+q% -Y5$b4F|`-3Aw]+@V&RC$@;5-Pf%,v]I$CD{Ki]Tt0K');
define('SECURE_AUTH_SALT', 'g)|=r)d%*}; ojgOK]6V:Y+;4Ka43}0OkND_u$QtFQa9Rk-op=9O1`]#UFw_giMR');
define('LOGGED_IN_SALT', 'uOjj,+!Cy:U|U-|Dy c(-wu3L@5(3-a+(g@gZj!kTsL)(-%oJ+3?}BObHcE9;y5H');
define('NONCE_SALT', 'qmPyW]OJJFbTH++QJDZw]QL/~]GUS~/&(0OQzSIzIG9Qxa(8lL-k0Ww&;@eo*^^%');

Note:  It is important that you request unique values each time. Do NOT copy the values shown above.

Now you need to open the WordPress main configuration file on Debian 11 and paste the values directly to the file to set secure keys.

Open the file with your favorite text editor, here we use vi:

sudo vi /var/www/your-domain/wp-config.php

Find the section that contains the dummy values for those settings.

. . .
define('AUTH_KEY',         'put your unique phrase here');
define('SECURE_AUTH_KEY',  'put your unique phrase here');
define('LOGGED_IN_KEY',    'put your unique phrase here');
define('NONCE_KEY',        'put your unique phrase here');
define('AUTH_SALT',        'put your unique phrase here');
define('SECURE_AUTH_SALT', 'put your unique phrase here');
define('LOGGED_IN_SALT',   'put your unique phrase here');
define('NONCE_SALT',       'put your unique phrase here');
. . .

Delete the line and paste the unique values that you have copied from the command line.

Then, in the database connection settings at the top of the file, you need to set the database name, database user, and password.

. . .
define('DB_NAME', 'wordpress');
/** MySQL database username */
define('DB_USER', 'orca');
/** MySQL database password */
define('DB_PASSWORD', 'password');
. . .

Next, add the following line to the database connection settings or anywhere else that you
want:

define('FS_METHOD', 'direct');

When you are done, save and close the file.

Access WordPress Web Interface

At this point, you can complete your WordPress installation on Debian 11 through the web interface.

Type your domain name or your server’s IP address in your web browser:

https://server_domain_or_IP

On the first page, you need to select your desired language and click on continue.

WordPress language selection on Debian 11

In the next window, you will see the main setup page.

Select a name for your WordPress site and choose a username (it is recommended not to choose something like “admin” for security purposes). A strong password is generated automatically. Save this password or select an alternative strong password.

Enter your email address and select whether you want to discourage search engines from indexing your site.

WordPress main setup

Click on the install WordPress, you will see the page where you can log in to your WordPress:

log in to WordPress

Enter your WordPress user and password, you will see the WordPress dashboard:

WordPress dashboard

Conclusion

Now you learn to Set up WordPress on Debian 11. You can easily manage your site and publish content to your site.

Hope you enjoy it.

You may be interested in these articles:

Install and Configure WordPress on Ubuntu 22.04

How To Install WordPress on Rocky Linux 8

How To Set up WordPress on DirectAdmin

1 COMMENT
  1. It’s nearly impossible to find experienced people for this subject, but you sound like you know what you’re talking about! Thanks

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles

POPULAR TAGS

Most Popular