Enabling PHP in Mac OS X

Mac OS X comes with everything a web developer needs. Php, Perl, Ruby, Apache. But they are not activated by default to get your Apache to play nice with default PHP install of OS X. Follow these steps.

Open file called “httpd.conf” which is located under “/private/etc/apache2/” with your favourite editor.

/private/etc/apache2/httpd.conf

Or, open up a terminal and type,

sudo vim /private/etc/apache2/httpd.conf

Move to line “around 114” at the end of LoadModule section it should print

#LoadModule php5_module        libexec/apache2/libphp5.so

Remove the # symbol to uncomment that line.

LoadModule php5_module        libexec/apache2/libphp5.so

Now apache knows about your php module. Go to you System Preferences then sharing and turn on web sharing. To test your installation create a file called hello.php with the following code snippet and place it in /Sites/

<?php
Print "Hello, World!";
?>

If everything went fine going to http://127.0.0.1/hello.php in your browser should print Hello, World!.

Defeating Cooperate Firewalls

When you work at a company that won’t let you browse Facebook or any other itchy site. OS X comes with a utility called SSH (secure shell).

With it you can setup a secure encrypted channel between 2 machines and browse anything you want without IT department knowing about it.

What you need is a machine with SSH and a valid user account (Your home Mac ). Fire up a terminal on your work machine and enter.

ssh -ND 9999 -v [email protected]

This will setup the secure channel between your work machine and home machine. Anything you send to port 9999 on your local machine will be encrypted and forwarded to your home machine, from there it will travel unhindered to its destination.

Effectively by passing any Firewall or blocking rules your IT department migth have.

Now you have your secure channel things will not work magically. You need to set your browser to use the proxy you just setup.

Go to your browsers proxy settings

Safari:

Preferences -> Advanced -> Proxy -> Change  Settings -> Socks proxy

Firefox:

Preferences -> Advanced -> Network  -> Connection settings -> Socks proxy

Set your proxy ip to 127.0.0.1 and port 9999

You are set now, any thing your IT department will see is garbage going to/from your machine at home and machine at work.

For Firefox users there is a plugin called FoxyProxy which will let you use the proxy only when connecting to blacked list sites. Since proxy is a little bit slower than your local network it will speed up your overall browsing exprience.

Terminal: Stuck Trash

Ever empty your trash but stuck with a full trash icon or can not empty your trash because finder is complaining that files in it are in use.

If you want to get rid of it fire up a terminal and type

rm -rf .Trash/

A word of coution “rm -rf” will delete everything starting from the
provided folder without warning. it will not complain if the directory is
not empty. A typo like “rm -rf /” will cost you your whole drive.

Switching From Linux to Mac ?

You want to make the switch but don’t know if your favorite Linux application is avaible under OS X. Then you are in luck. Macports is an open source community that provides a apt-get like interface for downloading, compiling, updating open source applications. Its probable that your application is already working. They have a huge repository of open source applications.

Mute your Mac's Startup Sound

Personally, I am a big fan of all Mac’s startup sounds. And I know that, there are soo many hardcore fans of this sounds. But it can also be annoying, if you’re in a library or a quiet place or the place you do not want to make a noise.

To mute the startup sound; here are some basic tricks.

  • If you have to restart your running Mac, press the mute button (F3 on laptops) or lower your volume manually before you restart.
  • If you’re starting up your Mac from scratch, press and hold the mute key on the keyboard (F3 on laptops) before pressing your Mac’s power button.