Normally we do self depoyment to WordPress, we usually do it through FTP – download the ZIP file of WordPress, uncompress it on your own device and then upload the whole content under the folder to the remote server via FTP.

The question is – can we still do a self deployment of WordPress without the FTP?

The answer is YES – we can do it via the Shell of remote server over SSH. Nowadays, most hosting providers offer the SSH command lines, and we can benefit from it without introducing any potential security issue by using FTP.


Assume we will get the “lastest” version of WordPress to run with MySQL database. And also, you have already set up the SSH connection to the remote server.

If you have any issue to set up the SSH, you may consult your own hosting provider.

Step 1 – Setting up MySQL database

Be sure you have installed MySQL correctly to the remote server.

Login as root user to MySQL

$ mysql -uroot -p

Enter the password based on the prompt.

Create a new user account

Usually, when we deploy an instance to the server, we will set up a “dedicated” MySQL user account for this instance to run. If you are willing to use any existing account, you can skip this part.

mysql> create user 'newuser'@'localhost' identified BY 'password';

Grant the connection access to mySQL for this user

mysql> grant usage on *.* to 'newuser'@'localhost' identified by 'password';

Create a new database

mysql> create database new_database;

Grant the user access to this database

mysql> grant all privileges on new_database.* to 'newuser'@'localhost';

Step 2 – Download WordPress

Go into a “temp” folder on the remote server, then download the latest version of WordPress into this folder and uncompress it.

$ cd /tmp/wordpress_download
$ wget  
$ tar xfz latest.tar.gz

Now, we have a new subfolder “wordpress” under the folder “/tmp/wordpress_download”. Then we move all the content under this folder to the place we want to put the wordpress site in. Usually, it will be under the folder “/var/www” if you are running Apache on the remote server.

$ mv wordpress/* /var/www/new_wordpress/

Then you can delete the files you just downloaded.

$ rmdir ./wordpress/
$ rm -f latest.tar.gz

Step 3 – Install WordPress

Based on the Step 1 and 2, we have had the WordPress working folder setup as well as the corresponding MySQL database. Now we need to do the configuration to WordPress, in order to link the database to WordPress.

Go into the WordPress working folder, and edit the file “wp-config.php“. If it does not have one, you can “copy” one from the file “wp-config-sample.php“.

$ cp wp-config-sample.php wp-config.php
$ vi wp-config.php

In the file, configure the database info that you need to use for WordPress.

/** The name of the database for WordPress */
define('DB_NAME', 'database_name_here');

/** MySQL database username */
define('DB_USER', 'username_here');

/** MySQL database password */
define('DB_PASSWORD', 'password_here');

/** MySQL hostname */
define('DB_HOST', 'localhost');

/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8');

/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', '');

Step 4 – Website Setup

Now, your WordPress instance has been setup the connection to the MySQL database, It is rerady to run the instance and finish other setup of WordPress (like name, admin account etc.)

You may also need to set up the domain name of the WordPress instance. You can refer it to other resources depending on the actual HTTP server your remote server runs.

Leave a Reply

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

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>