Contact Krimson

Call us: +32 (0) 3 298 69 98

Email us: info@krimson.be

Towards a perfect Drupal Development Environment.

Below you'll find my slides for the presentation at fosdem 2010

Setting up a new machine to be able to do drupal development often takes a lot of time, googling and tweaking. To ease that process i've created a automated installation process which takes you up to speed in roughly 20 minutes.
The whole installation process is split up in three different steps.

  • Setup Lamp Server
  • Setup Drush
  • Setup Eclipse

These steps have been automated based on a freshly installed Ubuntu 9.04.
Just run the following code and follow the trivial installation steps.

SETUP UBUNTU
mkdir ~/bin
cd ~/bin
wget http://krimson.be/sites/default/files/setup_ubuntu.sh && chmod +x setup_ubuntu.sh && ./setup_ubuntu.sh

SETUP DRUSH
cd ~/bin
wget http://krimson.be/sites/default/files/setup_drush.sh && chmod +x setup_drush.sh && ./setup_drush.sh
. ~/.profile

SETUP ECLIPSE
cd ~/bin
wget http://krimson.be/sites/default/files/setup_eclipse.php.txt && mv setup_eclipse.php.txt setup_eclipse.php && chmod +x setup_eclipse.php && ./setup_eclipse.php

Please go through the last slides for some extra manual steps to give even more power in drupal,eclipse and firefox

I'll paste the current version of those scripts here for further reference and discussion.

setup_ubuntu.sh : SETUP Drupal friendly LAMPSERVER in Ubuntu

#PREPARE ubuntu dev machine
sudo apt-get update
#sudo apt-get upgrade
sudo tasksel install lamp-server
sudo apt-get install phpmyadmin
sudo apt-get install php5-cli
sudo apt-get install curl php5-curl
sudo apt-get install php5-xdebug
sudo apt-get install subversion
sudo sed -i 's/memory_limit = .*/memory_limit = 128M/' /etc/php5/apache2/php.ini
sudo sed -i 's/upload_max_filesize = .*/upload_max_filesize = 128M/' /etc/php5/apache2/php.ini
sudo sed -i 's/post_max_size = .*/post_max_size = 256M/' /etc/php5/apache2/php.ini
#for installing PECL libs
sudo apt-get install php5-dev php-pear
#better uploadprogress bar
sudo pecl install uploadprogress
sudo sed -i '/; extension_dir directive above/ a\
extension=uploadprogress.so' /etc/php5/apache2/php.ini
#cleanurl
sudo sed -i 's/AllowOverride (None)/AllowOverride All/' /etc/apache2/sites-available/default
sudo a2enmod rewrite && sudo /etc/init.d/apache2 restart

TEST Point your browser at http://localhost and Apache will tell you it's working

setup_drush.sh : SETUP Drush in Ubuntu

#default directory structure
DEFAULT_WORKSPACE=$HOME/workspace
if [ ! -d "$DEFAULT_WORKSPACE" ];then
echo "create workspace folder"
mkdir $DEFAULT_WORKSPACE
fi
cd $DEFAULT_WORKSPACE
#install drush
#NOTE : WHEN changing the drush folder, also update the $PROFILE_PATH
DRUSH_ROOT=$DEFAULT_WORKSPACE/drush
PROFILE_PATH='\n # set PATH so it includes drush if it exists \n
if [ -d "$HOME/workspace/drush" ] ; then \n
\t PATH="$HOME/workspace/drush:$PATH" \n
fi \n'
DRUSH_VERSION=2.1
DRUSH_TGZ=drush-All-Versions-$DRUSH_VERSION.tar.gz
if [ ! -d "$DRUSH_ROOT" ];then
echo "grabbing drush"
wget http://ftp.drupal.org/files/projects/$DRUSH_TGZ
if [ -a "$DRUSH_TGZ" ];then
tar -zxvf $DRUSH_TGZ
rm $DRUSH_TGZ
else
echo "ERROR : unable to download $DRUSH_TGZ"
fi
fi
if grep -q drush ~/.profile
then echo 'DRUSH already in path'
else echo -e $PROFILE_PATH >> ~/.profile
source ~/.profile
echo '
----------------------------------------------------------------------
| Please update your path by reloading your .profile. |
| Just run the command at the bottom from your terminal. |
| Note : this will only work in current shell. if you want a decent |
| DEV environment, you should logout/login. |
| |
| the command to run : |
| |
| . ~/.profile |
----------------------------------------------------------------------
'
fi

TESTRun the command 'drush' from the commandline and retrieve info about most common drush commands.

setup_eclipse.php : SETUP Eclipse 3.5 in Ubuntu

#!/usr/bin/php -q
<?php
$ECLIPSE_DOWNLOAD_URL="http://d2u376ub0heus3.cloudfront.net/technology/epp/downloads/release/galileo/SR1/eclipse-php-galileo-SR1-linux-gtk.tar.gz";
$ECLIPSE_TAR_NAME=basename($ECLIPSE_DOWNLOAD_URL);
$ECLIPSE_NEW_FOLDER_NAME="eclipse-pdt-galileo";
$ECLIPSE_BIN_FILE="eclipse";
echo "#Install JAVA Runtime\n";
passthru("sudo apt-get install sun-java6-jre sun-java6-plugin sun-java6-fonts");
echo "#Get Eclipse ("+$ECLIPSE_NEW_FOLDER_NAME+") \n";
passthru("mkdir -p ~/bin/packages");
// Download it - if needed
exec("rm " . $ECLIPSE_DOWNLOAD_URL ."*");
if (!file_exists($ECLIPSE_TAR_NAME)) {
exec("wget " . $ECLIPSE_DOWNLOAD_URL);
if (file_exists($ECLIPSE_TAR_NAME)) {
echo "Downloading " . $ECLIPSE_TAR_NAME . " was successful.";
}
else {
echo "Unable to download $ECLIPSE_TAR_NAME from ". $ECLIPSE_DOWNLOAD_URL;
}
}
system("mv " . $ECLIPSE_TAR_NAME . " ~/bin/packages/");
system("cd ~/bin/packages/ && tar -zxvf $ECLIPSE_TAR_NAME && rm $ECLIPSE_TAR_NAME && mv eclipse $ECLIPSE_NEW_FOLDER_NAME");
if (!file_exists($ECLIPSE_BIN_FILE)){
$fh = fopen($ECLIPSE_BIN_FILE, 'w') or die("can't open file $ECLIPSE_BIN_FILE\n");
$stringData = "#/bin/bash\n";
fwrite($fh, $stringData);
$stringData = "export GDK_NATIVE_WINDOWS=1\n";
fwrite($fh, $stringData);
$stringData = "`~/bin/packages/$ECLIPSE_NEW_FOLDER_NAME/eclipse -data ~/eclipse-workspace -vmargs -Xms128M -Xmx512M -XX:PermSize=128M -XX:MaxPermSize=512M &> /dev/null` & \n";
fwrite($fh, $stringData);
fclose($fh);
system("chmod u+x eclipse && mv eclipse ~/bin/eclipse") ;
}
?>

TESTLaunch eclipse from the commandline by running 'eclipse'.
For more mouse oriented people, drag 'n drop the eclipse command onto your top-panel.

AttachmentSize
Roel_Dev_Machine.pdf362.22 KB