How to install WordPress on Ubuntu 18.04

Installing WordPress on Ubuntu 18.04 is a straightforward process. Here’s a step-by-step guide:

  1. Update the system: Before installing WordPress, it’s a good idea to make sure your Ubuntu system is up-to-date. You can do this by running the following command in the terminal:
sudo apt update && sudo apt upgrade
  1. Install LAMP stack: WordPress requires a web server, database server, and PHP to run. You can install all of these by installing the LAMP stack (Linux, Apache, MySQL, PHP) using the following command:
sudo apt install apache2 mysql-server php libapache2-mod-php php-mysql
  1. Create a MySQL database: WordPress requires a MySQL database to store its data. You can create a new database using the following command:
sudo mysql -u root -p

This will prompt you to enter your MySQL root password. Once you’re logged in, create a new database with the following command:

CREATE DATABASE wordpress;

Replace “wordpress” with the name of your database.

  1. Create a MySQL user: After creating a database, you need to create a MySQL user with privileges to access that database. You can create a new user with the following command:
CREATE USER 'wordpressuser'@'localhost' IDENTIFIED BY 'password';

Replace “wordpressuser” with the name of your user, and “password” with a strong password.

  1. Grant privileges to the MySQL user: Next, you need to grant privileges to the MySQL user to access the WordPress database. You can do this with the following command:
GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpressuser'@'localhost';
  1. Download and extract WordPress: You can download the latest version of WordPress from the official website. Once downloaded, extract the WordPress archive into the Apache web server’s root directory using the following command:
sudo tar -xzf /path/to/wordpress.tar.gz -C /var/www/html/

Replace “/path/to/wordpress.tar.gz” with the path to the downloaded WordPress archive.

  1. Set permissions: You need to set the appropriate permissions on the WordPress directory to ensure that Apache can read and write files to it. You can do this with the following commands:
sudo chown -R www-data:www-data /var/www/html/wordpress/
sudo chmod -R 755 /var/www/html/wordpress/
  1. Configure WordPress: Finally, navigate to your WordPress site in your web browser to complete the installation process. The WordPress installation wizard will guide you through setting up your site, including connecting to the MySQL database you created earlier.

That’s it! You’ve now installed WordPress on Ubuntu 18.04.