Install WordPress in 5 Minutes – Using the Command Line

     

So you want to Install WordPress quickly? There are already official guides how to achieve this – but let me refine this a bit and present you my guide, using command line to install WordPress in five minutes!

Requirements:

SSH-enabled hosting. We’ll install WordPress with the command line, so having SSH access to your web hosting is necessary.

PuTTY. A simple Windows tool to access your hosting server via SSH command line. Download it here and place it on your desktop and you’re good to go. It’s already an executable so you don’t have to use any installers with PuTTY.

Database. Obviously, because WordPress uses database to store its files.

The procedure:

  1. Login to your server via SSH (PuTTY program)
  2. cd <your public_html directory>
  3. wget http://wordpress.org/latest.zip
  4. unzip latest.zip
  5. mv wordpress/* .
  6. mv wp-config-sample.php wp-config.php
  7. nano wp-config.php (change DB_NAME, DB_USER and DB_PASSWORD)
  8. Done

The procedure explained:

Step 1 – Login to your server with PuTTY. Use your domain name on the Host Name (or IP address) field. Moving on to the Port section, this is 22 by default but can also be something else, depending on your host’s configuration. Finally, the correct Connection type is SSH (the secure way) in this case.

Hit Open and you’re asked for credentials. They are your SSH username and password. You can ask your hosting provider if you don’t know them. When you type in the password, it won’t be shown to you but will of course be received by the server. So don’t panic.

Step 2 – Now you’re on your hosting server’s command line, also known as shell. It looks like a big black box. Change the directory to your document root, with the cd command. In other words, to the directory from where Apache (the web server you probably have) reads the files and presents them on www.yourdomain.com. Chances are this directory is called public_html.

cd <your public_html directory>

Step 3 – Now we’re in the right directory. It’s time to download WordPress, the command line style, with wget tool. It downloads whatever file you want from Internet. In this case, we want to download the latest WordPress zip file.

wget http://wordpress.org/latest.zip

Step 4 – Now that the WordPress zip file is downloaded, it’s time to unzip it:

unzip latest.zip

The command unzips a lot of files to a directory called wordpress.

Step 5 – Now our WordPress installation is available on www.yourdomain.com/wordpress/. Well, we don’t really want it like that, do we? We want it to be available directly on www.yourdomain.com. So we must move the WordPress files to public_html, the directory we’re currently in. We’ll do this all with the mv command.

mv wordpress/* .

The command moves everything (*) from the wordpress/ directory to the current directory (.) which is public_html in this case.

Step 6 – Every file is now in the right directory. We still have to let WordPress know your database credentials. Otherwise, it couldn’t write or read any posts! The default WordPress configuration file is called wp-config-sample.php, but in reality WordPress system only reads configurations from a file called wp-config.php. So we must rename the sample file. We’ll use the mv command that was also used on the previous step:

mv wp-config-sample.php wp-config.php

Step 7 – The configuration file now has a correct name. Next we’ll open it with the nano text editor:

nano wp-config.php

The wp-config.php file will now open, ready to be edited. Scroll down a bit with the down arrow on your keyboard until you start seeing lines like define(‘DB_NAME’, ‘database_name_here’);. There are four lines we are interested in:

DB_NAME – The MySQL database name you want to use for WordPress. The database should already exist, it’s not being created here.

DB_USER – The username associated with the above MySQL database.

DB_PASSWORD – The password associated with the above MySQL username.

DB_HOST – The hostname of your MySQL server. In most cases, it’s localhost (the same host you’re using the PuTTY on).

After editing those fields, save the file and exit back to command line. This can be initiated by pressing Ctrl + X. After that, type “Y” to the question nano asks you about saving and hit Enter to accept the default name, wp-config.php, which nano offers.

Step 9 – Now you are done, go to www.yourdomain.com to see your blog!

Conclusions

This procedure is, in my opinion, the fastest and most convenient way to install WordPress. However, if you don’t want to use command line and have cPanel installed, chances are there’s also an automated way to do all this in your cPanel settings. Pick your poison – I prefer the good old command line way.

Share Your Thoughts

Have something to say about this post? Then say it by filling the form below!

(required):

: