Configure Apache to run CGI program

Source: Internet
Author: User

Configure CGI program run in Apache. cgi configuration outside the cgiscriptalias directory in the [hide] ScriptAlias directory can be divided into two situations: cgi in the ScriptAlias directory, the second is CGI in a directory other than ScriptAlias. The cgiscriptalias command in the ScriptAlias directory allows Apache to execute CGI programs in a specific directory. When the client requests resources in a specific directory, Apache assumes that all files in the directory are CGI programs and tries to run them. The ScriptAlias command is like: CGI outside the ScriptAlias/cgi-bin // usr/local/Apache/cgi-bin/ScriptAlias directory for security reasons, CGI programs are usually restricted in the directory specified by ScriptAlias, so that the administrator can strictly control who can use CGI programs. However, if appropriate security measures are taken, there is no reason not to allow CGI programs in other directories to run. For example, you may want users to store pages in the home directory specified by userdir, but they have their own CGI programs, but do not have access to the cgi-bin directory, the requirement to run CGI programs in other directories is generated. 1. explicitly allow CGI execution with options. You can use the Options command to explicitly allow CGI execution in a specific directory in the master server configuration file: the <directory/usr/local/Apache/htdocs/somedir> options + execcgi </directory> command allows Apache to execute cgi files. In addition, you must tell the server which files are cgi files. The following addhandler Command tells the server that all the files with CGI or PL suffixes are CGI programs: addhandler CGI-script CGI pl2 ,. htaccess file. the htaccess file is a method for directory configuration. When apache provides a resource, it searches for the. htaccess file in the directory where the resource is located. If yes, the command takes effect. The AllowOverride command determines whether the. htaccess file is valid. It specifies which commands can appear or are not allowed at all. Therefore, you need to configure AllowOverride options in the master server configuration. In the. htaccess file, you need to configure options + execcgi so that Apache can allow the execution of CGI programs in this directory. Finally, you can write a CGI program for testing, such :#! /Usr/bin/perlprint "Content-Type: text/html \ n"; print "Hello, world."; reference: Plain

Configure Apache to run CGI program

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.