Drupal development server install

How to install and configure a development server for Drupal projects on Ubuntu 8.04 LTS Server, as a LAMP server in virtual machine.

8.04 LTS Server install

We install here the LAMP and OpenSSH Server of Ubuntu 8.04 LTS Server.

The installation procedure of Ubuntu starts with choosing your preferred language (it's english in this tutorial).

the install screen of Ubuntu
the install screen of Ubuntu

At partitioning, I'm using the default, automated method, so partitioning the whole disk. Others can prefer the manual method, and define three partitions: the swap, the root and the home.

Don't forget to notice the name and password of your first user, you will need it later!

the first user on the LAMP
the first user on the LAMP

At the software selection, select the LAMP and OpenSSH server options, and just than continue.

the LAMP and the OpenSSH server options
the LAMP and the OpenSSH server options

Then it asks for the password of the MySQL root.

the MySQL root
the MySQL root

Some seconds later, the install is completed, and you can reboot. You can left your "CD" in the CR-ROM.

LAMP install completed
LAMP install completed

And at the end, log on with your user and password you noticed before.

here we are: you can login
here we are: you can login

So you have an Ubuntu LAMP server out of the box, let's add some supplementary packages we need for Drupal develpoment, like phpMyAdmin, the GD library of PHP, and so on.

Additional components

Here we are going to upgrade to the latest packages, install Webmin and phpMyAdmin, the NFS common module, and some supplementary modules to PHP. At the end of this session, we will have all the components we need for the Drupal development environment.

  1. Upgrade standard packages
  2. First check whether new update packages are available to 8.04 LTS Server. To get the latest packages from Ubuntu, type to your terminal:

    sudo apt-get update && sudo apt-get upgrade
    sudo apt-get autoclean && sudo apt-get autoremove

    The downloads and install process can take some time, so be patient!

    upgrading the LAMP stack
    upgrading the LAMP stack

  3. Webmin install
  4. We download here the minimal package of Webmin, as well as some Ubuntu packages needed. For the whole functionality, many Webmin modules will be downloaded later, during the configuration process. To download the the minimal webmin package, type:

    wget http://prdownloads.sourceforge.net/webadmin/webmin-1.420-minimal.tar.gz
    sudo apt-get install perl libnet-ssleay-perl libauthen-pam-perl

    The 1.420 version includes already the fixes of Webmin for Ubuntu 8.04. For the latest webmin version, check also the webmin home

    To install webmin type:

    mv webmin-1.420-minimal.tar.gz /tmp
    cd /tmp
    tar xf webmin-1.420-minimal.tar.gz
    cd webmin-1.420
    sudo ./setup.sh /usr/local/webmin
    rm -rf webmin-1.420
    rm -rf webmin-1.420-minimal.tar.gz

    During install, accept defaults, set the webmin user and its password, and say yes to ssl and to start webmin at boot time.

    To start Webmin, open your browser and type: https://your-ip:10000/ where 'your-ip' is the IP address the LAMP server. It is now a temporary link to check this step, but we will set up the permanent address later on. In order to manage your Ubuntu, you will need some more webmin modules and theme. We'll configure Webmin in Session 3.

  5. The NFS package
  6. In order to mount source files from other servers or clients, we need to install the nfs-common package of Ubuntu

    sudo apt-get install nfs-common

  7. PphMyAdmin
  8. It is the common tool for administrating the MySQL databases and tables during Drupal development.

    sudo apt-get install phpmyadmin

    In the configuration screen, select apache2.

    Configuration of phpMyAdmin
    Configuration of phpMyAdmin

    After that, open your browser, and type: http://your-ip:10000/phpmyadmin/ where 'your-ip' is the IP address the LAMP server to have the PhPMyAdmin.

  9. The GD libraries of PHP
  10. Because of the standard LAMP package does not contain a very important PHP graphical package used by Drupal, we install it, and also restart the webserver:

    sudo apt-get install php5-gd
    sudo /etc/init.d/apache2 restart

    Now we have all of the packages for our development environment on Ubuntu LAMP server, we continue now with some configurations.

Configurations on LAMP

How to configure the LAMP server in a virtual machine for Drupal developments.

These are the configuration steps before Drupal install.

Drupal install

How to install Drupal development environment.

So, up to now, there is a drupal core exported via NFS to the development server. Now we set up a new development project, adding specific modules and themes to the /sites directory. The /sites/all will contain all the standard modules, like CCK, Views, Mollom, Pathauto, which are used in every project. The project stuff (/sites/project-1.com, /sites/nw-cee.com and /sites/wepoca.net) will be set up and exported to the development server separately. The /sites directory will look like this:

defaults
all
- modules
- themes
- default.setting.php
project-1.com
- modules
- themes
- files
- setting.php
nw-cee.com
- modules
- themes
- files
- setting.php
wepoca.net
- modules
- themes
- files
- setting.php

So let's assume, we have a project directory in our host, and each Drupal project is listed there:
project-1.com
nw-cee.com
wepoca.net

Each project contains the content for the /site directory. For example, the nw-cee.com looks like this here:

v1
- modules
- themes
- files
- setting.php
v2
- modules
- themes
- files
- setting.php

In order to export the project specific stuff to the development server, type:
sudo nano /etc/exports

And add one line to the end:
/home/www/projects/nw-cee.com/v1 192.168.2.1/24(rw,no_root_squash,async,no_subtree_check)

Save and exit, than restart the NFS server
/etc/init.d/nfs-kernel-server restart

Check the result with exportfs.

Then we have to mount this on the development server.
cd /var/www
sudo mkdir nw-cee.com
sudo mount host.local:/home/www/projects/nw-cee.com/v1 /var/www/nw-cee.com

To make it permanent, update the /etc/fstab file, and add one line to the end:
host.local:/home/www/projects/nw-cee.com/v1 /var/www/nw-cee.com nfs defaults 0 0

We just need now a link in the development server, in order to bind the nw-cee.com directory into the drupal sites:
ln -s /var/www/nw-cee.com /var/www/drupal6/sites/nw-cee.local

Now we configure a virtual host for Apache.
(http://www.debuntu.org/2006/02/22/7-virtual-hosting-using-apache-2)
sudo nano /etc/apache2/sites-available/nw-cee.com.conf

Add this to the file. Replace nw-cee.local according to your project name.

<VirtualHost nw-cee.local>
DocumentRoot /var/www/drupal6
ServerName nw-cee.local
ServerAdmin webmaster@localhost
<Directory "/var/www/d6">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
LogLevel warn
CustomLog /var/log/apache2/access.log combined
ServerSignature On
</VirtualHost>

Enable this new host, and restart Apache
sudo ln -s /etc/apache2/sites-available/nw-cee.com.conf /etc/apache2/sites-enabled/nw-cee.com.conf
sudo /etc/init.d/apache2 reload

As a last step, we just have to set up a database in MySQL, and run the Drupal install script.
mysql -u root -p
and enter the root password for MySQL. Recall, it has been set up during the install phase.

Once you have the "mysql>" promt, type:
create database nwcee;
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON *.* TO 'YOUR-DRUPAL-USER'@'localhost' IDENTIFIED BY 'YOUR-PWD';
FLUSH PRIVILEGES;
exit

So you have now a database called 'nwcee' and a database user called 'YOUR-DRUPAL-USER' with privileges necessary for Drupal. This user will have the same access rights to all databases you create here.

And it's convenient to have an DBA user, creating and deleting databases, and for database maintenance tasks via phpMyAdmin. If you want to use the root here, it's also possible, but not recommended.
mysql -u root -p

In the "mysql>" promt, type:

GRANT ALL PRIVILEGES ON *.* TO 'YOUR-DB-ADMIN'@'localhost' IDENTIFIED BY 'YOUR-PWD' WITH GRANT OPTION;
FLUSH PRIVILEGES;
exit

And now you can open your browser, type nw-cee.local and start the Drupal install procedure.