Setting up a Development VM (debian etch)
I needed a new Virtual Machine for my development environment. I never wrote down what exactly I do, so each time I have to think it trough again and search solutions for the same issues. So, below you can find a list of steps I follow to install a new DEV Debian VM.
If you want to use this as well, you'll need either VMWare Fusion (Mac) or a Windows variant to run the VM.
Step 1: Getting the VM running
I just a pre-installed Debian VM. Or at least, partially installed. I find it easy to work with and I don't have to keep CD/DVDs lying around. Start by downloading the VMWare image at ThoughPolice.co.uk. I installed Debian Etch. After downloading, unzip it.
Now, you can keep it with the same name, or you can rename it. If you want to rename it, you have to open following files in a text editor:
debian-40r0-i386-netinst.vmdk debian-40r0-i386-netinst.vmx
Inside, do a search and replace on "debian-40r0-i386-netinst" and replace it by "the_vm_name_you_choose". After that is done, you change all the filenames so the "debian-40r0-i386-netinst" parts are renamed to "the_vm_name_you_choose". Example:
debian-40r0-i386-netinst.vmx becomes the_vm_name_you_choose.vmx debian-40r0-i386-netinst-s001.vmdk becomes the_vm_name_you_choose-s001.vmdk etc...
Don't forget the directory name.
I then move the directory inside the Virtual Machines folder in my documents (on Mac). I'm not sure where the virtual machines are located on Windows, so if anyone knows let me know and I'll add it.
Next step is adding the VM to VMWare Fusion. In the Menu go to File > Open and go to the vmx file in the directory you copied. When VMWare fusion asks you if you copied or moved the file, just say "copied it". If VMWare asks you about your floppy, you don't want him to try again next time!
The basic installation happens now, be patient for a minute until it ends. When the user prompt appears, use root as username and thoughtpolice as password.
Step 2: Basic configuration and set up
The first thing you need to do is to upgrade the system (I just do 'y' on all questions ;)) and reboot afterwards.
debian:~# apt-get update debian:~# apt-get upgrade debian:~# reboot
After the reboot, I always install ssh so I can login remotely (use "ifconfig" to find out your ip address).
debian:~# apt-get install ssh openssh-server
Okay, one thing I need to do before I'm ready is change the keyboard map. I'm on AZERTY (why the hell did they invent that!), so I'm having a problem typing. ;)
debian:~# dpkg-reconfigure console-data
Now the keyboard is what you want, you can change the root password to something more appropriate:
debian:~# passwd
Next I activate some aliases that will make my live easier:
debian:~# nano /root/.bashrc
Uncomment all lines, except for the plain English ones of course. To use the aliases in this session (they will be loaded automatically in the next) use the command below:
debian:~# . /root/.bashrc
I then change my hostname. For this you add a line to your /etc/hosts file (on your VM) with your IP (that you got from ipconfig) and preferred hostname. I added following line:
debian:~# 192.168.69.134 dev.keppens.biz dev
I then modified the hostname:
debian:~# echo dev > /etc/hostname debian:~# /etc/init.d/hostname.sh
Then verify that the hostname is set:
dev:~# hostname dev dev:~# hostname -f dev
Don't forget to add the hosts to your local hosts file as well (on mac: sudo nano /etc/hosts).
At this point, I like to install some more packages I'll need later on (all in 1 line):
dev:~# apt-get install binutils cpp fetchmail flex gcc libarchive-zip-perl libc6-dev \ libcompress-zlib-perl libdb4.3-dev libpcre3 libpopt-dev linux-kernel-headers lynx \ m4 make ncftp nmap openssl perl perl-modules unzip zip zlib1g-dev autoconf automake1.9 \ libtool bison autotools-dev g++
I have a nasty bug when I use nano in my VM. My backspace key is actually mapped as delete. To mitigate that bug, edit /etc/nanorc and uncomment following line:
# set rebinddelete
Now, this is my queue to switch to the mac console and login to the vm using ssh.
Last but not least, I need to set up the VMWare tools.
First you need to install the packages to build the kernel modules:
dev:~# aptitude install autoconf automake binutils cpp gcc linux-headers-$(uname -r) make psmisc
Then you need to find out where the kernel headers are (you may need this later):
dev:~# ls -d /usr/src/linux-headers-$(uname -r)*/include /usr/src/linux-headers-2.6.18-4-686/include
In VMWare Fusion, go to the menu "Virtual Machine" and choose "Install VM Tools". This should mount your VMWare tools CDRom. If it doesn't (it didn't for me), you can mount it using:
dev:~# mkdir /media/cdrom dev:~# mount /dev/cdrom /media/cdrom
Now, let's proceed and actually install the tools. I entered on every question to use all defaults. Please note that you need to do this from the VM console, and not trough ssh as you might loose the network connection during the install.
dev:~# cd /media/cdrom dev:~# tar -C /tmp -zxvf VMwareTools-*.tar.gz dev:~# cd /tmp/vmware-tools-distrib dev:~# ./vmware-install.pl
Step 3: Installing LAMP
First of all, add following lines to your /etc/apt/sources.list. This will allow you to use one of the later versions of PHP.
deb http://packages.dotdeb.org etch all deb-src http://packages.dotdeb.org etch all
This will need to be followed by an update/upgrade of apt:
dev:~# apt-get update dev:~# apt-get upgrade
Let's start by installing MySQL:
dev:~# apt-get install mysql-server mysql-client libmysqlclient15-dev
Since I don't want mysql to be bound to localhost only, I commented out following line in /etc/mysql/my.cnf:
#bind-address = 127.0.0.1
Then we restart MySQL:
dev:~# /etc/init.d/mysql restart
Change your root password:
dev:~# mysqladmin -u root password yourrootsqlpassword dev:~# mysqladmin -h yourhostname -u root password yourrootsqlpassword
Next is apache & PHP:
dev:~# apt-get install apache2 apache2-doc apache2-mpm-prefork apache2-utils libexpat1 \ ssl-cert dev:~# apt-get install libapache2-mod-php5 php5 php5-common php5-curl php5-dev php5-gd \ php5-idn php-pear php5-imagick php5-imap php5-json php5-mcrypt php5-memcache \ php5-mhash php5-ming php5-mysql php5-ps php5-pspell php5-recode php5-snmp php5-sqlite \ php5-tidy php5-xmlrpc php5-xsl php5-cli
If you get a question if you want to install libc-client without Maildir support, answer YES.
Since we want our index.php to be loaded by default, modify the file "/etc/apache2/mods-available/dir.conf" so the DirectoryIndex line looks like:
DirectoryIndex index.html index.htm index.shtml index.cgi index.php index.php3 index.pl index.xhtml
Since I use both http as https, I need to add port 443 to the ports apache listens to. Modify the file /etc/apache2/ports.conf so it looks like:
Listen 80 Listen 443
Last but not least I activate a few modules I used in the past:
dev:~# a2enmod ssl Module ssl installed; run /etc/init.d/apache2 force-reload to enable. dev:~# a2enmod rewrite Module rewrite installed; run /etc/init.d/apache2 force-reload to enable. dev:~# a2enmod include Module include installed; run /etc/init.d/apache2 force-reload to enable. dev:~# /etc/init.d/apache2 restart Forcing reload of web server (apache2)... waiting .
I also want my time to be in sync, so I install ntp.
dev:~# apt-get install ntp ntpdate
Step 4: The code paths
IN VMWare Fusion settings, I typically add the project workspace to the shared folders. This way I keep my code on my local machine, while it's immediately accessible in the VM. Once you have modified the settings, you should have the path in /mnt/hgfs. You will notice that you will have issues with the user / groups since they don't match the local ones. You can see another post on my blog which explains this in detail.
Possible Mysql Issue
If you encounter a problem with mysql that doesn't want to stop, it might be a problem with the debian-sys-maint user.
Go into /etc/mysql/debian.cnf and copy the password you find in there. Then open the mysql client and log in with root and execute following mysql commands:
GRANT ALL PRIVILEGES ON *.* TO 'debian-sys-maint'@'localhost'
IDENTIFIED BY 'the_password_you_copied' WITH GRANT OPTION;
FLUSH PRIVILEGES;
Try restarting mysql now and it should work.






+32 475 62.42.64