How to Install WordPress on VPS?

To install WordPress on a VPS (Virtual Private Server), you need to follow the below steps:

  1. Choose a VPS provider and create a VPS instance.
  2. Log in to your VPS instance using SSH.
  3. Install Apache web server and PHP:
    sudo apt-get update
    sudo apt-get install apache2 php php-mysql php-gd libapache2-mod-php php-curl
  4. Start and enable Apache to start at boot time:
    sudo systemctl start apache2
    sudo systemctl enable apache2
  5. Install MySQL database server:
    sudo apt-get install mysql-server
  6. Secure MySQL installation by running the following command and following the on-screen instructions:
    sudo mysql_secure_installation
  7. Create a database and user for WordPress:
    sudo mysql -u root -p
    CREATE DATABASE wordpress;
    CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'password';
    GRANT ALL PRIVILEGES ON wordpress.* TO 'wpuser'@'localhost';
    FLUSH PRIVILEGES;
    exit;
  8. Download and extract WordPress:
    cd /var/www/html
    sudo curl -O https://wordpress.org/latest.tar.gz
    sudo tar -zxvf latest.tar.gz
  9. Copy the WordPress sample configuration file and make changes to it:
    sudo cp /var/www/html/wordpress/wp-config-sample.php /var/www/html/wordpress/wp-config.php
    sudo vi /var/www/html/wordpress/wp-config.php

    Replace the following lines with the database, username, and password that you have created:

    define('DB_NAME', 'wordpress');
    define('DB_USER', 'wpuser');
    define('DB_PASSWORD', 'password');
    define('DB_HOST', 'localhost');
  10. Set proper permissions on the WordPress directory:
    sudo chown -R www-data:www-data /var/www/html/wordpress
    sudo chmod -R 755 /var/www/html/wordpress
  1. Restart Apache:
    sudo systemctl restart apache2

You should now be able to access your WordPress installation by visiting your server’s IP address or domain name in a web browser.