Set up wordpress on Debian

We can download WordPress straight from their website:


The next command will now download the zipped WordPress package straight to your user’s home directory:

tar -xzvf latest.tar.gz


Create WordPress Database and User

After we unzip the WordPress files, they will be in a directory called “wordpress” in the home directory.

MySQL Directory For WordPress
We need to take a moment and create a new MySQL directory for WordPress. Go ahead and log into the MySQL Shell:

mysql -u root -p

*Now let’s make the database.

This tutorial will call its database wpdatabse for simplicity’s sake– feel free to give it whatever name you choose):

CREATE DATABASE wpdatabase; Query OK, 1 row affected (0.00 sec)

Then we need to create the new user. You can replace the database, name, and password, with whatever you prefer:

CREATE USER wpsuser@localhost; Query OK, 0 rows affected (0.00 sec)

Set the password for your new user:

SET PASSWORD FOR wpuser@localhost= PASSWORD("password"); Query OK, 0 rows affected (0.00 sec)

Finish up by granting all privileges to the new user. Without this command, the wordpress installer will not be able to start up:

GRANT ALL PRIVILEGES ON wordpress.* TO wpsuser@localhost IDENTIFIED BY 'password'; Query OK, 0 rows affected (0.00 sec)

Then refresh MySQL:

FLUSH PRIVILEGES; Query OK, 0 rows affected (0.00 sec)

Exit out of the MySQL shell:



Setup the WordPress Configuration

The first step to is to copy the sample wordpress configuration file, located in the wordpress directory, into a new file which we will edit, thus creating a new usable wordpress config:

cp ~/wordpress/wp-config-sample.php ~/wordpress/wp-config.php

Then open the wordpress config:

sudo nano ~/wordpress/wp-config.php

Find the section that contains the field below and substitute in the correct name for your database, username, and password:

// ** MySQL settings - You can get this info from your web host ** // /** The name of the database for WordPress */ define('DB_NAME', 'wpdatabase'); /** MySQL database username */ define('DB_USER', 'wpuser'); /** MySQL database password */ define('DB_PASSWORD', 'password');

Save and Exit.

Copy the Files

We are almost done uploading WordPress to the virtual private server. The final move that remains is to transfer the unzipped WordPress files to the website’s root directory.

sudo rsync -avP ~/wordpress/ /var/www/

Finally we need to set the permissions on the installation. First, switch in to the web directory:

cd /var/www/

Give ownership of the directory to the apache user.

chown -R www-data: /var/www/

(or whatever your wordpress directory is called)  If you mess up this step, no biggie, you can always go back and fix it later.  But the way you’ll know you’ve got it wrong is when you go to install your first plugin.  If you get prompted for an FTP password, you need to try this again.  If the above doesn’t work, it’s probably because www-data is not the apache user.  To find this out, install a file named who.php somewhere on your wordpress file.  The file contents should be:

<?php echo(exec(“whoami”)); ?>

When you hit that file in a web browser, it will list your apache user.
From here, WordPress has its own easy to follow installation form online.

However, the form does require a specific php module to run. If it is not yet installed on your server, download php-gd:

sudo apt-get install php5-gd

Posted in Exclusives | Leave a comment

Turn an old laptop into a web server

You’d be amazed at what a good server an old laptop makes.  Here’s how:

Download Debian and create a bootable usb stick

Your old laptop probably has such a clunky operating system (we’ll fix that!) that you’ll want to do this part on your new laptop.  Here’s how to do that on a mac:

1. Download the latest version of Debian (the backbone of 90% of the world’s websites).  So long as you have an internet connection in your home, you should choose the smaller (tiny) installation.  You’ll also need to choose the version of Debian that is best for your hardware.  For my old asus eee PC, I chose the amd64 (this is also the likely choice for your hardware).  When the file downloads, move it to your desktop.

2. Open Terminal and paste this into the command line:

