Logo

How To Install WordPress with LAMP on Ubuntu 24.04

Mar 15, 2024

To install WordPress on Ubuntu 24.04 using LAMP stack, follow the guide below.

Step 1 : Install LAMP Stack

If you haven't installed LAMP yet, follow the guide on Ubuntu 24.04 Guides.

Step 2 : Create Database

- Log in to MySQL:

sudo mysql

- Create a new MySQL user and database:

CREATE DATABASE wpdatabase;
CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON wpdatabase.* TO 'wpuser'@'localhost';
FLUSH PRIVILEGES;

Step 3 : Download and Install WordPress

- Create directory (e.g., example.devtutorial.io)

sudo mkdir /var/www/example.devtutorial.io

- Change directory and download WordPress:

cd /var/www/example.devtutorial.io
wget https://wordpress.org/latest.tar.gz

- Extract the downloaded file:

tar -xzvf latest.tar.gz

- Move WordPress files:

mv wordpress/* .

- Set permissions:

chown -R www-data:www-data /var/www/example.devtutorial.io
chmod -R 755 /var/www/example.devtutorial.io

Step 4 : Create a new Apache configuration file for your domain:

sudo nano /etc/apache2/sites-available/example.devtutorial.io.conf

Add the following configuration:

<VirtualHost *:80>
    ServerAdmin webmaster@devtutorial.io
    DocumentRoot /var/www/example.devtutorial.io
    ServerName example.devtutorial.io

    <Directory /var/www/example.devtutorial.io/>
        Options FollowSymlinks
        AllowOverride All
        Require all granted
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Step 5 : Enable the Site

sudo a2ensite example.devtutorial.io.conf

Step 6 : Test Configuration and Restart Apache

sudo apache2ctl configtest
sudo systemctl restart apache2

Step 7 : Open a Browser and Navigate to Install WordPress

- Visit http://example.devtutorial.io

- Choose your language

- Click "Let's go!"

- Fill in the database information

- If information is correct, click "Run the installation"

- Enter WordPress information and click "Install WordPress"

Step 8 : Login to WordPress

- Enter the credentials you provided during installation

Step 9 : Access WordPress Dashboard

Congratulations! You have successfully installed WordPress with LAMP on Ubuntu 24.04.

Recommended