Introduction

Let me start off by explaining why I wrote this tutorial. I have been hosting with SliceHost for quite some time now, and decided to mess around with Wordpress a bit instead of building something from scratch. After downloading and installing Wordpress I noticed it wanted FTP login details to install plugins etc from the Admin interface. That was a problem as I only have SSH / SFTP acces. (I never setup an FTP server because it would just take up more memory, I have a 256MB slice/vps.) Anyways, I was in a bit of a pickle, I didn’t want to have to upload each plugin by hand and then manually install through the admin section. Then I found some tutorials on how to set up SSH support in Wordpress, but they were a bit unclear. Hence my reason for writing this.

Prerequisits

  • Apache 2
  • PHP5
  • MySQL5
  • Ubuntu (probably works on Debian too, or any deritive there of)
  • A document root ready to be used

If you haven’t installed Apache, MySQL and PHP5 yet make sure you do that first.
You can find many nice articles how to do so on SliceHost Articles.

Let’s get started

First we need to download and extract wordpress to where we want it installed.
If you are not going to be doing this from command-line (using ssh, on a linux machine) skip this step or read up how to install using another method Wordpress Famous 5 Minute Install

# Go to your home dir
cd ~

# Download the latest wordpress version
wget http://wordpress.org/latest.tar.gz

# Unpack the file, this should create the wordpress dir
tar xzf latest.tar.gz

# Go into the wordpress dir
cd wordpress

# Copy all the files to where you want to install wordpress (document root is easiest)
# BE SURE TO CHANGE THIS LINE
cp -R * /var/www/vhosts/username/domain.com/public

If this step doesn’t work due to permissions you might have to start the line above with sudo. Afterwards you will also probably need to set the right owner for the files, probably www-data:www-data (sudo chmod -R www-data:www-data /var/www/etc/etc/etc)

Now you run the installation.
Follow the guide from Step 5: Running the Install Script.

Now I will explain how to install libSSH2 which we will need to enable Wordpress to install Plugins / Themes from the admin section without using normal FTP.

# First make sure we have all necessary compilation software
sudo aptitude update
sudo aptitude install libgcrypt-dev build-essential autoconf

# Go to your home dir
cd ~

# Download the source to libssh2 v1.1
wget http://kent.dl.sourceforge.net/sourceforge/libssh2/libssh2-1.1.tar.gz

# Unpack the file
tar xzf libssh2-1.1.tar.gz

# Go to the unpacked directory
cd libssh2-1.1/

# Configure it for your system
./configure

# Compile
make

# Install
sudo make install

Now we will link Apache to libSSH2 by using PECL. This is the easiest way to do this, if you do not have PECL support you will want to look into that first. I’m not going to go into detail on how to install PECL, in Ubuntu it should be almost as easy as doing a: sudo aptitude install php-pear.

sudo pecl install -f ssh2

In my case I had to run it the following way because I run Zend Server CE and PECL is only callable directly:

sudo /usr/local/zend/bin/pecl install -f ssh2

Now you have to edit your php.ini to load the new extension. Open the php.ini file and search till you find Dynamic Extensions and add the following line:

extension=ssh2.so

Now it’s time to restart Apache and everything should be working! :D

sudo /etc/init.d/apache2 restart

When you now go to the admin page of your Wordpress installation you will see that you now have the option to use SSH for Plugin installs. Of course you will need your username & password for SSH to login. At times it’s a bit slow I’ve noticed, but don’t give up right away. If you don’t get an error message things should be OK ;)

I have tested this on Ubuntu Hardy and Jaunty without problems.