Tag Archives: Apache

Turn Off the built in apache on OSx

There are a handful of reasons why you would want to turn off the built in apache on OSx, you might have installed your own version, maybe you don’t use apache and it is interfering with something else, whatever the reason there is one command you need to run to turn it off.

sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist

You should run that from Terminal.app

I wanted to take a second to explain what is going on because too often people (myself included) will post a code snippet without explaining what it is, the worrying this is so many people run them without checking what is happening.

sudo tells your computer to run the following command as the root (administrator) account.
launchctl is an OSx program that interfaces with launchd, which is a daemon manager. Daemons are small programs that run as background processes (like what would setup Apache).
unload tells launchctl to unload a specified configuration file.
-w tells launchctl to override a disabled key, basically this will force the file to be marked as disabled.
/System/Library/LaunchDaemons/org.apache.httpd.plist is the file that we are unloading.

Hopefully that helps!

Share this on

Finding out what version of Apache and PHP a webserver is running when you have little access

There are better ways to do this, but let us assume you have no access via SSH or even FTP to be able to add a file.

Linux / OSx

Open up a terminal window and type the following;

curl --head http://thesite.com

This will return something similar to:

HTTP/1.1 200 OK
Date: Wed, 15 Aug 2012 10:41:32 GMT
Server: Apache/2.2.9 (Debian) PHP/5.3.8-1~dotdeb.1 with Suhosin-Patch
X-Powered-By: PHP/5.3.8-1~dotdeb.1
Set-Cookie: PHPSESSID=47d6a5e22c54307f211f67294f17495f; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Keep-Alive: timeout=15, max=100
Content-Type: text/html
Accept-Ranges: none
Connection: Keep-Alive

And as you can see in this information you can find the Apache and PHP information.

Share this on

Setting up Apache on OSx Mountain Lion

I have always used XAMPP on Windows machines and it comes with an OSx version so I have usually been lazy and just used it on any OSx installs I have had to use.

Recently though I have wanted finer control over my machines and part of that is to run anything as barebones as possible, which means not having something like XAMPP in the middle.

This guide assumes you are running OSx Mountain Lion and have xCode installed, it may work on older versions of OSx and may not require xCode, but honestly I don’t have any other systems to test this on!

The guide is also only three steps step long, because with this set up Apache is already installed.

  1. Open your terminal.
  2. Type sudo apachectl start
  3. Enter in your password.

Now when you browse to http://localhost you should see an ‘It works!’ message.

To change the settings you should edit the file located at /etc/apache/httpd.conf

Share this on

[notice] cannot use a full URL in a 401 ErrorDocument directive — ignoring!

I was skimming through my Apache Error Log today (as one does of a Saturday evening) and was finding a load of entries with.

[notice] cannot use a full URL in a 401 ErrorDocument directive — ignoring

Naturally you want to fix anything in your error log so I went looking for a solution.

In my case it turns out what was happening was in one of my .htaccess files I was giving a complete URL as the path to error documents, the fix was to change it to a relative path.

Which basically means I had something like;

ErrorDocument 401 http://mysite.com/errorpage.html

And I had to change it to

ErrorDocument 401 /errorpage.html

Unfortunately it doesn’t tell you much about the location of your .htaccess file and if you have several sites on a server hunting it down could be a bummer.  I would suggest using find and grep commands to help narrow down your list of possibilities. I did something like this;

find -name '.htaccess' -exec grep ErrorDocument {} \; -print

From inside the home directory and it returned all the .htaccess files with reference to ErrorDocument.

A very quick fix but one that will keep my Error Log all the cleaner!

Share this on

Useful Security Pages

I have been doing some trawling for security checklists and other web app related security documents and I have come across some web pages that I have found fairly useful.  I will add to this list as and when I find more;

Apache

PHP

MySQL

Share this on