Skip to content

OPW – Miscellaneous web development tips

January 17, 2013

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 /var/www to /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 cat or 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

The -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!

Happy debugging!

Ω

About these ads
12 Comments leave one →
  1. January 17, 2013 7:47 pm

    You should use windows it’s neato :P

    • g33kgrrl permalink*
      January 17, 2013 7:54 pm

      …says the Mac guy. Hahahahaha! Ha! :P

      • January 17, 2013 7:58 pm

        Who Loves ya baby! Besides if I’m not in the recording studio I’m using Ubuntu Studio via my 64MB thumb drive. My hatred for apple inc is epic believe me, bunch of boneheads running that place now

      • g33kgrrl permalink*
        January 31, 2013 1:33 am

        Back at ya, hon! Haha, awesome! I assume you mean 64GB, though, correct? ;) I’m running Ubuntu on a 16GB thumbdrive this very moment, for development purposes on this project. Running a VM on 1GB RAM was chapping my hide. Must. Upgrade. Memory. OMG. :P

  2. Lewis permalink
    January 21, 2013 7:41 am

    less has a follow mode: ‘F’, (ie -F) is the key you need, CTRL-C returns to normal.

    • g33kgrrl permalink*
      January 31, 2013 1:49 am

      Cool beans – thanks for posting this, Lewis!

      I do find, for some reason, that doing less -F /var/log/apache2/error.log gives me a lot of [Tue Jan 29 06:18:45 2013] [warn] child process 1696 still did not exit, sending a SIGTERM lines I’m not seeing when I use tail. Not really sure why, as I don’t see them using tail or cat, but they show up in vim as well. Using CTRL-C to exit less in follow mode doesn’t work for me, but Q works as it always did.

      • Lewis permalink
        February 2, 2013 3:56 pm

        Sorry, I didn’t describe that very well and the post got a little mangled or something as well.
        What I was trying to say was once less is running and you are viewing the log hit F and you’ll be in follow mode.
        Using the switch “-F” wasn’t what I meant but that now that you mention it, it looks like “less -F” would make a good alias for less.

      • g33kgrrl permalink*
        February 25, 2013 5:36 pm

        Hmm, thank you, but that still doesn’t seem to work. It displays the log as it exists at execution, but does not update with additional messages. I just tried it again, and it doesn’t even seem to work with less -f. less -F does nothing at all. As far as I can tell, for whatever reason, tail is the only one that seems to work.

  3. January 30, 2013 5:10 pm

    This is almost step-by-step what I did this weekend to set up a virtual server on my Mac, save for the symlink, which would have saved me a lot of trouble. I wish I had seen this earlier!

    • g33kgrrl permalink*
      January 31, 2013 1:52 am

      Oh dear! Heh, isn’t that the way it goes? Still, I’m glad to hear it would have been useful. :P Hopefully, it’ll save someone else some time and trouble.

  4. Andreas permalink
    February 14, 2013 10:44 am

    Great! Thanks. But i wrote wrong shirtcut and canät delete it. How do I edit the shortcut? Thanks in advance!

    • g33kgrrl permalink*
      February 25, 2013 5:51 pm

      Hi Andreas, please excuse my delay in replying. The last couple of weeks have been absolutely crazy, and I’ve been stuck without internet for most of that time. I’m now playing catch-up with my project, emails, and blog.

      There is a discussion and solution for that here. The short answer is, a trailing slash in the rm command tells the system to delete the directory. Omitting the trailing slash tells it to delete the symlink to the directory. That’s the difference between rm /var/oopswrongname/ and rm /var/oopswrongname .

      The usual caveats apply, of course. You should back up your work somewhere else, in case something goes wrong when you try this.

      Hope that helps!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: