“Getting” The Latest WordPress Installation From The Command Line

“Getting” The Latest WordPress Installation From The Command Line

Tutorial Details
  • Program: WordPress, Putty, Windows
  • Version (if applicable): 3.0 +
  • Difficulty: Moderate
  • Estimated Completion Time: 15 minutes

There are several ways to install WordPress, I have found that installing it via the command line is fast and efficient. Don’t worry, it’s easy! This is not an exhaustive tutorial on the command line, but simply how to copy the WordPress code on your server without downloading it to your computer.

First off – this is the Windows version of this tutorial as that’s what I’m working off of right now (and so are 75% of the readers here according to Brandon’s stats!). If anyone has notes on how this differs in an Apple OS environment, let us know in the comments!


Step 1 Set up Putty

First, I want to mention something that may be confusing to someone who hasn’t worked much with servers, or hosts. You may work on a windows based computer, but chances are, you website is running on a Linux server. While there are Windows servers, most run on Linux. Your host can tell you if you are not sure.

One of the most popular and simple ways to utilize the command line on Windows, is through a program called "Putty" (http://www.putty.org/). The installation of Putty is well documented, and simple. There are several different downloads at the Putty page, and unless you are well versed in various installation methods, I recommend using the putty.exe download. It will self extract and install when clicked.

Once you have installed Putty, it is easy to start a session. You click on the shortcut and you will see a dialog box. This dialog box allows you to control everything PuTTY can do. You don't usually need to change most of the configuration options. To start our session, all you need to do is to enter your domain name of the website you want to install WordPress on in the `Host Name' box. On the left menu, you will click on "data" under Connection. Where it says "Auto-login Username", you will put the username you use to login to your domain (used in FTP also).

Once you do this, hit Open, and another window will open. This is the Command Line. It will ask you for your password. You WILL NOT see the letters as you type in the password, but they are there.

QUICK TIP: I like to open Notepad, and type out the password, then copy and paste it into the command line window, since you can't see the password as you type it. This can save you from typing in the wrong password by accident. Also, on the command line, when you right click, it automatically pastes whatever you have copied, or if you have something selected in the command line, it will copy/paste it. For more information, you can reference the Putty website.

When you finish typing the password, hit ENTER. If you have used the correct information, you will see a dialog in the command window, that tells you the username you are using, the last login, and some other data. The you will see where you are in your host. This may look like: [username@domain ~]$. This is where you start typing. There is a good resource for basic commands at http://www.tuxfiles.org/linuxhelp/fileman.html

Important Note!: It is very easy to wreak havoc on the command line. With the wrong term, you can erase great amounts of data, and there is not an magical undo function, so take care with what you do. It is very important that you follow this tutorial exactly, and if you want to venture further into the command line, learn the basics at least first. Complete websites can be erased with a simple command. This is not an exhaustive tutorial on the command line. One resource is http://linuxcommand.org with a guided tour at http://linuxcommand.org/lts0040.php.


Step 2 Getting WordPress

Now the really fun part. Grabbing the current WordPress installation with a line of code!

Getting the current installation of WordPress without downloading it

Now, on your command line, make sure you are in the directory you want to install WordPress in. Remember, many hosts have a public_html or ht_docs folder that houses your "root", so make sure you are inside that if applicable. If you want to install in a subdirectory, if it doesn't exist, create it by typing

mkdir  foldername

(where foldername is the name of the directory you are creating). This stands for "make directory foldername". If the folder already exists, type

cd foldername

which stands for change directory foldername. Once you are in the directory you want to install WordPress in type:

wget http://wordpress.org/latest.tar.gz

and hit

ENTER

You will see a lot of lines of code go by, and voila! WordPress' latest version is now yours!

Now you need to extract it, you have what is called a “tarball”; which is much like a zip file. To extract it, type

tar -zxvf latest.tar.gz 

and it will extract the WordPress files. Now you will have a folder called WordPress with all the files in it. We need to take the files out of the folder, so now we will change directories to the WordPress folder. To do that, we type

cd WordPress

(change directory WordPress), and now we are inside the WordPress directory. Now we type

 move -i * ../ 

which will move everything (*) to the folder above the one you are in, which should be the directory you want your installation. We are still in the WordPress directory, so to check that the files moved, we can type

ls

which means show directory, and if we see nothing, we are good. If the files are still there, we did not succeed in moving them, so we will try again. Now that the files are moved, we can type

cd .. 

and we will be moved to the directory above (AKA parent), where the files are. Again, we can type

ls

to ensure they are there. If so, we can

 rm -rf WordPress

to get rid of the WordPress folder which is empty, and we are done. We can now go to the browser and begin the installation process.


Step 3 Setting Up Your Database

If you have not already setup your database for the WordPress installation, you will need to do that now. If you use Cpanel, you should have easy access to the MySQL database installer. Create the database, (I like to copy the username/password details to notepad for later). If you don't use Cpanel, and don't know where your database installer is, contact your host.

Step 4 Installation

Now point your browser to the address of the WordPress installation. You can now begin the installation of WordPress, and you didn't have to download the code! I will be writing more about custom installations in a later tutorial. For now, enjoy the time you save with your installations, and hopefully for some of you, this will open a whole new world of capabilities and learning!

Note: Want to add some source code? Type <pre><code> before it and </code></pre> after it. Find out more
  • Pingback: My Stream » “Getting” The Latest WordPress Installation From The Command Line

  • Xenonnn

    If one wants to know how to do this in a Unix environment such as OS X, one could go check out the article about syncing WordPress with a server – published on this very site about a week ago. As far as I remember it was a matter of just typing “wget http://wordpress.org/latest.zip” and then “unzip latest.zip” in the directory one’s in. Somehow in this tutorial, that takes a lot longer to say lol. As for the database part, I think Cpanel + CLI access is a very odd combination. Don’t most people who work locally on Windows use WAMP… Cpanel should be mostly for web hotels I think, but they don’t usually offer SSH access.

  • Thomas

    You might want to fix the third code-box (from the top), remove the anchor object and leave only the url.

    “wget http://WordPress.org/latest.tar.gz

    • http://jerryschrader.info Jerry Lee
      Author

      Yes, not sure why that came through, but that and the wget need to be different.
      Use the wget http://wordpress.org/latest.tar.gz
      and the mkdir FOLDERNAME
      where foldername is the name of the folder you are creating.

  • Nate

    Quicktip, if you’re on OS X wget needs to be installed first so it would be easier to use something like
    “curl -O http://wordpress.org/latest.zip

  • http://www.mayersdesign.com MayersDesign

    From there why not go grab your “usual” plugins with:

    cd wp-content/plugins
    rm hello.php
    wget http://downloads.wordpress.org/plugin/all-in-one-seo-pack.zip
    wget http://downloads.wordpress.org/plugin/google-sitemap-generator.3.2.6.zip
    wget http://downloads.wordpress.org/plugin/wp-smushit.1.4.1.zip
    find . -name ‘*.zip’ -exec unzip {} \;
    rm *.zip

    This forms a part of my general WP install script, which also downloads my biolerplate templates, writes the wp-config file, makes and mods the upload directories and more.

    Gotta love the command line!

    • http://jerryschrader.info Jerry
      Author

      Definitely, the command line, though a little taunting at first, is a powerful tool. I first came across it, when installing Magento for a client. I found that the usual install, which took forever, took less than a minute in the command line.

  • http://twitter.com/matiskay Edgar Marca

    You should check WP-CLI: WordPress Command Line Tools https://github.com/andreascreten/wp-cli

    Also, I wrote a bash script to download and setup wordpress https://gist.github.com/1207457

    Long Life to the Command Line

    • http://jerryschrader.info Jerry
      Author

      sweet! I saw install instructions at GIT for Linux and Mac, what about Windows?

  • http://www.matgargano.com mat gargano

    Just a heads up, I’m really only familiar with RHEL (RedHat Enterprise Linux) but this may apply to other distros. The command “move” in RHEL is “mv” so instead of “move -i * ../” the command to issue is “mv -i * ../”

    -MG

  • Pingback: Installing Wordpress with Command Line - Jerry Schrader | Jerry Schrader

  • Josh

    I know this post is old, but just wanted to share that when using PuTTY, I kept getting the message “move” is not a command… Turns out, I had to use the command “mv” instead.