How to Install WordPress on Ubuntu 22.04

WordPress is a popular content management system (CMS) that allows you to create and manage websites easily. This guide will walk you through the process of installing WordPress on an Ubuntu 22.04 server.

Prerequisites

Before you start, ensure you have the following:

  • An Ubuntu 22.04 server with a non-root user with sudo privileges
  • A LAMP stack installed on your server (Linux, Apache, MySQL, PHP)
  • A domain name pointed to your server's IP address

Step 1: Update Your Server

First, update your package index and upgrade the installed packages to the latest versions:

sudo apt update
sudo apt upgrade

Step 2: Install Required PHP Extensions

WordPress requires several PHP extensions. Install them using the following command:

sudo apt install php-curl php-gd php-mbstring php-xml php-xmlrpc php-soap php-intl php-zip

Step 3: Create a MySQL Database and User for WordPress

Log in to MySQL as the root user:

sudo mysql -u root -p

Create a new database for WordPress:

CREATE DATABASE wordpress DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;

Create a new MySQL user and grant privileges to the WordPress database:

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

Step 4: Download and Configure WordPress

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

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

Extract the downloaded file:

sudo tar -xvzf latest.tar.gz

Move the extracted files to the root directory and set the correct permissions:

sudo mv wordpress/* .
sudo chown -R www-data:www-data /var/www/html
sudo chmod -R 755 /var/www/html

Step 5: Configure the Apache Web Server

Create a new virtual host configuration file for your WordPress site:

sudo nano /etc/apache2/sites-available/wordpress.conf

Add the following configuration to the file:

<VirtualHost *:80>
    ServerAdmin [email protected]
    ServerName example.com
    ServerAlias www.example.com
    DocumentRoot /var/www/html
    <Directory /var/www/html/>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Enable the new virtual host and the rewrite module:

sudo a2ensite wordpress.conf
sudo a2enmod rewrite
sudo systemctl restart apache2

Step 6: Complete the WordPress Installation

Open your web browser and go to your domain name (e.g., http://example.com). You will see the WordPress installation page.

Select your preferred language and click "Continue."

On the next screen, enter the database details you configured earlier:

  • Database Name: wordpress
  • Username: wordpressuser
  • Password: your_password
  • Database Host: localhost
  • Table Prefix: wp_ (you can leave this as the default or change it for better security)

Click "Submit," and then "Run the installation."

On the next screen, enter your site information and create an admin account:

  • Site Title: Your WordPress Site
  • Username: admin
  • Password: your_admin_password
  • Your Email: [email protected]

Click "Install WordPress."

After the installation is complete, log in with the admin account you created.

Conclusion

Congratulations! You have successfully installed WordPress on your Ubuntu 22.04 server. You can now start customizing your site, installing themes, and adding plugins to create a fully functional website. Remember to keep your WordPress installation and plugins updated to ensure the security and performance of your site.

Was this answer helpful? 0 Users Found This Useful (0 Votes)