How to configure Apache to support cgi, SSI, and shtml

Source: Internet
Author: User

1. First, it is clear that only a fixed directory can be specified. cgi is supported, that is, the cgi program is run in this directory; otherwise, it is not safe.
Search:

Copy codeThe Code is as follows :#
# "C:/Program Files/Apache Group/Apache/cgi-bin" shocould be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.
#
<Directory "E:/Website_Field/cgi">
AllowOverride all
Options all
Order allow, deny
Allow from all
</Directory>

Set Directory to a Directory that can execute cgi

2.
Search:

Copy codeThe Code is as follows :#
# ScriptAlias: This controls which directories contain server scripts.
# ScriptAliases are essential the same as Aliases, doesn't that
# Events in the realname directory are treated as applications and
# Run by the server when requested rather than as your ents sent to the client.
# The same rules about trailing "/" apply to ScriptAlias directives as
# Alias.
#
ScriptAlias/cgi-bin/"E:/Website_Field/cgi"

Change the following directory to the same as the preceding directory.

3.
Set the suffix of the cgi script to search:

Copy codeThe Code is as follows :#
# AddHandler allows you to map certain file extensions to "handlers ",
# Actions unrelated to filetype. These can be either built into the server
# Or added with the Action command (see below)
#
# If you want to use server side except des, or CGI outside
# ScriptAliased directories, uncomment the following lines.
#
# To use CGI scripts:
#
AddHandler cgi-script. cgi. pl

Set the suffix such as. cgi,. pl, and so on. you can think of anything, but avoid using existing ones such as. html,. asp,. php, etc.

Note: After a cgi-supported directory is set, all contents in the directory and sub-directories can be executed.

Configure Apache to support SSI, that is, server-parsed html (shtml) parsed by the server)
For more information about SSI and shtml, see the other two articles on this site.
You can use SSI to dynamically embed html content. It can be an SSI command, or even a result returned by the system, or a commonly used Perl Program (especially the cgi return results of perl)

1. Configure Apache:
1) First find:

Copy codeThe Code is as follows :#
# To use server-parsed HTML files
#
AddType text/html. shtml
AddHandler server-parsed. shtml

Remove the # number before the last two rows;
2) at the same time, you need to specify the directory in which to support this resolution and find:

Copy codeThe Code is as follows :#
# "C:/Program Files/Apache Group/Apache/cgi-bin" shocould be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.
#
<Directory "E:/Website_Field/shtml">
AllowOverride all
Options all
Order allow, deny
Allow from all
</Directory>

Modify from Directory:
First, specify your own directory. Here is "E:/Website_Field/shtml ";
Then set the options as above:

Copy codeThe Code is as follows: AllowOverride all
Options all
Order allow, deny
Allow from all

Restart Apache.

2. For the SSI commands supported by Apache, refer to the following:
Http://www.jb51.net/tools/onlinetools/apache-chs/howto/ssi.html

3. A shtml page instance using SSI:
1)、index.shtml

Copy codeThe Code is as follows: <Head>
<Title> shtml </title>
</Head>
<Body>
<! -- # Config timefmt = "% D" -->
This file last modified <! -- # Echo var = "LAST_MODIFIED" --> <br/>
<! -- # Config timefmt = "% A % B % d, % Y" -->
Today is <! -- # Echo var = "DATE_LOCAL" --> <br/>
<! -- # Include virtual = "embed.html" --> <br/>
<! -- # Exec cmd = "test. pl" --> <br/>
<! -- # Exec cmd = "dir" --> <br/>
</Body>
</Html>

2)、embed.html

Copy codeThe Code is as follows: <Head>
<Title> embed html </title>
</Head>
<Body>
This is the content from embed.html
</Body>
</Html>

3) test. pl

Copy codeThe Code is as follows :#! C: \ perl \ bin \ perl-w
Use strict;

Sub print_header ()
{
Print "This is Header function! ";
}

Sub print_footer ()
{
Print "This is Footer function! ";
}

Print_header ();
Print_footer ();

Summary:
When you set Apache to support cgi and SSI, you must set the Directory to the same.
Therefore, if you use ssi, you can configure it according to the ssi settings, and place shtml and so on under the Set Directory;
If you have set Apache to support cgi, you only need to open ssi and place files such as shtml in the cgi directory.

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.