Here’s a step-by-step guide to install WordPress on Ubuntu (20.04/22.04) using a LAMP stack (Linux, Apache, MySQL, PHP):
โ Step 1: Update Your System
Open your terminal and run:
sudo apt update && sudo apt upgrade -y
โ Step 2: Install Apache Web Server
sudo apt install apache2 -y
Enable and start Apache:
sudo systemctl enable apache2
sudo systemctl start apache2
โ Step 3: Install MySQL (Database Server)
sudo apt install mysql-server -y
Secure MySQL:
sudo mysql_secure_installation
Follow the prompts to set root password and remove test users/databases.
โ Step 4: Create a MySQL Database for WordPress
Log into MySQL:
sudo mysql -u root -p
Then run:
CREATE DATABASE wordpress;
CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'your_strong_password';
GRANT ALL PRIVILEGES ON wordpress.* TO 'wpuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;
โ Step 5: Install PHP and Required Extensions
sudo apt install php php-mysql php-curl php-gd php-xml php-mbstring php-xmlrpc php-soap php-intl php-zip libapache2-mod-php -y
Restart Apache to apply PHP:
sudo systemctl restart apache2
โ Step 6: Download and Configure WordPress
Navigate to /tmp:
cd /tmp
Download WordPress:
curl -O https://wordpress.org/latest.tar.gz
Extract the archive:
tar -xvzf latest.tar.gz
Move WordPress to the web root:
sudo rsync -av wordpress/ /var/www/html/
โ Step 7: Set Permissions
sudo chown -R www-data:www-data /var/www/html/
sudo find /var/www/html/ -type d -exec chmod 755 {} \;
sudo find /var/www/html/ -type f -exec chmod 644 {} \;
โ Step 8: Configure Apache for WordPress
Create a virtual host file:
sudo nano /etc/apache2/sites-available/wordpress.conf
Paste this:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ServerName your_domain_or_IP
<Directory /var/www/html>
AllowOverride All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Enable the site and rewrite module:
sudo a2ensite wordpress.conf
sudo a2enmod rewrite
sudo systemctl restart apache2
โ Step 9: Configure WordPress
Rename the sample config:
cd /var/www/html
sudo mv wp-config-sample.php wp-config.php
Edit it:
sudo nano wp-config.php
Update the database settings:
define( 'DB_NAME', 'wordpress' );
define( 'DB_USER', 'wpuser' );
define( 'DB_PASSWORD', 'your_strong_password' );
define( 'DB_HOST', 'localhost' );
Save and exit.
โ Step 10: Complete Installation via Web Browser
Open your browser and visit:
http://your_domain_or_IP
Follow the on-screen instructions to:
- Choose language
- Set site title
- Create admin account
- Finish installation
๐ WordPress is now installed!
41
Discover more from CONTEXT EDUCATION
Subscribe to get the latest posts sent to your email.

