OPW – Miscellaneous web development tips
The Ubuntu virtual machine (VM) I was developing on decided to have a thermonuclear meltdown yesterday. I reappropriated a 16GB thumbdrive and have installed Ubuntu natively on that. Since I have to redo the nice little setup I’d done for myself, I might as well document it while I’m remembering. I can’t take credit for it, as it came from other developers who were nice enough to share their wisdom with me, either directly or indirectly. In the spirit of paying it forward, here ya go. :)
First, a bit of background info:
When you clone from a GitHub repository with Git, it automatically creates the main project directory for you.
Rather than cloning to the Apache document root
/var/www and fiddling with sudo every time one creates, moves, or edits a file, it’s nice to be able to work from a folder in one’s home directory… but then it’s a pain to keep copying the modified files to
/var/www for testing.
Here’s how I made my life a little easier:
I more or less followed the steps on Forking and Creating a New Branch in Git and GitHub, with a couple of little tweaks. The first is that I did the
git clone from my home directory
/home/g33kgrrl , so that Git would create the
TidePools project directory there and the files would all be in
/home/g33kgrrl/TidePools . The second is that I created a symlink from
/home/g33kgrrl/TidePools . Now the system “thinks” my TidePools directory is my Apache docroot, and I can edit to my heart’s content without using sudo. I did this with:
g33kgrrl@saturn:~$ sudo ln -s /home/g33kgrrl/TidePools /var/www
When I’m ready to push my edits back to GitHub, I can do it right from the same directory. Neat.
So I already happen to know that there are some bugs to fix in this program, and PHP is going to throw some errors right off the bat. When you’re trying out different tasks in the program to see if they work, it can be difficult to tell from the the error log what events might have caused the errors one is seeing. They’re just listed by the time they occurred, and if you use something like
less to view the Apache/PHP error log, you have to keep checking it for new errors every time you test another task. Worse, new errors are added to the end of the log… so as you go along, you have to scroll farther and farther down to see the most recent errors. Wouldn’t it be nice if you could watch the tail end of the error log in realtime and see the errors as they occur, so you know what’s causing what? You can. I’m using the following:
g33kgrrl@saturn:~$ tail -n 40 -f /var/log/apache2/error.log
-n 40 tells
tail to display the last 40 lines of the error log, and
-f tells it to “follow” along as new errors are added to the end. What a timesaver!