Skip to content

ServerAdmins.NET

Stuff for Server Admins…

Archive

Tag: osx

So if you’re ever connected to a remote machine (or several), and you frequently see this message after you walk away from your term for a bit…


Write failed: Broken pipe

Do this from the machine you’re connecting from. SSHD for Macs/Linux boxes should all have this file. Windows, I’m not so much sure on.

(if not root already)

sudo echo "ServerAliveInterval 5" >> /etc/ssh_config

Or just open it up in your favorite text editor, save and call it good.

What’s happening here is that somewhere between you and your destination, there’s a long enough of a timeout happening that you hit SSHs internal timeout. This line just forces your SSH client to send a keepalive pulse fairly regularly to the endpoint.

Anyway, dumb quick fix to what ails so many of is.

Recently I’ve caught myself writing more code on my Macbook and for the first time in… YEARS, not needing an internet connection to actually be productive. To be quite honest, it’s a bit weird. :)

So, the first thing I wanted was the ability to run/exec CGI via a webserver. At first, I was thinking I’d go about a source build of Apache, and then I remembered OSX comes with one built in. Huzzah!

So, first let’s enable the builtin webserver.

System Preferences -> Sharing, and then click on “Web Sharing”. Go ahead and close out the window now, you’ve just fired off Apache. (hooray!). You should now be able to open your browser of choice and go to http://127.0.0.1/~

Now, the document root is going to be off of your user account in /sites/. My user is chrismm on my machine, so /Users/chrismm/Sites/ is my public HTML. Any web content you want to view with the above URL needs to go off of this directory. Go ahead and add the obligatory "Helloworld.html", I'll wait. :)

Now that that's done and functioning, I needed to get some hawt hawt Perl/CGI action going on. This, was incredibly easy.

OSX's main httpd.conf does a per-user http include in /private/etc/apache2/users/.conf, so once again for me, it was /private/etc/apache2/users/chrismm.conf. This file contains just a super basic Directory configuration for apache to parse and we only need to make one quick change here…

First and foremost, we need to be the root user, so go ahead and open up Terminal (Finder->Applications->Utilities -> Terminal), and type ‘sudo su -’ . Here, you’ll be prompted to enter your password.

Keep in mind as soon as you do this, you are the root user on your machine, ***BE VERY CAREFUL AS IF YOU ARE NOT YOU CAN END UP WITH A WORTHLESS WORKSTATION ***.

Now, go ahead and open up the include for your user, at /private/etc/apache2/users/.conf, and make the following changes.

Original:

maynard:beta root# cat /private/etc/apache2/users/chrismm.conf

Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all

Needs to be changed to....


maynard:beta root# cat /private/etc/apache2/users/chrismm.conf

Options Indexes MultiViews ExecCGI
AllowOverride None
Order allow,deny
Allow from all

See that? All I added was “ExecCGI” at the end of that Options statement. We’re halfway done now!

One more change…

Go ahead and open up ‘/private/etc/apache2/original/httpd.conf’ in your text editor of choice, and search for ” #AddHandler cgi-script .cgi”

Go ahead and remove the ‘#’ mark, save and exit.

Now, let’s restart the webserver…


killall -HUP httpd

Done!

And now, you can use your CGI and be happy. :)