Archive for the ‘OSX’ Category

Installing LAMP stack on OSX 10.6 Snow Leopard

I’m setting up a new machine and found a great tutorial written by Josh Lockhart on getting a PHP web development environment up and running on Snow Leopard.  This goes through almost everything to be up and running for a typical LAMP stack with unit testing using all of the default services.

Josh’s instructions include everything that I need except mcrypt.  Luckily Michael Gracie has provided a walk-through for installing mcrypt on Snow Leopard which involves re-compiling some things, but isn’t as tough as it first appears.

After getting PHP and mcrypt going, the last step for me is setting up MySQL which has some caveats on OSX.  The main problem is that the MySQL installer places the mysql.sock file in a non-standard place and so you have to either create a link or alter your php.ini file before PHP will be able to talk to MySQL.  (If you get “Can’t connect to local MySQL server through socket ‘/var/mysql/mysql.sock’” or  “No such file or directory” when calling mysql_connect, then this is the problem)

Read more

PHP on OSX: Can’t connect to local MySQL server through socket ‘/var/mysql/mysql.sock’

When installing PHP and MySQL on OSX  you may get the error Can’t connect to local MySQL server through socket ‘/var/mysql/mysql.sock’.  Or you may also get “No such file or directory” when calling mysql_connect from a PHP page.  This occurs because PHP is looking for the file mysql.sock in it’s typical installation location of /var/mysql/mysql.sock. However the MySQL OSX installer actually puts the file in /tmp/mysql.sock. There are two easy ways to solve the problem.

Read more

TortoiseSVN for Apple OSX

tortoise_on_osx

TortoiseSVN is my personal favorite SVN client, unfortunately it’s only fully supported on Windows.  With a little bit of hacking, though, TortoiseSVN is usable on OSX.  You can checkout, commit, update view the repo, etc.  At this point there are no overlays or Finder contextual menus.  These instructions are not for the novice user, but chances are if you’re using SVN it shouldn’t be a problem.

Read more

SCPlugin – authorization failed

SCPlugin for OSX may return “authorization failed” when you try to update or commit the first time you use it. The reason for this is that it uses the keychain however it doesn’t seem to pop-up the Allow/Deny dialog in order for you to allow it to access the keychain.

The solution is that you need to do at least one initial checkout using the command line in order to give SVN access to the keychain.  To do this, just open terminal and navigate to an empty folder.  Do a checkout of your project with the command “svn co http://myrepolocation.com/ –username myusername –password mypassword .”

when you do this, you’ll get the OSX Allow/Deny dialog and you should Allow SVN access to the keychain.  From this point on SCPlugin will be able to correctly remember your authentication information.

Mount an OSX AFS shared folder over SSH

This is a simple way to mount an OSX shared folder over SSH without installing any additional software. For this to work you must be sharing a folder using AFP (Apple File Sharing) protocol and have “Remote Login” (i.e. SSH) enabled. These settings are all found in System Preferences->Sharing. If your server is behind a firewall, you must open the SSH port (usually port 22).

Step One: Open up terminal and enter the following command:

ssh -N -p 22 USERNAME@HOSTNAME -L 5480/localhost/548

Replace USERNAME with the remote username and replace HOSTNAME with the domain name or IP address of your server. For example jason@192.168.1.100. If you run SSH on a non-standard port, you can also replace 22 with your port number. You’ll be prompted for a password then you won’t see any further output.

This creates an SSH tunnel from local port 5480 to remote port 548. In Apple terms you might think of this as an alias. The remote server’s incoming port 548 is the default port used by Apple File Sharing service. Our local outgoing port 5480, on the other hand, is just an open port that is not known to be used by any common service. The outgoing port is not actually important, but these instructions assume you’re using 5480. Anyway, you might think of your tunnel as something like this:

local port 5480 -> SSH -> Internet -> SSH -> remote port 548

Step Two: Click anywhere on your desktop or open Finder so that you see the “Go” menu in your menu bar. Select from the menu bar: Go-> Connect to Server…

In the server address, enter “afp://localhost:5480″ (without the quotes)

This may seem crazy because it appears you are connecting to “localhost” which would normally be your local computer. Remember, though, the SSH tunnel connects local port 5480 to remote port 548. So we are actually connecting to port 548 on the remote machine.

After a moment you should get a standard login dialog. Enter your remote username/password and you’ll be presented with the available shares. Select the share you want and you should see it appear in the Finder in a moment. That’s it! You can now open and drag/drop files. The connection will probably be slower depending on your connection speed, but otherwise it works the same as if you were connecting directly.

(Optional) Additional Software and Alternatives

If you’re uncomfortable with the command like, there’s a GUI application for connecting to SSH servers and creating tunnels called SSH Tunnel Manager. You can download it from http://projects.tynsoe.org/en/stm/. The functionality is the same, but if you prefer clicking a button instead of typing in the terminal window, it can be useful.

Another method for connecting to shares over SSH is through an application called MacFuse with it’s required counterpart sshfs. This may look the same as an SSH tunnel, but is technically very different. MacFuse is a program that allows you to make anything appear to be a file system and SSH is just one of the possible implementations. You might say that this app tricks your computer into thinking something is a local hard drive. I gave MacFuse a try and personally did not find it reliable. A plain old SSH tunnel works great for me so I don’t plan to use MacFuse for this purpose. However it is an interesting idea and has many other uses.

Please feel free to leave a comment if you have any remote connection tips or tricks.

Return top