hdiutil convert -format UDRW -o /PATH/sourcefile.img /PATH/sourcefile.iso

3. Select the downloaded Debian file on your desktop and press command-i.  Copy the path beside ‘where:’ in the window appears, copy and paste it into your terminal window to replace both /PATH/ in the above.  Do the same to replace sourcefile.iso with the name and extension of the file and sourcefile.img with the name of the file followed by img.  Hit return and watch as terminal creates your bootable file from the iso.  Mac will add the ‘.dmg’ extension automatically to the end of the file.  You don’t have to change it…it doesn’t make a difference.

4. In terminal, execute:

diskutil list

5. Look at the list of disks.  Now insert a usb drive into an open port.  Execute the above command again and note the name of the usb drive.

6. Run diskutil unmountDisk /dev/diskN (replace N with the disk number from the last command).

7. Execute sudo dd if=/PATH/sourcefile.img.dmg of=/dev/rdiskN bs=1m (replace /PATH/sourcefile.img.dmg with the path where the image file is located).

  • If you see the error dd: Invalid number ’1m’, you are using GNU dd. Use the same command but replace bs=1m with bs=1M
  • If you see the error dd: /dev/diskN: Resource busy, type diskutil unmount /dev/diskN (replace N with the disk number)

8. Execute “diskutil eject /dev/diskN” and remove the flash drive.

Install Debian on your old laptop

1. Make sure your old laptop is completely shut down (you may want to unplug and remove the battery, then restore the power source)

2. Plug the usb stick into your old laptop and hold down the escape key while you boot it up.

3. Select the usb stick in the menu that appears and hit return.  (If you don’t see your usb as an option, reboot again.)

4. Select ‘Install’ from the Debian installation menu.  This will take up to an hour and you’ll occasionally need to make some choices, so grab a cup of coffee.  All the choices are fairly straight-forward (and the default is usually the best option).  When it asks whether you want to install through a proxy, answer no.  When it asks you if you want to install any add-ons, select them all (even though this is not the default.  For all usernames and passwords, use something you’ll remember!  For the partition, I recommend filling the whole space (no partitions).  In the past, you needed to build out a partition for things like swap space, but linux now does this automagically using the file space.

Create your local server

1. Now you’ll want to place your laptop where you want it to live permanently (with the lid open at all times, since laptops ventilate through the keyboard).  I’d suggest plugging it directly in to your router and turning off wifi.  I’d also suggest you remove the battery completely.  Both of these measures will allow it to run all the time without using too much power or burning out your battery, and it’ll help keep the laptop cool all the time.  Reboot the machine.

2. You should now see a standard desktop environment.  It may be a little unfamiliar if you’ve never used a linux box before, but it’s pretty much like mac.  You can swipe up to the upper left corner and get a search box, just like you’d get with the spotlight on your mac.  Type terminal there and select the Root terminal.

3. Find the local IP address address assigned automatically by your router.  You can do this by typing this command into the terminal:


4. make a note of the inet address next to eth0 (your ethernet port)

Remote log in to your server

1. Now, on your new laptop, open up terminal and type:


2. Type “Y” when it asks if the key is ok and then type your password, when prompted.

3. You’re in!  To test your new powers, you’re going to remotely shut off the screen to your new server (this will also allow it to stay running all the time with minimal power use)  In terminal, type:

sudo apt-get install vbetool
vbetool dpms off

Open up your ports to the world

Although all devices in your home have a unique local address, they all look the same to the outside world, which means that no one can see them.  To change this, you’ll have to access your router settings.  This may vary depending on your internet provider, but in most cases this can be achieved by pointing your web-browser to the IP address of your home router, which is usually the same as your computer’s INETADDRESS, except you should replace the number(s) after the last dot with a 1.

1. From a web browser, type in the IP address of your router.

2. Log in.  If you don’t have credentials, call your internet provider.

3. Once you’re in, look for “Port Forwarding” (usually this is buried in the firewall settings).

4. Select your server (same INETADDRESS as before, probably listed in a dropdown under a heading like “Create new port forwarding rule”)  Alternatively, you may need to type in the INETADDRESS manually.

5. Select http (web) from the ‘application to forward’ list and save the new settings.  This will make your server the default when people try to access your machine from the outside world.  Alternatively, you may need to manually type in the port.  Port 80 is your best bet.

6. To access the new webpage from your server, google what is my IP and copy and paste the IP into your browser window.  You should see a page with “It works!” at the top.  (when you’re ready to edit this page, you’ll find it listed as /var/www/index.html in your server.)

7. If you want to access your root terminal from outside your wifi network, you’ll need to repeat the steps above to set up ssh port forwarding.  This will also allow you to use Filezilla or an IDE such as Komodo Edit from a remote connection (so long as you set up the client as sftp rather than ftp).  The steps are the same, except you should select SSH (or Port 22) in step 5.  The same goes for mySQL (3306).

Set up the rest of the LAMP stack

To run most web applications (such as wordpress), you’ll want the LAMP stack (Linux, Apache, MySQL, PHP).  You’ve already set up the first two.  Now just add mySQL (your data center) and PHP (your data mover).

1. For mySQL installation, login as root into your terminal and run:

apt-get install mysql-server

2. Next, run:


3. Answer yes to all the questions.

4. To install PHP, run:

 apt-get install php5 php-pear php5-mysql

5. Next, restart apache:

service apache2 restart

6. And test it by setting up a info.php file in /var/www

nano /var/www/info.php

7. Add the line:


8. Save and exit, and point your web browser to YOURIPADDRESS/info.php.

9. You may need to adjust permissions on various folders to, for example, execute linux commands from php.  Executing ‘chmod 777 -R /var/www’ from command line should do the trick.

Open up MySQL db for remote administration

If you want to use a db admin tool (such as MySQLWorkbench) to work on your MySQL db remotely:

1. type ‘nano /etc/mysql/my.cnf’ in the command line

2. comment out (put a # in front of) the line ‘bind-address =′ and close and save the file, as before.

3. type ‘mysql -u username -p’ in the command line.

4. enter your password at the prompt.

5. From the mySQL prompt, execute ‘USE mysql’

6. From the mySQL prompt, execute ’SELECT * FROM user;’

7. Inspect the output.  You should see a 40 character hex password hash (probably copied in three or four places).  mouse over it and select command-C to copy the password hash to your clipboard.

8. From the mySQL prompt, execute ‘GRANT ALL PRIVILEGES ON *.* TO ‘root’@'%’ IDENTIFIED BY PASSWORD ‘paste hex password hash here’ WITH GRANT OPTION;

9. From the mySQL prompt, execute ‘exit’

10. From command prompt, execute ‘/etc/init.d/mysql restart’

A note about installing other web software (for nubes like me):

apt-get will work for most common packages, such as wordpress.  You should know, though, that many packages are not available in apt-get, and those that are are sometimes outdated.  Most of these packages will give you the (only slightly) more involved custom compile (make install) process.  In that case, there are two things to remember:

1. make sure you’re in root (or using sudo)

2. make sure you’re in the /usr/bin folder when you start the install.

Posted in Exclusives | Leave a comment

Instant Queue: Children of Heaven

On the surface, Children of Heaven is the simple story of what happens when a poor Iranian child loses his sister’s shoes, but dig deeper and you find a timeless parable of kindness and virtue even in the hopelessness of poverty.

Sumptuously filmed on the streets of Tehran, the film presents the question of why people remain poor in spite of social programs and noblesse oblige.  Outside the context of the story, the premise — two children going to great lengths to get by with only one pair of shoes between them — would seem absurd.  As absurd, perhaps, as the many minimum wage workers in America who will pay $60 per night to live in a hotel when they could live much more cheaply in an apartment.   Read More »

Posted in Exclusives | 1 Response