Problem with web-sharing and resolving localhost I was using web-sharing and accessing some webpages that I had developed using localhost. I messed up a PostGreSQL installation and deleted anything related to PostGreSQL and in the process appear to have damaged my apache installation. 

If I run ping localhost the result is 


  --- localhost ping statistics --- 794 packets transmitted, 794 packets received, 0.0% packet loss round-trip min/avg/max/stddev =
  0.033/0.076/0.920/0.055 ms


I then tried running apachectl configtest and recieved the following output:

Library not loaded: /usr/lib/libpq.5.dylib   Referenced from: /usr/sbin/httpd
Reason: image not found /usr/sbin/apachectl: line 90: 16227 Trace/BPT trap: 5       $HTTPD -t


I also tried

curl http://localhost || echo $? curl: (7) couldn't connect to host 7


Within System Preferences-&gt;Sharing-&gt;Web Sharing when I try to tick web-sharing I end up with it being unticked automatically. I'm fairly sure that my local webserver is not working, but I'm not sure what I can do to fix this problem.
Judging from your feedback in the comments, the installation of PostgreSQL brought its own version of libpq (which then got removed during un-install). To fix

cd /usr/lib
sudo rm libpq.5.dylib
sudo ln -s libpq.5.3.dylib libpq.5.dylib


Then run apachectl configtest again to check for further errors.