A huge majority of web hosting companies use Linux servers to host their clients’ web sites. There are plenty of good reasons why Linux is the preferred operating system for a web hosting server, among which are:
- Linux is a stable and secure operating system
- There’s a wide variety of Linux distributions to choose from; including free community supported ones, as well as those which offer support contracts
- Linux supports a huge variety of hardware platforms and devices
- The Linux kernel undergoes a constant improvement and enhancement process
- Linux is open source, thus making the code underlying it probed by thousands of eyeballs dedicated to making it better
One feature that makes Linux servers particularly useful is that you can perform remote administration on it via SSH. SSH is a command line interface that provides a secure and encrypted way of connecting to a remote server.
If you’re planning to host your web site on a Linux server, never under any circumstances go with a hosting provider that doesn’t provide SSH access to their servers. This is a tell-tale sign of lazy administration and a misplaced preference for security by obscurity.
You need a software called SSH client to connect to an SSH-enabled host. Most Linux distributions include the OpenSSH SSH client. For Windows users, I recommend grabbing PuTTY, a free, open source SSH client.
Here are some cool things you can do with an SSH-enabled server:
Download and Install Scripts Quickly
I’m going to give you a step by step example of how I install WordPress via SSH:
Move to the temporary directory
What this command does is to download the latest version of WordPress. Once the download is finished, I execute the following command;
tar -xzf latest.tar.gz
This extracts the content of the WordPress archive file to the current directory
I can then move or copy the files over to my web directory.
The obvious benefit of using wget to retrieve the file, followed up by using tar to extract it is that I’m using my server’s fast internet connection to retrieve the WordPress archive file and extract it directly on the server itself within seconds!
I’m sure those who don’t have shell access will have to go through a process similar to this:
- Download WordPress from wordpress.org
- Watch the download status progress from 0% to 100%
- Extract the files and folders in the archive to somewhere on your hard disk
- Upload the extracted files and folders on to yor server via FTP
- Watch the upload status progress from 0% to 100% for each file and folder
- Decided to go for coffee because it takes so damn long!
- Came back only to find out that your transfer was interrupted and you have no idea which files have been uploaded and which haven’t
- Repeat the upload process praying that it’s successful this time
So which method would you prefer? 😉
Perform Simple Editing of Web Files
Imagine this scenario;
- You’ve just uploaded a wonderful theme you spent days creating
- You activated the theme on your site and smile proudly as your web site is skinned by your latest creation
- “Eh, what’s this? Bargh, I forgot to add an
a:hoverstyling for the theme’s stylesheet!”, you suddenly noticed
- You fixed the stylesheet and uploaded it again, overwriting the previous version
- Refreshed the page and smile as you play around with the link hover effect.
- You then scroll to the bottom of the page and realised that you forgot to set the background colour for your footer… Bargh!
Sounds familiar? You must be using a host which doesn’t have shell access (this is another way to describe an SSH-enabled host). Sucks to be you.
With an SSH-enabled host, you will be able to perform simple text file editing using vi or any other command-line text editor your hosting provider may have installed for you. I’d recommend that you familiarise yourself with the basics of using vi as it is almost surely installed in any Linux or other Unix-like operating system. Here are some links which may help you.
I’ll be the first to admit that the vi interface will be damn intimidating for first timers. My advice is, stick with it and persevere. The process may be a little painful at the start, but believe me, the time you’ll save once you’ve understood the basics of vi is priceless.
If you still find yourself lost within the vi interface and if you’re in luck, you might find that your host has other command-line editors such as nano and (heaven forbid) emacs, which you could find more at home with.
Manipulate Files and Directories Easily
Let’s say you want to have a directory currently residing on your web server to be copied somewhere else. I’m sure those who have shell access to their server would be grinning as they read this. Because for us, the process is as simple as running this command:
cp -R /path/to/the-directory /new/path/to/the-directory
If you only have FTP access to your server, you’d probably have to do this:
- Download the directory to your computer
- Optionally rename the downloaded directory to something else
- Upload the folder to its destination on the server
Even the process of renaming files can be done easily using SSH:
mv current_file_name new_file_name
What if you want to have an automatically updating text file that shows the source of a particular PHP script, for example. For me, I’d create a symlink with a
.txt extention to the source script using the following command:
ln -s script.php script.txt
Now, everytime I modify the
script.php file, I will get a mirror of the file’s content in
script.txt which can be viewed instead of interpreted by the web server.
If you think what I’ve mentioned above are amazing, let me tell you that I’ve barely scraped the surface of how having an SSH-enabled web server can benefit you as a webmaster.
Have anything to say about this post? I look forward to your comments!