How to Install WordPress on Ubuntu 22.04 Server (Step-by-Step Guide)

If you’re running a fresh Ubuntu 22.04 server and want to install WordPress, follow this simple step-by-step guide. This method uses Apache, MySQL, and PHP (a LAMP stack) to get your WordPress site up and running.

 

Step 1: Update the System

sudo apt update

Step 2: Install Apache Web Server

 
sudo apt install apache2

Step 3: Install MySQL Database Server

 
sudo apt install mysql-server
sudo mysql_secure_installation

This will secure your MySQL installation with recommended settings.


Step 4: Install PHP and Required Extensions

sudo apt install php libapache2-mod-php php-mysql
sudo systemctl restart apache2

Step 5: Create a MySQL Database for WordPress

 
sudo mysql

Then run these SQL commands inside the MySQL shell:

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

You can change 'password' to something more secure.


Step 6: Download and Extract WordPress

cd /tmp
curl -LO https://wordpress.org/latest.tar.gz
tar xzvf latest.tar.gz

Step 7: Configure WordPress

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

Update the following lines with your database details:

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

Step 8: Move WordPress Files to Web Directory

 
sudo rsync -avP /tmp/wordpress/ /var/www/html/

Set proper permissions:

sudo chown -R www-data:www-data /var/www/html/
sudo chmod -R 755 /var/www/html/

(Optional) Remove the default Apache page:

sudo rm /var/www/html/index.html

Final Step: Finish Installation in Browser

Open your server’s IP in a browser, for example:

http://your_server_ip/

Follow the WordPress setup wizard to complete the installation.


That’s it! You’ve successfully installed WordPress on Ubuntu 22.04.
If you found this helpful, don’t forget to share and subscribe to my YouTube channel for more tutorials.

Leave a Reply

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