I have a web server running on my Mac and I'd like to be notified (via Growl for example) when someone accesses my server.
I searched for something like that in Automator but found nothing.
Do you know if this is possible ?
The key is your access logs. Assuming your webserver is properly configured, each time a page is served it should provide some level of detail in the access logs. This can be turned off for sites with enourmous traffic loads, but for your bog standard (assuming) apache install on a local machine I imagine you are not looking as a massive load.
So, what you need is a method to examine the access log periodically (or real time) either by checking timestamps, or tailing the content etc. Once this is sorted, you need a way to push it into growl. Growlnotify is a command line utility that will accept output from other commands and use it as the basis to provide a graphical growl notification.
At this point you need to decide if you want a simple "You have visitors!" message, or something that includes the details, say which page was served to which IP address etc. That's your choice, and makes the code you need to write that bit more complex or simple.
Check the following example (sorry, I use ksh, you may need to modify):
Obviously this will churn out far too much info and be generic, so you need to add your own special blend of a) configuring Apache to only log to the level you need, and b) filter out the entries anyway, possibly formatting while you go, e.g.:
Throw this into an automator service, and away you go.
One of the most powerful methods of getting notifications from a web server is to build in support for webhooks. The fine folks behind this software stack have a nice blog that helps describe how this might work if you wanted to code this into the web site.