Showing posts with label mac. Show all posts
Showing posts with label mac. Show all posts

Monday, March 2, 2009

Changing Mac OS X Web Server Root Directory

This is hardly the first post on the topic... but I'm documenting this more for my own sake than anyone elses.

First, create a backup of httpd.conf:

ditto /etc/httpd/httpd.conf /etc/httpd.conf.bak

Then open it in vi:

sudo vi /etc/httpd/httpd.conf

Find the line that reads:

DocumentRoot "/Library/WebServer/Documents"

Change it to something like:

DocumentRoot "/Volumes/Mac/Web"

Use something like this to confirm the changes in the file after saving:

more httpd.conf | grep DocumentRoot

Thursday, February 21, 2008

MacBookPro Faster Sleep

When I close the lid on my MacBookPro the white light stays on for 20-30 seconds... and then starts pulsing. It is taking this time to write the RAM contents to the HD in case the battery runs down or is removed this allows the computer to wake up and resume where I left off. There are a couple of command line options that one can enter to turn this on and off. Per this hint you can also save a shell script to make this process easier. I've included the script text here:

#!/bin/sh

SETTING=$1

if [ "$SETTING" == "off" ]; then
echo "Turning off safe sleep"
sudo pmset -a hibernatemode 0
sudo nvram "use-nvramrc?"=false
echo "Don't forget to reboot!"
echo You are now free to remove your sleepimage file at /private/var/vm/sleepimage
elif [ "$SETTING" == "on" ]; then
echo "Turning on safe sleep"
sudo pmset -a hibernatemode 3
sudo nvram "use-nvramrc?"=true
echo "Don't forget to reboot!"
else
echo "Usage: safesleep on | off"
fi

I put this in a file named safesleep in this directory: ~/Scripts/shell/. ~ is a shortcut for the current user's home directory. Then I made the file executable by running chmod on it:

sudo chmod ug+x ~/Scripts/shell/safesleep

I also had to add the ~/Scripts/shell directory to my path, so I created a new file at ~/.profile, into which I put:

export PATH="/bin:/sbin:/usr/bin:/usr/sbin:~/Scripts/shell"

Restart the shell (quit Terminal) and the script is ready to rock. Syntax is either "safesleep on" or "safesleep off". The script will remind you to reboot the computer for it to take effect.

I also installed the Dashboard widget Deep Sleep. This fellow causes the laptop to directly enter deep sleep. Deep sleep is a state that uses no power, the white light does not pulse, it is completely off. You do have to wait the 20-30 seconds for the ram to be written to the hard drive.

The combination of a safesleep off for fast normal sleeping, and Deep Sleep for no battery long term sleeping works well for me.

Thursday, February 14, 2008

Using Leopard Time Machine with Network Share

I just upgraded to Leopard. I want to use Time Machine to back up my laptop, but the only hard drive I have with extra space is an external hard drive currently plugged into my Mac Mini.

My first problem is that I don't have an open partition of the right size. To solve this I have created a 50 GB disk image. I setup that disk image with no encryption and a format of "read/write disk image." It took a few hours to create this image.

Then I mounted this image on the Mini and shared it through AFP (Personal File Sharing). Then I mounted this shared drive on the laptop. I could not tell Time Machine to use this network share... it did not appear. The solution was to change a system preference via the command line:

defaults write com.apple.systempreferences TMShowUnsupportedNetworkVolumes 1

I heard about this technique here.

Then I told Time Machine to start backing up now. It failed with the error message: Time Machine Error The backup disk image could not be created. Eventually I found this thread. It advised me to:

1. Start Time Machine backup. Wait a little.
2. On the server, make a copy (cp -r) of the in-progress disk image.
3. Let Time Machine fail and delete the image.
4. Rename (mv) the copy created earlier to the same name of the deleted Time Machine sparsebundle image.

This worked!

Favorites from my Blogroll