On most Linux distribution, it is impossible to access a serial port (ex. /dev/ttyS0) from a web server such as Apache or lighttpd using a cgi. Simply add the user under which the web server runs (www-data for example) to the group dialout. To do so, use vigr from the command line and add the user on the dialout group line. Such a line will typically look like:

dialout:x:20:myuser,www-data