Install Apache, MySQL, and PHP

Open a terminal window (Applications → Accessories → Terminal) and run the following command to install Apache, MySQL and PHP:

sudo apt-get install lamp-server^

When sudo asks for a password, simply enter the password you used to log in to the system.
Apt-get displays a list of the packages which are about to be installed. Answer yes or press enter to start the installation. Apt-get will then download and install the required packages.

Install additional software

Open a terminal window and run the following command to install the rest of the packages required to run Drupal and NetBeans:
(On Ubuntu 10.04 you need to enable the Partner repository to install the Java Development Kit: Go to System → Administration → Software sources. Click the Other software tab and enable the lucid partner repository. Click Close and then Reload to rebuild the list of available software.)

sudo apt-get install php5-cli php5-gd php5-xdebug sun-java6-jdk

This command installs the following packages:

php5-cli The PHP command-line interpreter
php5-gd GD support for PHP
php5-xdebug Xdebug support for PHP
sun-java6-jdk The Sun Java™ Development Kit

PHP

Open a terminal window and run the following command to edit the main PHP configuration file (this is not necessary on 10.04):

sudo vi /etc/php5/apache2/php.ini

Configure Apache

In order to use clean URLs in Drupal, you must enable the Apache rewrite module. Open a terminal window and run the following command:

sudo a2enmod rewrite

When the module has been enabled, you must restart Apache:

sudo /etc/init.d/apache2 restart

Apache will complain that it can’t determine the server’s fully qualified hostname. You can safely ignore this error message.
If you want to get rid of the error message, create a file called servername in the /etc/apache2/conf.d directory. Put the following line in the file:

ServerName drupal

Replace drupal with the hostname you chose for you machine during the Ubuntu installation process.

Configure MySQL

Next you must create a user in the MySQL database. This user will be used to access all your local Drupal databases. Open a terminal window and start the MySQL client (you will be asked to enter the password you chose when you installed MySQL):

mysql -u root -p

The command tells the MySQL client that you want to log in as the root user and that you want to be prompted for a password.
When you have logged in to the client, you can run the following commands to create a local drupal user and exit the MySQL client:

CREATE USER drupal@localhost IDENTIFIED BY ‘drupal’;
FLUSH PRIVILEGES;
EXIT

You can run the following command to make sure that the new user can log in:

mysql -udrupal -pdrupal

The user doesn’t have access to any databases yet. We will grant it database privileges when we set up the local Drupal sites.

Install Drupal

Before you can begin installing local Drupal sites you must create a local folder for them. Open a terminal window and run the following command to create a sub-directory in your home directory:

mkdir Drupal

We will use this as the base directory for all local Drupal sites.

From an official release Installing a local copy of an official Drupal release requires the following actions:

Download and unpack a stable release of Drupal
Create an entry in the hosts file
Create an Apache virtual host
Create a NetBeans project
Create a MySQL database
Run the Drupal installer
In the following sections each of these steps will be described in detail.

Download and unpack Drupal
Go to Drupal.org and download the latest version of Drupal. At the time of writing this is version 6.18. Save the file in the Drupal sub-directory in your home folder.

Next, open a terminal window and type the following commands to change to the Drupal sub-directory and unpack the downloaded file:

cd Drupal/
tar xzf drupal-6.18.tar.gz
rm drupal-6.18.tar.gz

You now have a copy of the latest version of Drupal in your Drupal folder.

Create an entry in the hosts file

To make it possible to run a number of local Drupal sites simultaneously, each site must have its own hostname. To add a new hostname, open a terminal window and run the following command to open the hosts file in a text editor:

sudo gedit /etc/hosts

Since we’re setting up Drupal 6.18, we’ll add the hostname drupal618to the hosts file and have it point at the local web server on the IP address 127.0.0.1.

Save the file and exit the text editor when you have added the hostname.

Create a Apache virtual host
Next we have to create a new Apache virtual host to handle requests to http://drupal618/. Open a terminal window and run the following commands to create a new virtual host definition:

cd /etc/apache2/sites-available
sudo gedit drupal618

It is a good idea to use the hostname as the name of the virtual host file. This makes it easier to manage a lot of virtual hosts.
Enter the following virtual host definition and save the file:

ServerAdmin webmaster@localhost
ServerName drupal618

DocumentRoot /home//Drupal/drupal-6.18

Options FollowSymLinks
AllowOverride All


The ServerName must match the hostname you added to the hosts file, and the DocumentRoot must match the name of the folder where Drupal is installed. Replace with the username you use to log in to the local machine (on this machine it got replaced by wulff).
When you have saved the file, you can run the following commands in a terminal window to enable the new virtual host and reload the Apache configuration:

sudo a2ensite drupal618
sudo /etc/init.d/apache2 reload

You can now access the Drupal site at http://drupal618/.

About these ads