OS X and Apache Web server
OS X Snow Leopard and the Apache Web server
This is the server run from System Preferences > Sharing > Web Sharing
The inspired location for configuration files is … wait for it …. /etc/apache2
OS X Snow Leopard and the Apache Web server
This is the server run from System Preferences > Sharing > Web Sharing
The inspired location for configuration files is … wait for it …. /etc/apache2
How to configure and run the Apache Web server included on OS X
From Apple Mac OS X keyboard shortcuts
Startup keyboard shortcuts
Press the key or key combination until the expected function occurs/appears (for example, hold Option during startup until Startup Manager appears, or Shift until “Safe Boot” appears). Tip: If a startup function doesn’t work and you use a third-party keyboard, connect an Apple keyboard and try again.
| Key or key combination | What it does
|
| Option | Display all bootable volumes (Startup Manager) |
| Shift | Perform Safe Boot (start up in Safe Mode) |
| C | Start from a bootable disc (DVD, CD) |
| T | Start in FireWire target disk mode |
| N | Start from NetBoot server |
| X | Force Mac OS X startup (if non-Mac OS X startup volumes are present) |
| Command-V | Start in Verbose Mode |
| Command-S | Start in Single User Mode |
With thanks to Mac OS X Hints.
In OS X 10.6, Snow Leopard you can enable / disable screen sharing from the command-line.
To enable screen sharing:
$ sudo sh -c "/bin/echo -n enabled > /private/etc/ScreenSharing.launchd"
To disable screen sharing:
$ sudo sh -c "rm /private/etc/ScreenSharing.launchd"
OS X uses a weird and wonderful structure for Java components that allows multiple versions of Java to coexist happily on the same system. Depending on what you want to do, choosing between them can create challenges.
Apple references that were useful compiling this article:
Thanks also go to various others who have already plumbed the mysteries of OS X and Java.
OS X places all kinds of Java components in the directory structure starting at:
/System/Library/Frameworks
The component that’s of particular interest for this discussion is the JavaVM itself. That structure starts at:
/System/Library/Frameworks/JavaVM.framework
Each distinct Java version has a directory in
/System/Library/Frameworks/JavaVM.framework/Versions
Here’s a sample from my machine
lrwxr-xr-x 1 root wheel 5B Aug 31 21:35 1.3 -> 1.3.1 drwxr-xr-x 3 root wheel 102B Jul 20 19:35 1.3.1 lrwxr-xr-x 1 root wheel 5B Nov 26 03:43 1.5 -> 1.5.0 drwxr-xr-x 8 root wheel 272B Jan 2 2007 1.5.0 lrwxr-xr-x 1 root wheel 5B Aug 31 21:35 1.6 -> 1.6.0 drwxr-xr-x 8 root wheel 272B Oct 18 08:31 1.6.0 drwxr-xr-x 9 root wheel 306B Oct 18 08:31 A lrwxr-xr-x 1 root wheel 1B Aug 31 21:35 Current -> A lrwxr-xr-x 1 root wheel 3B Aug 31 21:35 CurrentJDK -> 1.6
There are several interesting points about the subdirectories managed here.
There are several levels of indirection involved. You can stop here if you don’t need a further information or a bad headache. In this excursion, I’ll deal with the 1.6 (Java 6) trajectory.
This all serves to set the scene for the most interesting link from the point of view of daily use – ‘/Library/Java/Home’:
/Library/Java/Home -> /System/Library/Frameworks/JavaVM.framework/Home /System/Library/Frameworks/JavaVM.framework/Home -> /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home
This is the directory that Apple recommends using to set the ‘JAVA_HOME’ variable – beloved of the Java world, and required to get almost anything Java-based to work.
export JAVA_HOME=/Library/Java/Home
export PATH=${JAVA_HOME}/bin:${PATH}
If you want to change the Java version for everything on the system, you can do so with the Java Preferences application
/Applications/Utilities/Java Preferences
On the ‘General’ tab, follow the instructions to change the selection.
If the version you want doesn’t appear on the list, you need something more radical (To be supplied).
The Apple-sanctioned way to run a specific Java version from the command line is simple. This deliberately does not involve changing the Java Preferences.
These changes shown below will only apply for the lifetime of the (bash) shell in which they are used. Using the setup illustrated above for my machine:
export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home $JAVA_HOME/bin/java
This technique has been tested successfully in two environments:
To add a DNS nameserver to OS X Leopard
Summarized from these excellent articles, Overriding DHCP- or VPN-assigned DNS servers in Mac OS X Leopard, Updating OS X Network Settings to Use a Local DNS Server, and Using a Local DNS Server in Leopard
In OS X (Leopard and later) DNS entries are arranged as a hierarchy – general to specific. You need the most specific applicable entry. Order – general to specific. Output is from scutil list command.
So, now for the commands to adjust everything
sudo scutil
list State:/Network/Service/[^/]+/DNS
[Pick the appropriate service]
show State:/Network/Service/com.cisco.VPN/DNS
[
{
ServerAddresses : {
0 : 10.1.10.211
1 : 10.1.10.100
}
}
]
d.init
get State:/Network/Service/com.cisco.VPN/DNS
d.add ServerAddresses 10.1.10.74 10.1.10.211 10.1.10.100
d.show
[
{
ServerAddresses : {
0 : 10.1.10.74
1 : 10.1.10.211
2 : 10.1.10.100
}
}
]
set State:/Network/Service/com.cisco.VPN/DNS
^D
Remember to flush your local DNS cache after all is said and done:
(Leopard and later) dscacheutil -flushcache
In OS X Leopart, ro access advanced user settings:
System Preferences > Accounts > Unlock > Control-Click on User Name > Advanced Settings
To flush the DNS cache in OS X (as superuser):
lookupd -flushcache (Tiger)
dscacheutil -flushcache (Leopard and later)
With thanks to Setting JAVA_HOME on Mac OS X 10.5
(bash) export JAVA_HOME=/Library/Java/Home
The essential trick to running two copies of Firefox at the same time on OS X is to run them both with the commant line options ‘–no-remote’.
/Applications/Web/Firefox.app/Contents/MacOS/firefox -no-remote
I chose to do serveral more things to create a really clean solution.
/Applications/Web/Firefox.app/Contents/MacOS/firefox -ProfileManager
rsync – a /Applications/Web/Firefox.app/ /Applications/Web/FirefoxTest.app
In /Applications/Web/Firefox.app/Contents/MacOS, create a executable script file with contents similar to:
#!/usr/bin/env bash # firefox-single # Run a standard Firefox setup, but disable single application locking /Applications/Web/Firefox.app/Contents/MacOS/firefox -P default --no-remote &
And for the second copy of Firefox, in /Applications/Web/FirefoxTest.app/Contents/MacOS something similar to
#!/usr/bin/env bash # firefox-test # Run a test Firefox setup, but disable single application locking /Applications/Web/FirefoxTest.app/Contents/MacOS/firefox -P FirefoxTest --no-remote &
(in Firefox.app/Contents or the equivalent location)
| Key | Value |
|---|---|
| CFBundleExecutable | firefox-single |
| CFBundleIdentifier | org.mozilla.firefox.single |
For the test copy, use something similar to the following:
| Key | Value |
|---|---|
| CFBundleExecutable | firefox-test |
| CFBundleIdentifier | org.mozilla.firefox.single-test |
The ‘CFBundleExecutable’ entry links the startup Icon (also the command-line ‘open’ command) to the new script file you’ve created to run Firefox.
The ‘CFBundleIdentifier’ ensures that OS X sees separate applications running when managing the applications.
The last, critical step, is to force OS X to recache the ‘Info.plist’ file (where it caches I don’t know):
touch /Applications/Web/Firefox.app
and
touch /Applications/Web/FirefoxTest.app
Now you’ve got two nice icons you can drag to your toolbar to click, you’ll be running two copies of Firefox side by side – and you’ll forget you had to do this.