Deploying a WordPress Site on Your VPS

WordPress is a widely-used platform for creating websites, blogs, and online stores. This guide will take you through each step to install WordPress on your VPS, from setting up a web server to finalizing your site’s installation.


Step 1: Access Your VPS via SSH

  • Open an SSH client (e.g., Terminal for macOS/Linux or PuTTY for Windows).
  • Connect to your VPS:
    bash
    ssh root@your-server-ip
  • Press Enter, then input your VPS password when prompted.

Step 2: Update System Packages

Before installing WordPress, make sure your server's packages are up to date:

bash
sudo apt update && sudo apt upgrade -y

Step 3: Install a Web Server (Apache or Nginx)

You’ll need a web server to host your WordPress site.

To Install Apache:

bash
sudo apt install apache2 -y

Start and enable Apache to run at startup:

bash
sudo systemctl start apache2
sudo systemctl enable apache2

To Install Nginx:

bash
sudo apt install nginx -y

Start and enable Nginx to run at startup:

bash
sudo systemctl start nginx sudo systemctl enable nginx

Step 4: Install PHP and Necessary Extensions

WordPress requires PHP, so install PHP along with common extensions:

bash
sudo apt install php php-mysql php-curl php-gd php-mbstring php-xml php-xmlrpc php-zip -y

Step 5: Install a Database Server (MySQL or MariaDB)

To Install MySQL:

bash
sudo apt install mysql-server -y

Run MySQL’s secure installation script:

bash
sudo mysql_secure_installation

Step 5A: Create a Database and User for WordPress

  • Log into MySQL:
    bash
    sudo mysql -u root -p
  • Create a new database for WordPress:
    sql
    CREATE DATABASE wordpress_db;
  • Create a user and grant permissions:
    sql
    CREATE USER 'wp_user'@'localhost' IDENTIFIED BY 'your_password'; GRANT ALL PRIVILEGES ON wordpress_db.* TO 'wp_user'@'localhost'; FLUSH PRIVILEGES; EXIT;

Step 6: Download WordPress

  • Navigate to the web directory (Apache: /var/www/html or Nginx: /usr/share/nginx/html):
    bash
    cd /var/www/html
  • Download the latest WordPress version:
    bash
    wget https://wordpress.org/latest.tar.gz
  • Extract the downloaded file:
    bash
    tar -xzf latest.tar.gz
  • Move WordPress files to the root web directory:
    bash
    sudo mv wordpress/* ./
  • Remove unnecessary files:
    bash
    sudo rm -rf wordpress latest.tar.gz

Step 7: Configure WordPress

  • Copy the sample WordPress configuration file:

    bash
    sudo cp wp-config-sample.php wp-config.php
  • Open the wp-config.php file to edit:

    bash
    sudo nano wp-config.php
  • Find the following lines and update them with your database details:

    php
    define('DB_NAME', 'wordpress_db'); define('DB_USER', 'wp_user'); define('DB_PASSWORD', 'your_password');
  • Save and exit the editor (in Nano, press CTRL+X, then Y to confirm, and Enter).


Step 8: Set File Permissions

Set correct permissions for WordPress files to ensure they’re accessible:

bash
sudo chown -R www-data:www-data /var/www/html sudo chmod -R 755 /var/www/html

Step 9: Complete the Installation in Your Web Browser

  • Open your web browser and navigate to your VPS IP address (e.g., http://your-server-ip).
  • You’ll be guided through the WordPress setup. Select your language, create an admin account, and enter your site information.
  • After completing the steps, click Install WordPress.

Step 10: Log In to WordPress

Once installation is complete, log into your WordPress dashboard by visiting:

arduino
http://your-server-ip/wp-admin

Use the credentials you created during the setup to log in.


Your WordPress site is now live on your VPS! You can start adding content, install plugins, and customize the appearance of your site from the WordPress dashboard.

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