Install and Configure WordPress on Debian 12

In this guide, we want to teach you to Install and Configure WordPress on Debian 12. As you know, WordPress is a free and open-source content management system (CMS) that is written in PHP.

Now you can follow the steps below to set up WordPress with LAMP Stack on Debian 12.

Steps To Install and Configure WordPress on Debian 12

To install and secure your WordPress on Debian 12, you need some requirements.

Requirements

You must log in to your server as a non-root user with sudo privileges and set up a basic firewall. For this purpose, you can follow this guide on Initial Server Setup with Debian 12 Boookworm.

Then, you need to install LAMP Stack on your server. You can follow this guide on How To Install LAMP Stack on Debian 12.

Also, you must secure your Apache web server with SSL. To do this, you can visit this guide on Secure Apache with Let’s Encrypt on Debian 12.

When you are done, proceed to the steps below to start your WordPress installation.

Step 1 – Create WordPress Database and User on Debian 12

At this point, you must create a WordPress database and database user. To do this, log in to your MariaDB shell with the command below:

sudo mariadb -u root -p

From your MariaDB shell run the command below to create your WordPress database:

MariaDB [(none)]> CREATE DATABASE wordpressdb DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;

Then, create a database user with a strong password and grant all privileges to it with the following command:

MariaDB [(none)]> GRANT ALL ON wordpressdb.* TO 'wordpressuser'@'localhost' IDENTIFIED BY 'password';

Next, flush the privileges and exit from the MariaDB shell:

MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT;

Step 2 – Install PHP Extensions for WordPress

At this point, you need to install some PHP exertions for your WordPress on Debian 12. To do this, run the command below:

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

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.

Step 3 – Apache Configuration for WordPress on Debian 12

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

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

Step 4 – Download Latest WordPress Package on Debian 12

At this point, you can download WordPress from its official site in the latest version.

First, switch to the /tmp directory:

cd /tmp

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

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

Extract your downloaded file with the following command:

sudo 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:

sudo touch /tmp/wordpress/.htaccess

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

sudo 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:

sudo 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

Step 5 – WordPress Configuration on Debian 12

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 12:

# 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:

sudo 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',         'a57u#N}f 2b5ik!3LiLac;cpa_1,umnXx7:XDLu}-5Wsv^Ls.KAO>>T)(CF?>TGM');
define('SECURE_AUTH_KEY',  'd!UP(*,[-;SsT7y:Mh7L^Kr[RF0jX-q5FI=S.:Q14t;5!P`Fx=PP|TXxA`b1,MGb');
define('LOGGED_IN_KEY',    '7Q&2umUobQ=#b$LGdK^yOqWU^S64@%1#;MUxS}CT`;|kIy/%p2LP^B83MyqS8cW+');
define('NONCE_KEY',        '}`$pTbw<S.gqB!^>&L8hY<:?p:~S:)rHf&Zo4G]B4L|84%t*rw7[R8(VNsac6W% ');
define('AUTH_SALT',        'EM5|,mQasmCLAH<czs,<Mi4QEs|CHk}cU|KNk-y%zFUI>a 9Tu~i!r+x~L!2hZ(o');
define('SECURE_AUTH_SALT', '{x<|6V J72j|Z$h_Jk?:~~$94ek7O9Q^X-*1~}s}R_vyD<XbbmH:<(dGO;eh;48U');
define('LOGGED_IN_SALT',   'jCN[ZWL(|-?FkMZKE_v6g]>@a(, *(I#r3O0SW`!+^O@&@oaFHKmkwGC>VK%1&EJ');
define('NONCE_SALT',       '^2F|GTU(-qoX_:@C7#`o-3ugOL?Q&pu1P#s!TN9E]+6w/@7:eT[aw7#SrV$Msq|s');

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 12 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', 'wordpressdb');
/** MySQL database username */
define('DB_USER', 'wordpressuser');
/** 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.

Step 6 – Access WordPress Web Interface

At this point, you can complete your WordPress installation on Debian 12 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

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.

WordPress Success installation

Enter your WordPress user and password and click Login.

WordPress Login page

Now you should see your WordPress dashboard on Debian 12.

WordPress dashboard debian 12

From there, you can manage your website.

For more information, you can visit WordPress Official Website.

Conclusion

At this point, you have learned to Install and Configure WordPress CMS on Debian 12 with LAMP Stack and secure your installation by generating the SSL certificates from Let’s Encrypt and accessing your WordPress dashboard through a Web interface.

Hope you enjoy it. You may be like these articles too:

How To Change SSH Port on Debian

Set up MonoDevelop on Debian 12 Bookworm

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Stay informed and not overwhelmed, subscribe now!