Search Our Database

How to install WordPress in Ubuntu Noble (24.04)

Last updated on |
by

Introduction

This guide explains how to install WordPress on a Ubuntu server. It is intended for users who need to set up a WordPress website on a Ubuntu environment, ensuring that the correct steps are followed for a successful installation. The process covers the installation of necessary software like Apache, MySQL, and PHP (LAMP stack), along with the steps required to configure WordPress. These instructions apply to Ubuntu Noble (24.04) systems and should be followed by users with root or Sudo privileges.

 

 

Prerequisites

  • An Ubuntu Noble server with root or sudo access.
  • A registered domain name (optional but recommended).
  • A fully updated Ubuntu server (use apt update).
  • Apache, MySQL (MariaDB), and PHP installed (instructions provided below).
  • Port 80 and 443 on target server is not blocked by cloud provider of local firewall

 

 

Step-by-Step Guide

Step 1: Update Server package

Before we begin, let’s update and upgrade the system. Login as the root user to your system and update the system to update the repositories.

sudo apt update && sudo apt upgrade -y

 

Step 2: Install Apache Web Server

Start by installing the Apache web server, which will handle web requests to your WordPress site.

sudo apt install apache2 -y

 

After the installation, start and enable the Apache service to run on system boot:

sudo systemctl start apache2
sudo systemctl enable apache2

 

To verify further, open your browser and go to your server’s IP address or domain Name.

https://<ip-address>

You should be able to view the Apache Default page when browsing the server’s Ip address

 

if you cannot view this page, kindly check with your cloud service provider on whether the cloud instance is blocking on port 80 or 443. Additionally, you can check is this issue caused by local machine firewall by checking the firewall status using

sudo ufw status

typically, on a cloud instance, the local firewall is disable upon setup an rely on the cloud provider’s firewall mechanism, which you can edit via the cloud console provided by the cloud provider.

 

Step 3: Install MySQL (MariaDB)

Next, install MariaDB, which is the database system that WordPress uses to store information.

sudo apt install mariadb-server mariadb-client

 

Start and enable the MariaDB service:

sudo systemctl start mariadb 
sudo systemctl enable mariadb

 

Secure your MariaDB installation by running the following command:

sudo mysql_secure_installation

Follow the on-screen prompts to set up a root password and remove insecure defaults.

 

Step 4: Install PHP

PHP is required by WordPress for server-side processing. Install PHP along with its necessary modules:

sudo apt install php php-mysql -y

 

You can verify the PHP installation by creating an php.info file at the path /var/www/html/

vi /var/www/html/info.php

 

Add the following line


&lt;?php
phpinfo();
?&gt;

 

You should be able to see the output below when browsing the server at URL https://<ip-address>/info.php

 

Step 5: Download and Configure WordPress

Navigate to your Apache document root directory and download the latest version of WordPress:

cd /var/www/html 
sudo wget http://wordpress.org/latest.tar.gz

 

Extract the downloaded archive:

sudo tar -xzvf latest.tar.gz

 

Rename the WordPress directory and give it the correct ownership:

sudo mv wordpress/* /var/www/html/ 
sudo chown -R apache:apache /var/www/html/*

 

Step 6: Create a MySQL Database for WordPress

Log into MySQL and create a new database for WordPress:

mysql -u root -p <your database root password>

 

Within the MySQL prompt, execute the following commands to create a database and user:

CREATE DATABASE wordpress; 
GRANT ALL PRIVILEGES ON wordpress.* TO 'username'@'localhost' IDENTIFIED BY 'password'; 
FLUSH PRIVILEGES; 
EXIT;

 

Step 7: Configure WordPress

WordPress needs a wp-config.php file in order to run. WordPress by default provides a config sample file during default installation. We just need to rename it to wp-config.php

Rename the sample configuration file:

sudo mv wp-config-sample.php wp-config.php

 

From this point, you need to edit the wp-config.php so that it points to the previous database with correct credentials. You can achieve so by two methods:

Method 1: Configure via CLI

Edit the configuration file to update the database details:

sudo vi wp-config.php

 

Update the database name, user, and password fields to match the information from Step 5:

wordpress-config

define('DB_NAME', 'wordpress'); 
define('DB_USER', 'username'); 
define('DB_PASSWORD', 'password');

Save the file and exit the editor.

 

Method 2: Configure via WEB GUI

Open your web browser and navigate to http://your_domain_or_IP. You should see the WordPress config page. Follow the on-screen instructions to complete the configuration.

 

Step 8: Finalize Installation

Set the correct permissions for the WordPress files:

sudo chown -R apache:apache /var/www/html/* 
sudo chmod -R 755 /var/www/html/*

 

Finally, restart Apache:

sudo systemctl restart apache2

Now, open your web browser and navigate to http://<ip address>. You should see the WordPress setup page. Follow the on-screen instructions to complete the installation.

 

 

Conclusion

By following this guide, you have successfully installed WordPress on an Ubuntu server. Ensure that you regularly update both WordPress and your server software to maintain security and performance. For additional assistance or if you encounter any issues, please contact our support team at support@ipserverone.com.

 

 

 

Article posted on 22 February 2020 by IPSERVERONE