Forum Moderators: phranque

Message Too Old, No Replies

HTML files and PL files in same directory

HTML files and PL scripts in same directory displaying properly

         

tyatpi

12:08 am on Jun 28, 2011 (gmt 0)

10+ Year Member




Hello all,

I am trying to get regular HTML and particularly, SHTML files to display properly from directories with ExecCGI enabled. The PL files themselves work fine.

I am getting 500 errors with regular files. The error log says it is "Premature end of script headers: rules.shtml"

This is my httpd.conf file on the directories in question. The /contest/ directory on the site has the problem this post is about.

Listen 127.0.0.3:8080
<VirtualHost 127.0.0.3:8080>
DocumentRoot /home/tyler/piwebsolutions.ca/website
ServerName testtrunk.piwebsolutions.ca
ErrorLog /home/tyler/piwebsolutions.ca/website/logs/apache.error.log
TransferLog /home/tyler/piwebsolutions.ca/website/logs/apache.xfer.log
ErrorDocument 401 /401.shtml
ErrorDocument 403 /403.shtml
ErrorDocument 404 /404.shtml
</VirtualHost>

#CGI BIN
ScriptAlias /contest/ /home/tyler/piwebsolutions.ca/website/contest/

<Directory /home/tyler/piwebsolutions.ca/website/bbq/>
AddHandler script .pl
Options +ExecCGI
</Directory>
<Directory /home/tyler/piwebsolutions.ca/website/contest/>
Options +ExecCGI
</Directory>
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml


The /bbq/ directory however, has the OPPOSITE problem I am describing! HTML and SHTML files display properly, but Perl CGI scripts will not run and instead the .pl file is downloaded like any other MIME type.

phranque

10:42 am on Jun 28, 2011 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



for the /bbq/ problem try:

AddHandler cgi-script .pl


for the /contest/ problem:
your ScriptAlias directive means if you request a url such as:
http://example.com/contest/rules.shtml
then it will try to run rules.shtml as a CGI script instead of SSI.
http://httpd.apache.org/docs/2.0/mod/mod_alias.html#scriptalias:
The ScriptAlias directive ... marks the target directory as containing CGI scripts that will be processed by mod_cgi's cgi-script handler.

it's also unnecessary because you can process scripts in that directory with:

Options +ExecCGI

tyatpi

4:38 pm on Jun 28, 2011 (gmt 0)

10+ Year Member



Thank you phranque.

I will try those again tonight. I have been playing with those changes last night, but I was unable to get both pl files and html files to work.

Is it correct that ScriptAlias will make all files in a directory run as scripts? I tried just and Alias with a <Directory...>Options+ExecCgi</Directory> but also not working.

tyatpi

7:38 pm on Jun 28, 2011 (gmt 0)

10+ Year Member



Thanks for the advice, I have updated:

<Directory /home/tyler/piwebsolutions.ca/website/bbq/>
AddHandler script .pl
Options +ExecCGI
</Directory>

now HTML and SHTML files work fine, but scripts will be downloaded instead of run! I have refreshed and deleted all browser history. The perl script runs without error on the command line.

phranque

9:24 pm on Jun 28, 2011 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



AddHandler cgi-script .pl

tyatpi

4:58 pm on Jul 2, 2011 (gmt 0)

10+ Year Member



Thank you.

The following is working as I want it.


Alias /bbq/ /home/tyler/piwebsolutions.ca/website/bbq/
<Directory /home/tyler/piwebsolutions.ca/website/bbq/>
AddHandler cgi-script .pl
Options +ExecCGI
</Directory>