WordPress On VPS (Step 3): Installing WordPress

By now, you should have registered your domain name and configured the DNS settings so that it will point to your VPS. If you haven’t, and somehow stumbled on this post, go back to Step 1 to register your domain name via NameSilo. If you’ve missed Step 2, go back and configure the DNS settings for your domain.

Step 3: Installing WordPress
First, you need to SSH into your VPS. Next, perform the following commands while in your user directory (replace all with your own domain name):

  1. Wget the latest copy of WordPress from
    sudo wget
  2. Extract the wordpress folder from the .tar.gz file:
    sudo tar -xzvf latest.tar.gz
  3. Create the directory using your domain name in /var/www, and public_html folder in /var/www/
    sudo mkdir /var/www/
    sudo mkdir /var/www/
  4. Copy the contents of the wordpress folder into /var/www/
    sudo cp -r wordpress/* /var/www/
  5. Change the owner of your public_html folder and all its contents to www-data (the OS of my VPS is Ubuntu, so we use www-data):
    sudo chown -R www-data:www-data /var/www/
  6. In /etc/apache2/sites-available/, create a new file named
    sudo vi /etc/apache2/sites-available/
    Then type in the following:

    <Directory "/var/www/">
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
    <VirtualHost *:80>
    DocumentRoot /var/www/
    ErrorLog /var/www/
    CustomLog /var/www/ common

  7. Create a MySQL database for this WordPress website and a user that will have all privileges to access and modify it. I used phpMyAdmin as it’s definitely way easier to just click around, but if you haven’t got it installed and need to use commands, here they are.
    1. Login to MySQL:
      mysql -u root -p
    2. Create database (replace wordpress_db with your desired database name):
      create database wordpress_db;
    3. Create user and grant him all privileges to access and modify the database (replace wordpress_user and wordpress_pass with your desired username and password respectively):
      create user wordpress_user@localhost identified by 'wordpress_pass';
      grant all privileges on wordpress_db.* to wordpress_user@localhost;
    4. You’re done with the database, so exit:
  8. Make a copy of wp-config-sample.php and name it wp-config.php in /var/www/ folder:
    sudo cp /var/www/ /var/www/
  9. Open wp-config.php and modify the following lines:

    define('DB_NAME', 'database_name_here');
    define('DB_USER', 'username_here');
    define('DB_PASSWORD', 'password_here');

    Go to to obtain the secret keys and replace the following lines with those from your browser:

    define('AUTH_KEY', 'put your unique phrase here');
    define('SECURE_AUTH_KEY', 'put your unique phrase here');
    define('LOGGED_IN_KEY', 'put your unique phrase here');
    define('NONCE_KEY', 'put your unique phrase here');
    define('AUTH_SALT', 'put your unique phrase here');
    define('SECURE_AUTH_SALT', 'put your unique phrase here');
    define('LOGGED_IN_SALT', 'put your unique phrase here');
    define('NONCE_SALT', 'put your unique phrase here');

    Save your file.

  10. Now type in this command:
    sudo a2ensite
  11. Reload your Apache2 service:
    sudo service apache2 reload
  12. You may now access your WordPress site by entering your domain name into your browser! You will see a setup page and just go ahead to get your site ready!

Ta-da you’re done! You may now enjoy the process of selecting an appropriate theme for your WordPress site and designing your website to suit your needs. Have fun! 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *