Wednesday, December 18, 2013

Install latest WordPress on Debian Linux

This blog is built on the Google Blogger platform. My new blog however will switch to WordPress, and most likely be hosted by a third-party web hosting company. For now, I want to install WordPress on my home computer to be the staging server. This is where I experiment with new ideas before I upload the final contents to the production WordPress server.

My home computer runs Debian 7 (aka Wheezy) which includes a WordPress package, albeit a little outdated (3.6.1). This post is an overview of how to install the most recent WordPress release on Debian Wheezy.

The instructions below assume you have root privilege and command line access to the server. If you are using a web hosting company, the instructions will not apply because the web hosting company most likely will provide its own tools (e.g., cPanel).

Software Dependencies

To install and run the latest WordPress release, you need to have the following packages already installed.

  • Apache2
  • MySQL5 (version 5.0 or greater)
  • PHP5 (version 5.2.4 or greater)
  • SMTP server (e.g., exim4)

    Although a SMTP server is not required for installation, WordPress cannot send email without one.

It turns out that Debian Wheezy already includes the above software packages with the proper versions in the distribution. You just need to ensure that they are installed on your system.

To verify if a package is installed, use the dpkg command with -l parameter.

The following example indicates that PHP5 is NOT currently installed:

$ dpkg -l php5*
dpkg-query: no packages found matching php5*

If a package is already installed, the dpkg output will look something like this (edited to fit the screen):

$ dpkg -l mysql*
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                  Version             Arch    Description
+++-=====================-===================-=======-====================================
ii  mysql-client          5.5.31+dfsg-0+wheez all     MySQL database client (metapackage)
ii  mysql-client-5.5      5.5.31+dfsg-0+wheez amd64   MySQL database client binaries
ii  mysql-common          5.5.31+dfsg-0+wheez all     MySQL database common files
ii  mysql-server          5.5.31+dfsg-0+wheez all     MySQL database server (metapackage)
ii  mysql-server-5.5      5.5.31+dfsg-0+wheez amd64   MySQL database server binaries 
ii  mysql-server-core-5.5 5.5.31+dfsg-0+wheez amd64   MySQL database server binaries

Apache2

To install Apache2:

$ sudo apt-get install apache2

The Apache module mod_rewrite needs to be enabled. Otherwise, WordPress cannot be configured to have more user-friendly URLs. The exact procedure for enabling the module is covered in a later post.

MySQL5

To install MySQL 5:

$ sudo apt-get install mysql-server mysql-client

PHP5

To install PHP5 and related modules:

$ sudo apt-get install php5 php5-mysql php5-gd php5-curl

Notes:

  • php5-gd is only required if you want to enable CAPTCHA checking in your WordPress deployment.
  • Although php5-curl is not a prerequisite of the WordPress core, it is required by some very popular WordPress plugins such as Google Analyticator.

SMTP Server

exim4 is the default SMTP server on Debian wheezy. However, exim4 is configured out of the box for local email delivery only. A later post outlines the steps to configure exim4 to send email to external email servers through Google Gmail.

