WordPress installation

How Can We Help?

WordPress installation

You are here:
< Back to the Wiki

This article will explain how to install WordPress (6.2.2) using PHP (8.2) with a MariaDB (10.11.3) database and an Apache webserver.

Prerequisites

TBA…

Installation

MariaDB

WordPress requires a database to save its data. To install MariaDB run apt-get install mariadb-server. After the installation is finished secure the database by running mysql_secure_installation. This will prompt the following questions:

  • Enter current password for root: Fill in your root password
  • Switch to unix_socket authentication: Press n since we already have a root user
  • Change root password: Press Y and fill in a new password or your root password
  • Remove anonymous users: Press Y since we will add specific users later
  • Disallow root login remotely: Press Y since logging in locally is more secure
  • Remove test database and access to it: Press Y since we will add a specific database later
  • Reload privilege tables now: Press Y to update the database
Securing MariaDB database

Now open a connection to the database using mysql -u root -p and enter the following:

CREATE DATABASE wordpress_db;
CREATE USER 'wordpress_user'@'localhost' identified by '****';
GRANT ALL PRIVILEGES ON wordpress_db.* TO 'wordpress_user'@'localhost';
FLUSH PRIVILEGES;
QUIT;

This will set up a database with a user which will be used later for WordPress. Make sure to modify the variables to your needs, and write the details down for the next steps.
Alternatively, you can add the above-mentioned SQL statements to a file and let the database apply it using the following command:

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

Apache

To be able to visit the WordPress website, you need a web server. We will use Apache, to install it and run apt-get install apache2.

PHP

WordPress requires PHP to run, below is a table showing the recommended PHP (8.2) packages for WordPress.

NamePackageImportanceMotivation
jsonBundled since PHP 8.0.0RequiredUsed for communications with other servers and processing data in JSON format
mysqlphp8.2-mysqlRequiredConnects to MySQL for database interactions
curlphp8.2-curlHighly recommendedPerforms remote request operations
domphp8.2-xmlHighly recommendedUsed to validate Text Widget content and to automatically configure IIS7+
exifphp8.2-commonHighly recommendedWorks with metadata stored in images
fileinfophp8.2-commonHighly recommendedUsed to detect mimetype of file uploads
hashBundled since PHP 5.1.2Highly recommendedUsed for hashing, including passwords and update packages
imagickphp8.2-imagickHighly recommendedProvides better image quality for media uploads
mbstringphp8.2-mbstringHighly recommendedUsed to properly handle UTF8 text
opensslopensslHighly recommendedPermits SSL-based connections to other hosts
pcreBundledHighly recommendedIncreases performance of pattern matching in code searches
xmlphp8.2-xmlHighly recommendedUsed for XML parsing, such as from a third-party site
zipphp8.2-zipHighly recommendedUsed for decompressing Plugins, Themes, and WordPress update packages
memcachedphp8.2-memcachedRecommendedmemcached is a high-performance, distributed memory object caching system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load
opcachephp8.2-opcacheRecommendedPHP can be configured to preload scripts into the opcache when the engine starts
redisphp8.2-redisRecommendedPHP extension for interfacing with Redis
bcphp8.2-bcmathOptionalFor arbitrary precision mathematics, which supports numbers of any size and precision up to 2147483647 decimal digits
filterBundledOptionalUsed for securely filtering user input
imagephp8.2-gdOptionalIf Imagick isn’t installed, the GD Graphics Library is used as a functionally limited fallback for image manipulation
iconvphp8.2-commonOptionalUsed to convert between character sets
intlphp8.2-intlOptionalEnable to perform locale-aware operations including but not limited to formatting, transliteration, encoding conversion, calendar operations, conformant collation, locating text boundaries and working with locale identifiers, timezones and graphemes
simplexmlphp8.2-xmlOptionalUsed for XML parsing
sodiumBundled since PHP 7.2.0OptionalValidates Signatures and provides securely random bytes
xmlreaderphp8.2-xmlOptionalUsed for XML parsing
zlibBundledOptionalGzip compression and decompression
ssh2php8.2-ssh2Optional (for file changes)Provide access to resources (shell, remote exec, tunneling, file transfer) on a remote machine using a secure cryptographic transport
ftpphp8.2-commonOptional (for file changes)Implement client access to files servers speaking the File Transfer Protocol (FTP)
socketsphp8.2-commonOptional (for file changes)Implements a low-level interface to the socket communication functions based on the popular BSD sockets
Recommended PHP packages for WordPress from make.wordpress.org

