DEV Community

Cover image for LAMP (Install Wordpress on Ubuntu using the terminal):
MuthuKumar
MuthuKumar

Posted on • Updated on

LAMP (Install Wordpress on Ubuntu using the terminal):

To install WordPress on Ubuntu using the terminal, you'll need to set up a LAMP (Linux, Apache, MySQL, PHP) stack, as WordPress is a PHP-based application that requires a web server and a database. Here are the steps to install WordPress:

  1. Update System Packages: Open a terminal and run the following commands to update your system's package repositories and upgrade existing packages:
   sudo apt update
   sudo apt upgrade
Enter fullscreen mode Exit fullscreen mode
  1. Install Apache Web Server: Install the Apache web server by running:
   sudo apt install apache2
Enter fullscreen mode Exit fullscreen mode

After installation, Apache should start automatically. You can check its status using:

   sudo systemctl status apache2
Enter fullscreen mode Exit fullscreen mode
  1. Install MySQL Database: Install MySQL server and follow the prompts to set a root password:
   sudo apt install mysql-server
Enter fullscreen mode Exit fullscreen mode

Run the MySQL secure installation script to enhance security:

   sudo mysql_secure_installation
Enter fullscreen mode Exit fullscreen mode
  1. Install PHP and Required Modules: Install PHP and its required modules:
   sudo apt install php libapache2-mod-php php-mysql php-curl php-gd php-mbstring php-xml php-xmlrpc php-soap php-intl php-zip
Enter fullscreen mode Exit fullscreen mode
  1. Configure Apache for PHP: Enable the necessary Apache modules and restart Apache:
   sudo a2enmod php
   sudo systemctl restart apache2
Enter fullscreen mode Exit fullscreen mode
  1. Download and Configure WordPress: Navigate to your Apache web root directory:
   cd /var/www/html
Enter fullscreen mode Exit fullscreen mode

Download the latest WordPress release:

   sudo wget https://wordpress.org/latest.tar.gz
Enter fullscreen mode Exit fullscreen mode

Extract the downloaded archive:

   sudo tar -xzvf latest.tar.gz
Enter fullscreen mode Exit fullscreen mode

Rename the WordPress directory:

   sudo mv wordpress your-site-name
Enter fullscreen mode Exit fullscreen mode

Set appropriate permissions:

   sudo chown -R www-data:www-data your-site-name
Enter fullscreen mode Exit fullscreen mode
  1. Create MySQL Database and User: Log in to MySQL:
   sudo mysql -u root -p
Enter fullscreen mode Exit fullscreen mode

Inside the MySQL shell, create a database and user for WordPress:

   CREATE DATABASE your_database_name;
   CREATE USER 'your_username'@'localhost' IDENTIFIED BY 'your_password';
   GRANT ALL PRIVILEGES ON your_database_name.* TO 'your_username'@'localhost';
   FLUSH PRIVILEGES;
   EXIT;
Enter fullscreen mode Exit fullscreen mode
  1. Configure WordPress: Open your web browser and navigate to your server's IP address or domain followed by the directory name where you installed WordPress (e.g., http://your_server_ip/your-site-name).

Follow the WordPress setup instructions. Provide the database details you created earlier.

  1. Complete Installation: Finish the WordPress installation through the web interface, setting up your admin account and site settings.

That's it! You've successfully installed WordPress on your Ubuntu system using the terminal.

Try it YourSelf:

Top comments (0)