How to install WordPress on VPS with SSH

The most common way of installing WordPress is by downloading the zip file and uploading it to your server using an FTP client. But this is not the safest way, in this tutorial I teach how to install WordPress via SSH. There are many tutorials teaching how to connect via SSH so I’ll skip this step.

The steps to do this

The first step is to download the latest version of WordPress, If you don’t can your site in English you need change this URL for downloading in your language.


after this, the second step is to unzip files within this case I use a shell command:

tar xvf latest.tar.gz

A little explaining of this command:

-c: Create an archive.
-z: Compress the archive with gzip.
-v: Display progress in the terminal while creating the archive, also known as “verbose” mode. The v is always optional in these commands, but it’s helpful.
-f: Allows you to specify the filename of the archive.

the third step move files from WordPress folder to project folder that you want to put your WordPress site: (The most common is to use the root folder, but in this example, I’m taking into account a server that can have multiple projects. Adjust the path in the best way for you)

mv wordpress/* /var/www/html/your-folder-project/

Next step deletes the zipped file that we do not need anymore and the WordPress folder.

rm -rf wordpress-4.9.7-pt_BR.tar.gz
rm -rf wordpress

In the next step, make a copy of wp-config-sample.php

cp wp-config-sample.php wp-config.php

next edit the information on wp-config with your database name, user, and password and change de-auth keys, in this step you can change the table prefix to for improving the security of your new WordPress Site. (If you work on localhost don’t forget to make debug true)

In my case, I’ll use nano editor, but you can use everyone that you preferred like vim and etc.

sudo nano wp-config.php

Security enhancements

Now improve the security of your folder and change de user owner, This configuration fixes the problem that asks for FTP Credentials.

cd ..
sudo chown -R www-data:www-data /var/www/html/your-project-folder/

Now you can change the security for folders and files permissions:

//For folders
sudo find /var/www/html/your-project-folder/ -type d -exec chmod 755 {} \;

//For files
sudo find /var/www/html/your-project-folder/ -type f -exec chmod 644 {} \;

* If you can learn more about permissions on files and folder in WordPress look ate the codex

That’s all for today any comments or questions, message me 🙂

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.