Let Apache support CGI, SSI, shtml configuration Methods _linux

Source: Internet
Author: User

1. First clear, only can specify a certain directory, support CGI, that is, run the directory to execute the CGI program, otherwise not very safe.
Find:

Copy Code code as follows:

#
# "C:/Program Files/apache group/apache/cgi-bin" should be changed to whatever your
# CGI Directory exists, if you are have that configured.
#
<directory "e:/website_field/cgi" >
AllowOverride All
Options All
Order Allow,deny
Allow from all
</Directory>

Set directory to be able to execute CGI

2.
Find:

Copy Code code as follows:

#
# Scriptalias:this controls which directories contain server scripts.
# scriptaliases are essentially the same as aliases, except that
# documents in the Realname directory are treated as applications and
# run by the ' server when requested rather than as documents sent to the client.
# The same rules about trailing "/" apply to scriptalias directives as to
# Alias.
#
scriptalias/cgi-bin/"e:/website_field/cgi"

Change the following directory to the same as above.

3.
Set the suffix of the CGI script to look for:

Copy Code code as follows:

#
# AddHandler allows you to the map certain file extensions to "handlers",
# actions unrelated to filetype. These can is either built into the server
# or added with the Action command (below)
#
# If you are want to use server side includes, or CGI outside
# scriptaliased Directories, uncomment the following lines.
#
# to use CGI scripts:
#
AddHandler cgi-script. cgi. pl

Set suffixes such as. CGI,. PL, and so on, any conceivable, but avoid the use of existing such as. html,. asp,. PHP, etc.

Note: After you set up a directory that supports CGI, the contents of the directory and the contents of the subdirectory can be executed.

Configure Apache to support SSI, that is, server-side parsed server-parsed HTML (shtml)
For more information on what SSI is and what is shtml, see the other two articles from this site.
Use SSI to implement Dynamic HTML embedded content, for SSI commands, even system return results, and more commonly called Perl programs (especially Perl CGI return results)

1. Configure Apache:
1) First find:

Copy Code code as follows:

#
# to use server-parsed HTML files
#
AddType text/html. shtml
AddHandler server-parsed. shtml

Remove the # number before the second line;
2 at the same time need to specify which directory in which to support this resolution, looking for:

Copy Code code as follows:

#
# "C:/Program Files/apache group/apache/cgi-bin" should be changed to whatever your
# CGI Directory exists, if you are have that configured.
#
<directory "E:/website_field/shtml" >
AllowOverride All
Options All
Order Allow,deny
Allow from all
</Directory>

To start a modification from your directory:
First assign to your own directory, here is "e:/website_field/shtml";
Then set each option as above:

Copy Code code as follows:

AllowOverride All
Options All
Order Allow,deny
Allow from all

When you're done, restart Apache.

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

3. An shtml Page instance using SSI:
1), index.shtml

Copy Code code as follows:

<title>shtml</title>
<body>
<!--#config timefmt= "%d"-->
This file is last modified <!--#echo var= "last_modified"--><br/>
<!--#config timefmt= "%A%B%d,%Y"-->
Today's <!--#echo var= "date_local"--><br/>
<!--#include virtual= "embed.html"--><br/>
<!--#exec cmd= "test.pl"--><br/>
<!--#exec cmd= "dir"--><br/>
</body>

2), embed.html

Copy Code code as follows:

<title>embed html</title>
<body>
This are the content from embed.html
</body>

3), test.pl

Copy Code code 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 ();

Summarize:
When you set Apache support for CGI and support SSI, you have the same section, set directory directory, and need to be set to the same.
Therefore, if you use SSI alone, you can configure it according to the SSI settings and place the shtml in the set directory;
If you have set up Apache to support CGI, just open the SSI and place files such as shtml into 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.