Installing WordPress is a crucial step for anyone looking to create a website or a blog. While the traditional method involves using a web browser and a graphical user interface, advanced users often prefer the command-line approach for its efficiency and flexibility. In this article, we will walk you through the process of install WordPress from terminal, complete with step-by-step instructions and command examples.

Prerequisites: Before you begin, ensure you have the following prerequisites in place:

  1. A server with a terminal access (SSH).
  2. A web server (e.g., Apache or Nginx) installed and configured.
  3. A MySQL or MariaDB database server with appropriate user credentials.
  4. PHP installed on your server.
  5. Basic familiarity with command-line operations.

Step 1: Download WordPress Core Files To get started, open your terminal and connect to your server using SSH. Navigate to the directory where you want to install WordPress and use the following command to download the latest WordPress core files:

wget https://wordpress.org/latest.tar.gz

 

Step 2: Extract WordPress Files After the download is complete, extract the downloaded archive and move the WordPress files to your web server’s document root directory. Execute the following commands in sequence:

 

tar -xzvf latest.tar.gz

mv wordpress/* /var/www/your_website/

Step 3: Create a Database Next, log in to your MySQL or MariaDB server and create a new database for your WordPress installation:

CREATE DATABASE database_name;

Create a new user and grant them privileges on the newly created database:

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

Step 4: Configure WordPress Navigate back to your terminal and move to the root directory of your web server. Rename the wp-config-sample.php file to wp-config.php:

cd /var/www/website_name
mv wp-config-sample.php wp-config.php
Edit the wp-config.php file to provide your database credentials:
nano wp-config.php

Find the following lines and replace them with your database information:

define('DB_NAME', 'database_name');
define('DB_USER', 'wpuser');
define('DB_PASSWORD', 'password');
define('DB_HOST', 'localhost');

Step 5: Set Permissions Adjust the ownership and permissions for the WordPress files:

 

chown -R www-data:www-data *
chmod -R 755 *

 

Step 6: Complete Installation via Browser Now that you’ve completed the terminal-based setup, open a web browser and navigate to your server’s domain name or IP address (e.g., http://yourdomain.com or http://your_server_ip). Follow the on-screen instructions to complete the WordPress installation, including setting up the site title, admin username, password, and email.

Conclusion: Installing WordPress from the terminal offers a streamlined and efficient way to set up your website or blog. By following the steps outlined in this guide, you’ve successfully installed WordPress using command-line tools, demonstrating your prowess in managing server environments. Embrace this skill to optimize your web development workflow and gain better control over your WordPress installations.