Installing and Configuring Apache, PHP, MySQL and Drupal on Ubuntu

Zyxware default image4
Most of the web based systems that we build at Zyxware uses Drupal as the content framework. The following are the steps involved in setting up Apache, PHP, MySQL and Drupal on a freshly installed Ubuntu 8.04 system. If you follow the instructions you should be able to set it up as is but if you face problems let us know and we will try to help you.
This is divided into subsections each dealing with a specific task.

1. Apache2 Server Setup
2. Installing MySQL and PHP5
3. Installing Drupal & Configuring Drupal
4. Clean URLs Configuration in Apache2 for Drupal
5. Other Tweaks

Apache2, MySQL, PHP Setup

1. Run the following command to install apache on your machine
sudo apt-get install apache2 libapache2-mod-php5

sudo apt-get install mysql-client mysql-server mysql-query-browser mysql-admin mysql-navigator php5-mysql php5-gd
sudo /etc/init.d/apache2 restart

2. Install PHPMyAdmin. After this, make changes in the confinguration file to support PHPMyAdmin. You can skip this step if you prefer to use MySQL GUI based administration.

sudo apt-get install phpmyadmin

sudo gedit /etc/apache2/httpd.conf

At the bottom add the following

# Enable PHPMyAdmin
Include /etc/phpmyadmin/apache.conf

sudo /etc/init.d/apache2 restart

3. Enable usedir module in apache2 to allow URLs of the following format http://localhost/~username. Also enable mod_rewrite to allow for Drupal Clean URLs

cd /etc/apache2/mods-enabled
sudo ln -s ../mods-available/userdir.load
sudo ln -s ../mods-available/userdir.conf
sudo ln -s ../mods-available/rewrite.load
sudo /etc/init.d/apache2 reload

4. Create folder /home/<username>/public_html -- > this is the folder which we are going to use as the document root for local development. So you will be accessing your local websites as http://localhost/~username/sitename

5. Edit /etc/apache2/mods-available/userdir.conf and change the AllowOverride line to just read AllowOverride All

Install Drupal

1. Download the latest drupal version from http://drupal.org and extract it to the folder of your choice under ~/public_html. Say ~/public_html/drupal

2. In the drupal folder change permissions of /default/settings.php to 766 to make it writable to by all users

3. Once the things has been completed access the directory through the browser. If you had named the drupal folder as drupal you can now access it as http://localhost/~username/drupal

4. Create a database named drupal_db (your choice) in MySQL through the MySQL Query Browser or throuh the mysql command line client for Drupal. Also create a user for drupal. You can do by running the following query
GRANT ALL PRIVILEGES ON drupal_db.* TO 'some_username'@'localhost' IDENTIFIED BY 'some_pass' WITH GRANT OPTION;

5. After a couple of simple questions to be answered Drupal should be up and running.

Configuring Drupal

Clean URLs converts the querystrings that come in a normal URL into an integral part of the URL. By enabling Clean URLs you would improve the readability of the URL and also increase your google page ranking. We had already enabled mod_rewrite above. So we just have to make sure that Clean Urls is enabled in Drupal administration

Other Tweaks

Install sendmail to be able to send out mails from drupal.
sudo apt-get install sendmail


Edit: We have updated the information about enabling userdir module and its configuration. Thanks Kirri