Installing WordPress with LEMP and MariaDB on Ubuntu
To install WordPress with LEMP and MariaDB on Ubuntu, you will set up a WordPress MariaDB database, install the required PHP packages, download WordPress, configure the web server and MariaDB database, and then complete the installation through the WordPress web interface.Note
If you want to skip all the technical steps of setting up WordPress on your server and have it installed in minutes, then I have some great news for you! Our team of engineers has prepared a ready-to-use 1-click WordPress application for your convenience. Just choose a server, and while prompted to choose the operating system, choose WordPress from the dropdown menu. This will set up WordPress in minutes!Prerequisites for Installing WordPress with LEMP and MariaDB
To install WordPress with the LEMP stack and MariaDB database, you need the following:- An Ubuntu 24.04 server. We offer the globe's absolute lowest cost Ubuntu servers!
- Root access to your server or a
sudo
user. Check out our How to access your server using SSH guide to learn how to access your server and create asudo
user. - The LEMP stack installed on your server. Use our Installing LEMP on Ubuntu 22.04 LTS guide to set it up. Or you can use our LEMP 1-Click Application to get started in minutes! Just choose a server, and while prompted to choose the operating system, choose LEMP from the dropdown menu.
Step 1 - Updating the Package Cache
Before you install WordPress with LEMP and MariaDB, you need to update your Ubuntu packages in the package manager cache to the latest available versions using the following command:sudo apt update
Step 2 - Creating a WordPress MariaDB Database and User
WordPress needs a MySQL database to store your site's data, such as user information, posts, pages, etc. In this tutorial we'll use MariaDB, which is a compatible drop-in replacement for MySQL but with more features. To create a MySQL/MariaDB database, use themysql
client to connect to MariaDB and access its command line interface with the following command:
sudo mysql
If you get an error that contains Access denied for user 'root'
, this means that the default authentication method has changed, and connecting to MariaDB requires a password for the root account. To solve this issue, use the following command to connect to MariaDB using the root user and a password:
mysql -u root -p
You'll be asked for your MySQL root password, enter it and then press Enter.
Note: If you've installed the LEMP stack using our 1-Click App, you'll find your MySQL root password in the App Details widget on your SSDNodes Dashboard. As demonstrated in the following image:
You should get a prompt similar to the following:
Now you can create a database for WordPress. We'll name the database wordpress
, but feel free to use your site's name, or any other name you would like, just make sure to remember it. Use the following MySQL statement to create a database named wordpress
:
CREATE DATABASE wordpress DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
This creates a database called wordpress
with UTF-8 as a character set, which supports all alphabets and languages.
If you receive an error upon entering the preceding command, make sure you've typed it in correctly, and that you end it with a semicolon (;
).
Next, you'll need to create a MariaDB user account that will manage this wordpress
database. Only this one account can interact with the site's database, which is a good security best practice. For this new user, we'll use the name wp_user
, but again, feel free to use another name of your choice.
To create a new MariaDB user account, use the following statement in the MariaDB command line interface. Remember to replace password
with a strong password for your user account, or you might wake up some day to the news of your Wordpress website transforming into an abnormal nightmare:
CREATE USER 'wp_user'@'localhost' IDENTIFIED BY 'password';
Now, you'll need to give all access permissions to the user account that will manage your wordpress
database:
GRANT ALL ON wordpress.* TO 'wp_user'@'localhost';
Here, you use the GRANT ALL
statement to grant all privileges on the wordpress
database to your wp_user
user.
Refresh the privileges for the preceding command to take effect and apply the permission changes to the database server:
FLUSH PRIVILEGES;
Exit out of the MariaDB command line interface and return to the regular Linux shell with the following command:
EXIT;
With this, you have a MariaDB database and a MariaDB user account that can be used by your WordPress website to store data. Next, you'll install some important PHP packages that WordPress needs to function properly.
Step 3 - Installing Required PHP Extensions for WordPress
WordPress requires a few additional PHP packages to be installed, in addition to the PHP packages that were installed with the LEMP stack. In this step, you'll use theapt
command to install the most important PHP extensions that WordPress uses.
Note: The PHP packages we'll install are required for basic WordPress usage, but many WordPress plugins that extend the basic functionalities of WordPress come with their own requirements, and may require additional PHP extension packages to be installed. Refer to the documentation of the specific plugin you want to install to find out its required packages and install them with apt
using the method we'll demonstrate in this step.
To install the most important PHP extensions for WordPress, run the following command:
sudo apt install php-curl php-gd php-intl php-mbstring php-soap php-xml php-xmlrpc php-zip php-imagick
Here, you install the following packages:
php-curl
: Provides a CURL module for PHP. CURL is used in command lines and scripts to transfer data through URLs.php-gd
: Provides a GD module for PHP. The GD library is a library that offers graphics drawing tools to manage image data.php-intl
: Provides an Internationalisation module for PHP.php-mbstring
: A package that provides the MBSTRING module for PHP, which is used to manage non-ASCII strings.php-soap
: Provides the SOAP module for PHP. SOAP is an API architecture that uses the XML language to transfer data between software. Although it has been replaced by the more flexible REST architecture in most web services, SOAP is still used by some companies.php-xml
: A package that provides a DOM, SimpleXML, WDDX, XML, and XSL module for PHP.php-xmlrpc
: Provides a XMLRPC-EPI module for PHP. XML-RPC is a feature of WordPress that enables data to be transmitted via HTTP using XML for encoding.php-zip
: Provides a Zip module for PHP. Zip is a tool that is used to archive and compress files.php-imagick
: Imagick is a native php extension to create and modify images using the ImageMagick API.
php-fpm
process for it to use the newly installed PHP extensions:
sudo systemctl restart php8.1-fpm.service
Note: You may have another version of php-fpm
installed on your system, so you might have to change 8.1
in the preceding command with your version of PHP. To check your php-fpm
version, use the following command:
sudo systemctl status php* | grep fpm.service
You should receive the full name and version of yourContinue reading this article
by subscribing to our newsletter.
Subscribe nowby subscribing to our newsletter.
A note about tutorials: We encourage our users to try out tutorials, but they aren't fully supported by our team—we can't always provide support when things go wrong. Be sure to check which OS and version it was tested with before you proceed.
If you want a fully managed experience, with dedicated support for any application you might want to run, contact us for more information.