Download & Install WordPress Using SSH (Shell)
Getting a fresh WordPress installation up and running is usually a bit of a hassle. Even with various “automagic” tools out there now like Fantastico or SimpleInstall that often come bundled with cPanel, there is still the issue of setting up a database, making sure all the install files exist (or deleting the junk left over), and so on and so forth (plus, these “auto-install” tools are quite often using outdated versions of WordPress software). In order to have better control over their file structure and database settings, many webmasters still opt to install WordPress manually by downloading the latest zip file, uploading it over FTP, and then running through the setup wizard on the frontend using a web browser.
The truth is, there is a much better (faster, and cleaner) way to install WordPress by using SSH (also known as shell, or the Linux command line). Using this method, there is a much smaller chance of file corruption, no leftover installation files, and a generally cleaner and faster process. There is also the benefit of not having to visit various web pages, control panels, and so forth (although if you are using cheap shared hosting, getting SSH setup can be just as frustrating).
Assuming that you already know how to connect to your web server via SSH, and that you have successfully logged in, proceed to change to your website’s public directory (the domain where you want to install WordPress):
Next we are going to download (wget) the latest WordPress version to our public directory. Please note that depending on your SSH user’s privileges, you may or may not have to include the
sudo command. The second command below is what actually extracts the WordPress TAR.GZ file, so wait until download is complete before using it:
sudo wget http://wordpress.org/latest.tar.gz sudo tar xfz latest.tar.gz
At this point, all WordPress files should be downloaded and present within a new
wordpress directory. Of course, we must move these files “up” a level to your public root, so proceed to execute the command below:
sudo mv wordpress/* ./
Now let’s double check that all files are where they should be, using the “list” command:
After inputting the above command, you should see all proper WordPress files along with the now-empty
wordpress folder and
latest.tar.gz installation file. So, we can finish up by permanently deleting those two items:
sudo rmdir ./wordpress/ sudo rm -f latest.tar.gz
At this point, you can simply open your website in a browser and complete the WordPress installation, which includes the generation of a
wp-config.php file and a few basic settings for your new WordPress site. If you haven’t already created a MySQL database and user, you can do that via SSH (shell) as well.