Tuesday, October 7, 2008

Serving vmware shared folders

vmware's shared folders are a little strange to me. I'm having trouble running web apps from them because of owners and permissions

On the guest machine, first run

$ sudo umount -l /mnt/hgfs

Next, in /etc/fstab, add the options uid=[user],gid=[group] to the /mnt/hgfs entry so that it looks more or less like the following:

.host:/ /mnt/hgfs vmhgfs defaults,ttl=5,uid=[user],gid=[group] 0 0

(To see all the mount options for hgfs, run mount.vmhgfs --help.)

After that, remount /mnt/hgfs and verify that your folder now has [user] as its owner and group


Wednesday, September 17, 2008

Installing APC cache for PHP on Ubuntu 8.0.4

Apc offers a dramatic improvement in server speed. Apc is the standard php opcode cache. It parses your code once and stores in in memory, bypassing the filesystem. On a production server, you'll set the apc stat variable to false and it won't even check to see if the php script has been modified. On a development or staging server, you'll run Apc to make sure you haven't written anything that isn't compatible with opcode caches or Apc specifically. You'll set the apc stat variable to true and Apc will check to see if you've made modifications and use them if you have.

Install Apc,

I'm running php with fast cgi because everything about this stack is fast. Get the php development library.

apt-get install php5-dev
apt-get install php-pear
pecl install apc

Since we're not using apache, set Use apxs to set compile flags (if using APC with Apache)? to no.

Done.

Next I modify the php.ini to use the apc extension.


extension=apc.so
;; settings for apc. shm_size in megabytes, apc.stat set to zero in production
;; scenario where the php is restarted when the code is updated.
apc.enabled = 1
apc.shm_segments = 1
apc.shm_size = 33
apc.max_file_size = 10M
apc.stat=0
apc.ttl="7200"
apc.user_ttl="7200"


Thursday, September 11, 2008

Installing OS X without a CD Drive

I find myself with one old iBook G4 1.42Ghz with 1.5GB of RAM and a broken cd drive. I've read the instructions at ifixit.com and i'm pretty sure that for $100 or so, I could fix it myself. However, I bought a MacBook to replace the old iBook two months ago and I haven't used the CD drive yet. Two months without a CD drive, I'm thinking about it, I don't think I'll ever need the CD drive because I get all my software, music and movies online now.

So, the thing is, this iBook needs a clean OS install. After 2+ years as a developer's primary computer, its overrun with wierd modifications and lots of extra software, installed via the command line. I'm going to clean it up, reinstall everything and give it away.

Here's an easy way to erase and reinstall without a CD drive. I took my firewire drive, copied everything off of it onto the MacBook, opened disk utility and partitioned the drive with a 6GB partition and the rest on another partition. You can do this for as many boot disks as you want. I just need this one, so I'm only making one partition. Next, I put the Install disk into the MacBook and in disk utility, I made an image of it. When that was complete, I used disk utility again to restore the image to the 6GB partition. I moved all of the data that was on my external back onto the large partition. Now i have a bootable disk on my external. I plugged the external into the iBook and restarted while holding down the option key. The iBook booted up to a disk selecter, one of those crude UIs that lurk in the shadows behind your pretty OS waiting to help you when something breaks. Its a little slow and hard to use the trackpad at that point but it works and when you click on the name of your install disk partition and then click the little arrow, you're on your way to seeing the stupid OS X welcome video in no time at all.

Tuesday, September 9, 2008

Port Forwarding in Leopard using natd

I spent a couple hours trying to get port forwarding to work in OS X Leopard. I found natd, the bsd command line port forwarding thing. I couldn't get it to work. I had my virtual machine running, netstat said it was on 192.168.131.132 or whatever, and i had nginx installed on it listening to port 80. The challenge was to get traffic to my machine on port 8080 or whatever to forward to the virtual machine on port 80. If that could happen then I could force my coworkers to test my software on their workstations instead of having to do it all myself. Alas, I couldn't figure it out. The closest I came was

spinach$ ipfw flush
spinach$ natd -a lo0 -redirect_port tcp 192.168.131.132:80 8080

something like that, and it didn't work. If anyone figures it out, I'd love to hear.

Monday, September 8, 2008

how to install an ubuntu development server in OS X 10.5 Leopard

This was actually pretty easy after i figured it out. :)

I'm using VMware Fusion. I went to the VMware Fusion website and downloaded the bittorrent file for a Ubuntu Hardy Server disk image. I needed to unzip it and it was in the 7zip format so I had to get EZ 7z to unzip it. I unzipped it into the Virtual Machines folder which is in the shared folder on my Mac. Once it was in there, I booted it and ran apt-get update and what not to get ubuntu up to date. If you want it to run a little faster, shutdown the image and open up the .vmx file in textmate or whatever editor you're into. Add this to the .vmx file:

vmi.present=TRUE
that enables paravirtualization which dramatically speeds up the machine.

Now, if you're like me, you're setting up a webserver and you're wondering how to get that going. You would also prefer to ssh to the machine, you'll be able to copy and paste into the command line that way. Open up the MacOs 'Network Utility" app. Click on the netstat tab there and you'll see a list of addresses. Look in the list for those with a vmnet netif, on mine it was 192.168.131.132. That's the IP address for your virtual machine. You can only access it locally. Open the terminal and ssh user@192.168.131.132... and presto, you're ready to install your stack. When you get a hello world, point firefox at http://192.168.131.132.

Saturday, January 5, 2008

recipe

my red grapefruit, pear, almond and jicama salad experiment succeeds. it was pretty good. equal parts diced pear, jicama, and sectioned grapefruit some chopped almonds and fresh tarragon. dressed with rice vinegar, and some salt and pepper. that placed on top of some greens dressed with balsamic. we had it as an after-dinner salad-- kind of half-salad/half dessert.Q!Q!QA

Friday, January 4, 2008

ASP

ASP. Active Server Pages? Who developed this? It makes me appreciate Ruby on Rails. Active Server Pages, dozens of these things, all 'including' in other pages and all of it is covered in SQL strings. I can't find anything in the mess, and I don't particularly want to. I would prefer to work on something else.