My Ubuntu Setup – Development
Ubuntu 9.04, Jaunty Jackalope is set for release tomorrow, but I've been running the RC for about a week now. So far, so good! I was surprised that my wireless internet was working without me having to do anything this release. I've resorted to everything from using ndiswrapper to compiling madwifi from source previously, but this time, it just worked. Ubuntu++
However, having internet access is only the start of my setup. Once it's installed, it was time to install everything I need.
The main reason I use Ubuntu over Windows, is that as a developer it's much easier. Two screens is enough for me, so workspaces don't swing my decision like they used to. Infact, I'd go so far as to say that if I didn't code, I'd be using the Windows 7 beta full time.
However, as it stands, I use Ubuntu. To get a working development setup, it takes me a few steps. The first is to install everything I need via apt-get.
sudo apt-get install apache2 php5 mysql-server-5.0 phpmyadmin php5-cli php5-curl
As it's installing it asks a few basic questions, and mysql will prompt you for a root password. Once apt-get has finished doing it's thing, you need to enable phpMyAdmin. Open /etc/apache2/apache2.conf in your text editor of choice as root, and then add the following to the bottom:
# Enable PHPMyAdmin
Include /etc/phpmyadmin/apache.conf
Personally, I prefer running a mySQL terminal by using the following command:
mysql -u root -pPASSWORD
My development environment is then pretty much set up. After this, it's entirely down to preference.
I try and keep my /home/michael folder quite organised, but also wanted to keep my sites in /home, as it usually doesn't get wiped when I reinstall, simply remounted. So:
sudo mkdir /home/sites && sudo chown michael:michael /home/sites
Then, I use a little script I wrote to set up some vhosts with apache, and automatically create the folders in /home/sites. You can find it on github
I then install gPHPEdit as my text editor, as I've not put in the hours to learn how to use vi, and there we have it, my development environment is set up and I can start working on whatever I want. However, there's something else that I usually tweak before I start work. Firefox comes preinstalled, but I add a few extensions to make my life easier. Notably, these are Firebug, Firecookie, FirePHP, FireFTP and the Web Developer Toolbar.
I should mention that FireFTP is only for a few uploads, and that most of my code is managed using svn and deployed using rsync. Rsync comes pre-installed, but SVN needs installing.
sudo apt-get install subversion
After that, it's just a matter of checking out working copies of all my sites, and getting stuck in to current projects.
For reference, I use the following command to deploy sites (In this case, Project X). It ignores all .svn files and my config file, which contains all the database connection information. This allows me to deploy the site, and have it working on the server straight away.
alias xdeploy='rsync -r -v /home/sites/site.dev/ user@example.com:folder --exclude "*.svn*" --exclude "config.php"'
And there you have it, all the commands I use to setup my development environment. This is mainly as a reference, so I can easily recreate the setup I have should I ever lose it, but it also allows you to see how I work. Is there anything I'm missing, or anything I could do better? Let me know in the comments
No related posts.
I don’t see how that is any easier than using Windows. Most of what you have described can just as easily be done in Windows.
My editor of choice is notepad++ on Windows.
Also I hope that you check your sites work on more than just firefox
Checking sites in different browsers is the very last thing I do, and I’d need a variety of OS’s to check anyway, so I don’t really include it as a part of the development process. To me, it’s more part of the testing process.
As for it being just as easy to set up on a windows system, I’m not sure how true it is. It’s a long time since I’ve used a WAMP package, which are very easy to get up and and running, but not so easy to customise once it’s there. Even using Google to look at the install process for Apache, PHP and mySQL on Windows now doesn’t fill me with hope. You need to copy too many files into different locations, and edit different files to enable modules to get it all working. Using apt-get does all the downloading, installing and configuration for you. This is especially important when you’re constantly adding to your setup (apt-get install php5-curl is much easier than editing php.ini)
As for vhosts, they’re not quite as hard to set up as I remember. However, having to type the details I need into a config file and copy it into sites-avail/enabled is much more time consuming than using a script which creates the file, and a symlink which ensures both copes of the file are always identical.
However, I have come to a compromise recently.While I have apache et al installed on an Ubuntu machine (eeepc 901 plugged into the router), I have my main development setup installed on a Windows machne. notepad++ is my editor of choice, while using winSCP to access the files on the server. Opening a file with winSCP means that I can edit it locally and every time I save, it is uploaded to the server. As the server’s on the same network, I don’t notice any lag. It’s updated by the time I refresh Firefox. I access different sites using vhosts on the Ubuntu machine, and the Windows hosts file. Finally, use puTTy to connect to the machine and run a myQL terminal, and a normal terminal for quick file manipulation and mySQL administration.
And of course, if I ever need to develop on the move, I just pick up the eee901 on my way out of the house, and the environment is set up there, too – just with a different editor