Hi,
Imagine being able to teach someone to review/create patches, without having to teach them to setup a LAMP development environment.
Imagine windows and mac users, friends, learning together to do (blank) with a virtual machine development environment.
I created a virtualbox Drupal development image. I wanted a simple platform to collaborate with several others on for a project. I thought others might benefit from the work.
Features include:
- Slim lightweight image (OS+tools are under 1gig)
- LAMP with APC
- Netbeans and Eclipse with debugging
- Backup restore scripts (with gui interface - zenity)
- One-click drupal "subdomain" installers (wget or cvs) including config of hosts file and apache. E.g. site1.dev, site2.dev (all localhost)
- Step-by-step instructions to create image from scratch (see below)
- I could seed a bittorrent if there is any interest.
My intent was to create something I could share with collaborators so we had the same context, and to save time when ramping up a project. Maybe this could be useful for teaching "Patch bingo" or a some class like this.
I'm interested in feedback. The notes below are a bit stream of consciousness.
The attached zip file includes:
- 3 bash scripts to install: slim ubuntu, install lamp, and install netbeans
- backup/restore scripts
- install scripts
Would this be useful to continue working on? What would you use it for?
Mike
======= Desktop/Scripts/Dev Environment Setup/install notes.txt ========
What:
I want to setup a Drupal development environment with these features:
- PHP Debugging (XDebug + IDE)
- Javascript Debugging (FF, Firebug, Drupal for Firebug, and YSlow)
- Configured like a hosting environment (can run linux commands)
- Runs on windows! I don't want to reinstall my OS thankyouverymuch.
- Something I could create and share with others to collaborate from a shared context.
- A way to get someone "up and running" with development very quickly.
Windows + Linux + Same time = Virtual Machine :-)
So, why not create a virtual machine with this environment inside it?
If it was under 4GB, I could put it on a FAT32 USB flash drive and it would be portable to my several computers.
For others, it would be as simple as downloading and they could start testing patches/development/etc?
Why VirtualBox instead of VMWare?
- VirtualBox has a smaller download (20mb vs 340mb).
Why Ubuntu 9.04?
- Linux is the L in LAMP. Hosting is LAMP
- Popular distro. Let's make this easy for us linux n00bs
- Good support: Googling "ubuntu configure blah" has always turned up current relevant information
Info about the virtualbox image?
- Linux user is "drupaldev"
- Linux user password is "password"
- MySQL root password is "password"
To install the image:
1) Bittorrent the DrupalDev virtualbox image:
- (not hosted yet - see instructions below)
2) Install Virtualbox
- http://www.virtualbox.org/wiki/Downloads
3) Virtualbox -> File -> Import Appliance
- choose the drupaldev.ovf file (not hosted yet)
4) Read the next section "Plan" for how to use the image.
5) If you want to recreate it yourself, read the section after that "How".
6) Make a difference! Try some patch-bingo!
- http://drupal.org/patch-bingo
- http://drupal.org/contrib-patch-bingo
- http://dc2009.drupalcon.org/session/howto-test-patch-and-make-difference
=======
Plan:
Ok, here's the plan:
Let's say you want to work on three Drupal sites.
- hello.com
- world.net
- resume.org
To work on these sites, we'd like the following:
- Run private copies of each website running on our computer:
- hello.dev
- world.dev
- resume.dev
- http://hello.dev/index.php - for Firefox browsing/debugging of Drupal
- http://hello.dev/phpmyadmin - for database view/edit
- /home//websites/hello.dev - for convienent editing
- Debug/profile it with an IDE.
How do we do that?
1) Configure LAMP: Linux Apache MySQL PHP
2) Configure Virtual hosts so we can run more than one website
Well, when a webbrowser makes a request http://www.hello.com/path/file.html:
1) Browser asks DNS server what the IP of web server "www.hello.com" is.
2) Browser connects to web server's IP on port 80, and sends a text request, like this one:
GET /path/file.html HTTP/1.1
Host: www.hello.com:80
Fix 1) by editing /etc/hosts file. Fix 2) by editing /etc/apache2/httpd.conf and adding VirtualHosts. See below.
======
How:
1) Install Virtualbox (2.24)
- http://www.virtualbox.org/wiki/Downloads
2) Install Ubuntu (9.04)
- http://www.ubuntu.com/getubuntu/download
- Configured:
- USA keyboard
- Los Angeles timezone.
- user: drupaldev
- password: password
- Install VirtualBox Extensions (makes using mouse and resizing window nicer)
- In VirtualBox machine,
- Devices -> Install Guest Additions... ->
- Mounts CD. Open CD and dbl-click VBoxLinuxAdditions - x86.run
NOTE: "-" means it's a comment. "$" means run it from the command line. Ubuntu -> Applications -> Accessories -> Terminal
3) Update install and housekeeping
$ sudo aptitude update
$ sudo aptitude upgrade
4) Install LAMP + phpMyAdmin + PEAR + dev tools + Kitchen Sink
- The big download
$ sudo aptitude install apache2 mysql-server phpmyadmin php5 php5-gd php5-mysql php-pear php5-dev apache2-threaded-dev # (php5-dev and apache2-threaded-dev for installing APC)
- Set database password to "password"
- Install APC for Op-code caching
- Use APC/XCache/eAccelerator?
- APC actively maintained by PHP developers.
- XCache and eAccelerator have "instability" FUD (2008), which I am repeating here without testing :-/
$ sudo pecl install apc
$ sudo echo "extension=apc.so" > /etc/php5/apache2/conf.d/apc.ini
- Install XDebug - PHP Debugging
$ sudo aptitude install php5-xdebug
$ echo "xdebug.remote_enable=1" >> /etc/php5/conf.d/xdebug.ini
# http://wiki.netbeans.org/HowToConfigureXDebug
- Clear up after install
$ sudo aptitude clean
- Configure for Drupal performance:
- Enable "Clean URL's"
$ sudo a2enmod rewrite
- change default memory limit
$ sudo nano /etc/php5/apache2/php.ini
- set memory_limit = 32m
- Hint: Ctrl-w and then type "memory_limit" to search. Ctrl-w to search again
- Turn off some unneeded apache modules to help performance
$ sudo a2dismod cgi
$ sudo a2dismod autoindex
- restart apache to activate changes
$ sudo apache2ctl restart
- UBUNTU 9.04 CONDENSED COMMANDS SUMMARY (run as root):
slim.sh
!/bin/bash
sudo aptitude update
sudo aptitude safe-upgrade
echo "Set password to 'password'"
sudo aptitude -y install apache2 mysql-server phpmyadmin php5 php5-gd php5-mysql php-pear # apache2-threaded-dev php5-dev
sudo pecl install apc
echo "extension=apc.so" > /etc/php5/apache2/conf.d/apc.ini
sudo aptitude install php5-xdebug
echo "xdebug.remote_enable=1" >> /etc/php5/conf.d/xdebug.ini
sudo aptitude clean
sudo a2enmod rewrite
echo "Set memory_limit to 32M"
sudo nano /etc/php5/apache2/php.ini
sudo a2dismod cgi
sudo a2dismod autoindex
sudo apache2ctl restart
mkdir ~/websites
4) Test LAMP install:
- Check LAMP config in phpinfo()
$ echo "
<?php
phpinfo();
?>
$ firefox http://localhost/phpinfo.php
- Check for these sections (hint: use Ctrl-f to search):
- xdebug
- apc
- rewrite
- memory_limit (32m)
- Check out database http://localhost/phpmyadmin
- user: root
- password: password
- Troubles? Go back and check all the steps.
5) Setup reusable Apache development environment.
We're setting up these sites: hello.dev, world.dev, and resume.dev
1) Set DNS by editing /etc/hosts file. This file resolves domains to IP addresses.
$ sudo nano /etc/hosts
- add these lines at the top of the file:
127.0.0.1 hello.dev
127.0.0.1 www.hello.dev
- the www. entries are so both www.hello.dev and hello.dev URLs resolve.
- Test this out but browsing to http://hello.dev/phpinfo.php
- It should be the same page we tested with above.
2) Create a place for your websites files:
Because hello.dev and world.dev can have totally different files, Apache uses the "Host:" header to find the right "virtual host".
- For convienence, let's put the website files in our users home directory (/home/drupaldev/websites):
/home/drupaldev/websites/hello.dev
- Don't create them as user "root"! Either logout of "sudo", or create them through the GUI.
- Ubuntu Menu -> Places -> Home
- right-click -> Create folder -> "websites"
- Create project folders inside "websites"
3) When Apache answers the request, it needs to know what files to serve.
- We'll edit the httpd.conf and add two sections
- Add a <Directory> tag to set permissions on the /home/drupaldev/websites folder
- Add a <VirtualHost> tag for each website
- This file may be empty when you open it.
$ sudo nano /etc/apache2/httpd.conf
Include /etc/phpmyadmin/apache.conf
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
ServerAdmin webmaster@hello.dev
DocumentRoot "/home/drupaldev/websites/hello.dev/"
ServerName hello.dev
ServerAlias www.hello.dev
ErrorLog "/home/drupaldev/websites/hello.dev-apache-error.log"
- restart apache
$ apache2ctl restart
- Notice the "ServerAlias" in the VirtualHost tag? Use this to setup Multi-site. E.g.
- ServerAlias site1.dev site2.dev
- To add another website in the future, edit these files again. Remember to restart Apache. Here is a shell script I put in my websites folder:
! /bin/bash
gksudo gedit /etc/hosts
gksudo gedit /etc/apache2/httpd.conf
sudo apache2ctl restart
- P.S. This was the hard part :-)
6) Setup Drupal - Simplest Method - manual install:
Go to installation folder.
cd /home/drupaldev/websites/hello.dev
Download from drupal.org with wget. (like a command line "Save file as")
wget http://ftp.drupal.org/files/projects/drupal-6.12.tar.gz
tar -zxvf drupal-* --strip-components=1
Create a settings.php file and setup file permissions
cp ./sites/default/default.settings.php ./sites/default/settings.php
chmod a+w ./sites/default
chmod a+w ./sites/default/settings.php
Create a database, create database user:
mysqladmin -uroot -ppassword create hello
echo "GRANT ALL ON hello.* TO 'hello'@'localhost' IDENTIFIED BY 'password'; exit" > mysql -uroot -ppassword
Start the drupal installer
firefox http://hello.dev
follow the prompts
When finished, reset the permissions
chmod a-w ./sites/default
chmod a-w ./sites/default/settings.php
7) Install Netbeans PHP and Netbeans for Drupal module
- Netbeans PHP 6.7rc2 (find updated version here: http://www.netbeans.org/)
sudo aptitude -y install sun-java5-jre
cd ~/Desktop
wget "http://dlc-cdn-rd.sun.com/c1/netbeans/sync/6.7.1/bundles/netbeans-6.7.1-ml-php-linux.sh"
chmod +x ./netbeans-6.7.1-ml-php-linux.sh
wget "https://nbdrupalsupport.dev.java.net/files/documents/8560/115265/org-netbeans-modules-php-drupal-module.nbm"
double-click file on desktop
- Netbeans Drupal Module
Start Netbeans -> Tools -> plugins -> downloaded tab -> Add Plugins...
8) Install Eclipse PHP
- We'll focus more on Netbeans, but Eclipse is included: http://2tbsp.com/node/109 http://eclipse.org/pdt/downloads/
cd ~
wget "http://download.eclipse.org/technology/epp/downloads/release/galileo/RC2/eclipse-php-galileo-RC2-linux-gtk-x86_64.tar.gz"
tar -xvf eclipse-php-galileo-RC2-linux-gtk.tar.gz
rm eclipse-php-galileo-RC2-linux-gtk.tar.gz
ln ~/eclipse/eclipse ~/Desktop/Eclipse_PDT_RC2
9) Configure Firefox (3.1.2deb1)
- Open Firefox
- Menu -> Tools -> Addons
- Add these addons:
- Firebug (I had to click around to find version 1.3.3 compatible with Firefox 3.1.0)
- YSlow
- Drupal for Firebug
- And these other handy extensions:
- Colorzilla (color eyedropper)
- MeasureIt (pixel ruler)
- Web Developer (more web developer kung-fu)
- Dust-Me Selectors (find unnecessary CSS)
- Try these others too:
- FireRainbow (javascript syntax highlighting) (experimental)
- Firecookie (view/modify cookies)
- Tamper Data (view/modify headers)
- Page validator (test page for standards compliance)
- Clear Cache Button
- CodeBurner for Firebug (inline HTML/CSS reference) (check license)
- Firefinder for Firebug (CSS/Xpath search)
- Icons will appear in the bottom left and right. A toolbar (web developer) will appear at the top. Clear Cache has to be enabled manually.
BONUS POINTS:
A) Configure error logs:
Apache error logs are configured in the VirtualHosts section of httpd.conf
Php error logs
#change: log_errors = On
#change: error_log = /var/log/php-error.log
sudo nano /etc/php5/apache2/php.ini
sudo touch /var/log/php-error.log
ln /var/log/php-error.log /home/drupaldev/websites/php-error.log
sudo apache2ctl restart
MySQL error logs
ln /var/log/mysql.err /home/drupaldev/websites/mysql.err
B) Easier site install method - automate with Drush command line. http://drupal.org/project/drush
- Install Drush
$ mkdir ~/websites/drush
$ cd ~/websites/drush
$ wget http://ftp.drupal.org/files/projects/drush-All-Versions-2.0-rc1.tar.gz
$ tar -zxvf drush-* --strip-components=1
$ echo "alias drush='php ~/websites/drush/drush.php'" >> ~/.bash_profile
$ alias drush='php ~/websites/drush/drush.php'
- What is drush?
$ drush
- Install a new site with latest CCK, views, and Zen theme:
$ cd ~/websites/world.dev
$ drush dl drupal cck views zen
$ firefox
Attachment | Size |
---|---|
Scripts.zip_.doc | 25.6 KB |