"Adam D. Ruppe" <destructiona...@gmail.com> wrote in message news:iq6osh$25di$1...@digitalmars.com... > Nick Sabalausky wrote: >> Actually, I did have to remove the HTTP status code output from my >> little hello world cgi test in forder for Apache to not throw up a >> 500. > > HTTP status is normally done with a Status: header in cgi. (Actually > writing the line works too but only with certain settings.) > > writefln("Status: 200 OK"); // note: optional; 200 OK is assumed > writefln("Content-Type: text/plain"); > writefln(); // blank line ends headers > writefln("Hello, world!"); >
Ahh, sweet. Didn't know about that "Status:" thing. Or maybe I did and forgot... ;) BTW, another thing I just learned (posting here in case anyone reads this and has similar problems) is that on some servers, like mine, the permissions on the executable have to be set to *not* be writable by group or world, or Apache will just throw a 500. Apperently there's a whole list of conditions that have to be met here: http://httpd.apache.org/docs/current/suexec.html When I first compiled the app on my local CentOS VM, gcc set the binary's permissions to 775, which were preserved by ftp, and then I could run it on the server through ssh, but not through Apache/HTTP. Changing them to 755 fixed it. > I just saw this thread, but when I do my cgi apps, I actually > recompile them right on the live server. If that's an option > for you, it's a bit of a pain to set up, but it's less painful > than dealing with Linux's generally retarded library/bits situation. Yea, that would definitely a better way to go. Unfortunately I normally have to deal with shared hosts, so the stuff I can actually do on the server is usually very limited. On this particular server, I know I can't run gcc. (At least not the system's gcc anyway. Maybe there's some way to have a portable install of gcc? But knowing gcc, if there is a way, I'm sure it would be a royal pain.) DMD *is* a portable install, which is nice, but on linux it still needs gcc to link. And then on the other server I need to use, I don't think ssh is even available.