Install WordPress

  1. Download the latest WordPress tar-ball or zip file from the WordPress web site.
  2. Decompress the downloaded file to a temporary location on your hard drive.

    The examples below decompress the file to ~/tmp (the tmp sub-directory under your home directory).

    For tar-ball:

    $ tar -C ~/tmp/ -zxvf latest.tar.gz
    

    For zip file:

    $ unzip -d ~/tmp/ latest.zip
    
  3. Create database and database user.

    The following mysql commands create a database named wordpress, and a corresponding database user named wp, who has all privileges for the database. Customize with your own database name, user name, and user password.

    $ mysql -u root -p
    Enter password: 
    mysql> CREATE DATABASE wordpress CHARACTER SET utf8;
    Query OK, 1 row affected (0.01 sec)
    mysql> GRANT ALL PRIVILEGES ON wordpress.* TO 'wp'@'localhost' IDENTIFIED BY 'REPLACE_WITH_YOUR_USER_PASSWORD';
    Query OK, 0 rows affected (0.00 sec)
    mysql> GRANT ALL PRIVILEGES ON wordpress.* TO 'wp'@'%' IDENTIFIED BY 'REPLACE_WITH_YOUR_USER_PASSWORD';
    Query OK, 0 rows affected (0.00 sec)
    mysql> FLUSH PRIVILEGES;
    Query OK, 0 rows affected (0.00 sec)
    
  4. Create configuration file.

    Rename the sample configuration file.

     
    $ cd ~/tmp/wordpress
    $ cp wp-config-sample.php wp-config.php
    

    Edit ~/tmp/wordpress/wp-config.php.

    Locate the following lines, and replace the values with your own values.

    define('DB_NAME', 'wordpress');
    define('DB_USER', 'wp');
    define('DB_PASSWORD', 'REPLACE_WITH_YOUR_USER_PASSWORD');
    
    define('AUTH_KEY', 'put your unique phrase here');
    define('SECURE_AUTH_KEY', 'put your unique phrase here');
    define('LOGGED_IN_KEY',   'put your unique phrase here');
    define('NONCE_KEY', 'put your unique phrase here');
    define('AUTH_SALT', 'put your unique phrase here');
    define('SECURE_AUTH_SALT', 'put your unique phrase here');
    define('LOGGED_IN_SALT', 'put your unique phrase here');
    define('NONCE_SALT', 'put your unique phrase here');
    

    For the security keys and SALTs, replace the values with long, random strings of gibberish. For instance, something like t`DK%X:>xy|e-Z(BXb/f(Ur`8#~UzUQG-^_Cs_GHs5U-&Wb?pgn^p8(2@}IcnCa| is a good choice.

  5. Copy WordPress to the web server's document root directory.

    For Debian Wheezy, the Apache document root directory is located at /var/www. In the example below, I put wordpress under a subdirectory named myblog. The URL of the blog will look like http://localhost/myblog.

    $ sudo mkdir /var/www/myblog
    $ sudo cp -pr ~/tmp/wordpress/*  /var/www/myblog/
    
  6. Change owner/group of WordPress files to the web server user.

    To use the one-click upgrade feature of WordPress after the initial install, the web server must be granted the proper file permissions to update the WordPress-related files.

    First, identify the user under which the Apache web server executes.

    $ ps aux |grep -i apache
    ...
    www-data  7012  0.0  0.1 169576 27472 ?        S    08:59   0:01 /usr/sbin/apache2 -k start
    ...
    

    Then, modify owner and group of WordPress files to that user, www-data.

    $ sudo chown -R www-data:www-data /var/wwww/myblog
    [sudo] password for peter: 
    
  7. Run the install script.

    Open a browser, and enter this URL:
    http://localhost/myblog/wp-admin/install.php

  8. Fill in the information, and click Install.
  9. Login using the credentials you just created.

    The WordPress dashboard appears.

The WordPress web site claims that if you know what you are doing, the install will take only 5 minutes. For Debian Wheezy, given that all the pre-requisite software dependencies are already satisfied by the base distribution, this claim may not be that far from the truth.

Let me know your experience.

Below are my other posts on WordPress:

Thursday, December 12, 2013

How to install pre-packaged software collections after the initial install

During a fresh Debian install, you can specify the installation of pre-assembled collections of related software packages that together provide a high-level functionality, for example, Web Server. The install screen may look something like this:

If you select Web server, the install program will take care of installing the right packages for you. You don't need to know the names of the individual web server packages. The install program will install Apache2 automatically.

What to do if you have declined to install a collection, only to realize later that you do need it?

After the initial install, you can always execute the tasksel command. It brings up the same install screen as above as if you are arriving at the package configuration step in a text-based install.

$ sudo tasksel

If your base system does not have the tasksel command installed, install it like this:

$ sudo apt-get install tasksel

It is most comforting to know that you need not be perfect at install time in predicting the required software collections. You can always add a software collection using the tasksel command after the initial install.

Sunday, December 8, 2013

Dual booting Debian Wheezy and Windows 7

My ASUS CM6870 desktop computer came pre-installed with Windows 7. The following outlines the steps to set up dual boot of Debian Wheezy and Windows 7.

  1. Re-partition your hard drive.

    Initially, Windows takes up the entire hard drive. Two 'letter' drives were allocated on this disk: C, and D. The C: drive holds the Windows system with plenty of unused space. The D: drive stores user data, and is practically empty.

    Before installing Linux, you need to re-partition the hard drive to allocate space to Linux.

    I used the native Windows 7 Disk Manager for the task. Specifically, I shrunk the C: drive and deleted the D: drive entirely. Be sure that you leave enough unused space in the C: drive to hold future user data.

  2. Create Debian install media.
    • Download the install ISO image from the Debian web site. I chose the Live install ISO.
    • Burn the ISO onto a CD or DVD.

      If you are going to dual boot with Windows 7, don't copy the iso onto the USB stick. The Debian installer running from the USB stick boots in EFI mode. Your Windows 7 system was most likely installed in BIOS mode. As a result, the Debian installer may not detect the Windows 7 partitions. You may not be able to boot into Windows 7 if you run the Linux installer from the USB stick.

  3. Insert Live CD/DVD and reboot.
  4. In the boot menu, select Graphical Install, and follow the on-screen instructions.
  5. At the Partition Disks step, select Manual.

    To preserve the existing Windows partitions, manually configure the disk.

  6. While installing the GRUB bootloader, the installer will detect other operating systems residing on the hard disk.

    In this case, it does detect a Windows operating system: Vista (rather than Windows 7). That is 'normal' for Windows 7. Click Continue.

  7. Continue with the instructions on the screen until you finish the installation.

The next time you reboot the computer, the bootloader will display a menu which includes Windows 7 as well as Debian Wheezy.

Wednesday, December 4, 2013

KDE4: how to relocate icons on the Plasma desktop

As a long-time GNOME user, I had to overcome some initial learning curve to the KDE4 desktop environment. My first puzzlement is how to re-position icons on the desktop.

I tried to click and drag the icon. However, clicking the icon immediately runs the associated application. That was not my intention.

The trick is to click on the side panel which only appears when you mouse over the icon. Drag the side panel to the target location, and release.

Be careful to only click the background of the side panel, not any item on the panel. Clicking an item on the panel will execute the associated action, such as removing the icon, but will not relocate the icon.

While the technique may not be that intuitive to many users, I do not consider it a show stopper to using KDE4. For me, the jury is still out on whether to use KDE4 regularly.

Please share any pointer to help GNOME users to get comfortable with KDE4.

Sunday, December 1, 2013

KDE4: Show the Trash Can and Home icons

My earlier post shows how to display the Trash Can on the GNOME 3 desktop. Not to be out-done, KDE4 also hides the Trash Can by default. This post outlines the steps to enable the display of the Trash Can on KDE4. I'll also show how to set up the Home directory icon on the KDE4 desktop.

To display the Trash Can:

  1. Click anywhere on the desktop background.

    A menu is displayed.

  2. Click Add Widgets.
  3. Search for the trashcan widget by entering 'trash' in the search box.
  4. Double click the trashcan widget returned by the search.

You now have a Trash Can displayed on your desktop. You can drag & drop files onto the trash can to delete files.

To set up a Home directory icon on the desktop:

  1. Run your favourite File Manager (say Dolphin).
  2. Navigate to your Home directory (/home/username/).
  3. Drag and drop the Home directory onto the target location of the desktop that you want the icon to appear.

    A widget menu appears.

  4. Click Icon to create an icon for your Home directory.

    An icon labelled peter is created.

  5. Clicking the icon labelled peter runs the Dolphin file manager and opens your Home directory.

The icon labelled peter is essentially your Home icon. It'd be even better if I can rename the icon to Home. But, I can't find a way to do it. The user name suffices.