Apache cannot access files in the Cgi-bin directory

Source: Internet
Author: User

Apache cannot access files in the Cgi-bin directory


Turn from: http://www.cnblogs.com/shuang/archive/2008/12/08/1350718.htm



The reason I'm configuring Perl on my computer is always unsuccessful because I didn't get rid of the httpd.conf
scriptalias/cgi-bin/"#" in front of "f:/project/perl/cgi-bin/" (remove # and then back up Apache, from the taskbar's monitor Apache Servers, otherwise it will not work, It seems that Apache only uses httpd.conf files each time it is started, of course this is the Cgi-bin directory of the online tutorials, and my corresponding configuration is:
scriptalias/cgi-bin/"C:/Program Files/apache Software foundation/apache2.2/cgi-bin/" may also be associated with the installation path of Perl, I used Activeperl-5.10.0.1004-mswin32-x86-287188.msi, and I didn't put it together with Apache a few times, and finally I put Perl in the same level as Apache2.2, but forgot to create a directory for Perl, so it looked messy.

An error that has been reported as follows:

++++++++++++++++++++++++++++++++++
You cannot directly access the text document in this directory

Will complain:



+++++++++++++++++++++++++++++++++
Additional configuration about Perl:
<directory "d:/project/perl/cgi-bin/" >
AllowOverride All
Options All
Order Allow,deny
Allow from all
</Directory>
AddHandler cgi-script. cgi. pl. exe


++++++++++++++++++++++++++++++++++++++++++++
References: http://purpen.javaeye.com/blog/101328
Today I took a look at the Perl CGI tutorial, so I wanted to test the results, so I started the whole setup process.

Because, the previous did is PHP development, Apache has been installed successfully, and run normally (Installation path: E:/webserver/apache2), so, the installation of the apache2 is not more to explain. (Detailed reference: http://purpen.javaeye.com/admin/show/98673).

This highlights the Perl installation process and the configuration under Apache.

1, download the ActivePerl for Windows V5.8.8.820 (http://www.skycn.com/soft/1211.html) in the Windows environment.

2, decompression, double-click Activeperl-5.8.8.820-mswin32-x86-274739.msi installation. Here is the installation path, the default directory for Perl installation is C:\USR, and of course you can install it in any directory you like, and I'll put it in (e:/webserver/perl/, for ease of management)

3. Configure Apache to support CGI

Open httpd.conf Modifications:

scriptalias/cgi-bin/"f:/project/perl/cgi-bin/"
<directory "d:/project/perl/cgi-bin/" >
AllowOverride All
Options All
Order Allow,deny
Allow from all
</Directory>
AddHandler cgi-script. cgi. pl. exe


where "f:/project/perl/cgi-bin/" is the directory where I intend to store the *.pl script, and all the access rights to the directory are set. (Note Delete Front #, if any),

Here, the Apache Support perl/cgi environment is fully configured.

4. Create a hello.pl test in the F:project/perl/cgi-bin directory.
#!  E:/webserver/perl/bin/perl.exe #scriptname hello.pl print "content-type:text/html\n\n";   # This sentence must be written and written accurately. Print "Hello, world...\n";



Note: When you browse the CGI program with 500 errors, you can look at your program, is not to: #! E:/webserver/perl/bin/perl.exe begins.
Or no print "content-type:text/html;\n\n";

Run hello.pl, show up:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.