To install the packages select your preferred packages and run apt-get install <packages separated by spaces>. For our installation, we used:

# Required
apt-get install \
php8.2-mysql
# Highly recommended
apt-get install \
php8.2-curl php8.2-xml php8.2-common php8.2-imagick \
php8.2-mbstring openssl php8.2-zip \
# Recommended
apt-get install \
php8.2-memcached php8.2-opcache php8.2-redis \
# Optional
apt-get install \
php8.2-bcmath php8.2-intl

The following packages were not installed with reasons:

  • php8.2-gd: Since imagick is already installed
  • php8.2-ssh2: Since ftp and sockets are already installed via php8.2-common

To verify which PHP modules are enabled use php -v. If there are modules that are not enabled yet, you can run phpenmod __MODULE__.

phpenmod curl xml imagick mbstring zip memcached opcache redis bcmath intl

Restart the webserver to make sure that it uses the newly enabled modules: systemctl restart apache2.

Since we have installed an Apache web server we also require a PHP package to communicate with Apache, install it using apt-get install libapache2-mod-php8.2. To validate if PHP works, create a file named /var/www/html/php_info.php and add the following:

<?php
phpinfo();
?>

If you navigate to <your website URL>/php_info.php you should see an information page about the PHP installation.

PHP info

WordPress

When searching in the apt packages there is a WordPress package available. However, after testing this package it resulted in a lot of issues mainly since the files end up in /etc and /usr/share. Therefore, this article deviates from installing it using the apt packages and we install WordPress manually.

To install WordPress from the source, use the following commands:

# Navigate to the Apache web server file location
cd /var/www/html
# Download WordPress
wget https://wordpress.org/latest.tar.gz
# Extract the files
tar -xzvf latest.tar.gz
# Move the files to the correct folder
mv wordpress/* .
# Set the correct ownership for the web server
chown -R www-data:www-data /var/www/html
# Optional: Cleanup
rm -rf wordpress index.html latest.tar.gz php_info.php

Optionally, if you want to install a custom WordPress version go to the release archive (wordpress.org), copy the link of your preferred version and download and extract it on your server.

Navigate to <your website URL>/wp-admin/setup-config.php. Choose your preferred language and click Continue.

WordPress installation – Choose the language

It will prompt you with a welcome message, find your database credentials from before, and click Let’s go!

WordPress installation – Welcome!

Fill in your database connection details and click Submit.

WordPress installation – Database connection details

Unfortunately, writing to the wp-config.php file was not successful. Therefore, copy the information and paste it in /var/www/html/wp-config.php. Make sure to set the correct rights for the file by using chown www-data:www-data /var/www/html/wp-config.php. To continue to the installation click Run the installation.

WordPress installation – Failed to write to wp-config.php

It will now ask to give your site a name, create a user, and option to discourage search engine visibility. Once you are satisfied click Install WordPress, and after a short coffee break your WordPress website is ready to be used!

WordPress installation – Site information

Sources

14 Responses

  1. Jared says:

    I appreciate how your writing captures your unique character. It feels like we’re engaging in a meaningful conversation.

  2. Nelly says:

    I’m captivated by your aptitude to transform mundane subjects into persuasive content. Bravo!

  3. pura 600 says:

    Wow, superb weblog layout! How lengthy have you ever
    been running a blog for? you make blogging glance easy.
    The total glance of your web site is magnificent, let alone the content!

  4. stavkapro says:

    In my opinion, it is an interesting question, I will take part in discussion.

  5. avenue17 says:

    Тема интересна, приму участие в обсуждении.

  6. avenue17 says:

    Matchless phrase 😉

Leave a Reply to Cynthia Cancel reply

Your email address will not be published. Required fields are marked *

Table of Contents