Apache脚本路径别名(CGI接口)

CGI:Common Gateway Interface(通用网关接口)使WEB可以跟一个应用程序进行通信,从通信环境中获得结果。

CGI是不安全的,需要mod_alias,mod_cgi模块

ScriptAlias /URL/ "/path/to/somewhere" somewhere下的文件可以被执行,也可以在目录中实现

格式一般为:编辑vim /URL/test加入

#!/bin/bash

cat << EOF

Content-Type: text/html

<pre>

<h1>The hostname is : `hostname`</h1>

The time is : `date`.

</pre>

EOF

测试地址:http://ServerIP/URL/test显示结果为:

The hostname is : master.fansik.com

The time is : Thu Jun 30 10:57:36 CST 2016.

原文地址:https://www.cnblogs.com/fansik/p/5633522.html