In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
CGI(Common Gateway Interface) defines how a Web server interacts with external content generation programs, often referred to as CGI programs or CGI scripts. This is an easy way to put dynamic content on your website using the programming language you are most familiar with.
Configuring Apache to Allow CGI
For CGI programs to work properly, Apache needs to be configured to allow CGI execution. There are several ways to do this.
Method 1: ScriptAlias command
The ScriptAlias directive tells Apache to set aside a specific directory for CGI programs. Apache assumes that every file in this directory is a CGI program and attempts to execute that program when a client requests that particular resource.
The ScriptAlias command looks like this:
ScriptAlias "/cgi-bin/" "/usr/local/apache2/cgi-bin/"
If Apache is installed in the default location, the example shown can be found in the default httpd.conf configuration file.
The ScriptAlias directive is much like the Alias directive in that it defines a URL prefix that maps to a specific directory. Alias and ScriptAlias are typically used for directories other than the DocumentRoot directory.
The difference between Alias and ScriptAlias is that ScriptAlias has the additional meaning that everything under that URL prefix is considered a CGI program.
Thus, the example above tells Apache that any request for a resource that starts with/cgi-bin/should be served in the directory/usr/local/apache2/cgi-bin/and should be treated as a CGI program.
For example, if the URL http://www.example.com/cgi-bin/test.pl is requested, Apache will attempt to execute the file/usr/local/apache2/cgi-bin/test.pl and return output. Of course, the file must exist and be executable and return output in a certain way, otherwise Apache will return an error message.
Option 2: CGI outside the ScriptAlias directory
For security reasons, CGI programs are usually limited to ScriptAlias directories. In this way, administrators have tight control over who is allowed to use CGI programs. However, if proper security precautions are taken, there is no reason why CGI programs cannot be run from arbitrary directories.
For example, you might want to use the UserDir directive to let users own Web content in their home directories. If they want to have their own CGI programs but cannot access the main cgi-bin directory, they need to be able to run CGI programs elsewhere.
There are two steps to allowing CGI to be executed in arbitrary directories. First, the cgi-script handler must be activated using the AddHandler or SetHandler directive. Second, you must specify ExecCGI in the Options directive.
Option 3: Use Options to allow CGI execution
The Options directive can be explicitly used in the main server configuration file to specify that CGI is allowed to execute in specific directories:
Options +ExecCGI
The instructions above tell Apache to allow CGI files to be executed. You also need to tell the server which files are CGI files. The following AddHandler directive tells the server to treat all files with cgi or pl extensions as CGI programs:
AddHandler cgi-script .cgi .pl
Mode 4: User Directory
To allow CGI programs to execute in any file ending in.cgi in the user directory, you can use the following configuration.
Options +ExecCGI AddHandler cgi-script .cgi
If you want to specify the cgi-bin subdirectory of the user directory, where everything will be treated as CGI programs, you can use the following command.
Options ExecCGI SetHandler cgi-script
So how does Apache make CGI work? For more details, please pay attention to other related articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.