Tomcat7 部署CGI程序
2016-02-24 14:01
495 查看
部署环境:
1. ubuntu14.04.3_x64
2. jdk1.7.0_79
3. apache-tomcat-7.0.63
Apache官方参考资料: CGI How To
1) 修改
根据
2) 修改
在原来的基础上将Context部分添加上
python
Perl
1. ubuntu14.04.3_x64
2. jdk1.7.0_79
3. apache-tomcat-7.0.63
Apache官方参考资料: CGI How To
1) 修改$CATALINA_HOME/conf/web.xml
<!-- The CGI Gateway servlet --> <servlet> <servlet-name>cgi</servlet-name> <servlet-class>org.apache.catalina.servlets.CGIServlet</servlet-class> <init-param> <param-name>debug</param-name> <param-value>0</param-value> </init-param> <init-param> <param-name>cgiPathPrefix</param-name> <param-value>WEB-INF/cgi</param-value> </init-param> <load-on-startup>5</load-on-startup> </servlet> <!-- The mapping for the CGI Gateway servlet --> <servlet-mapping> <servlet-name>cgi</servlet-name> <url-pattern>/cgi-bin/*</url-pattern> </servlet-mapping>
根据
web.xml中的描述,关于
executable部分,默认值如下
<!-- if you leave the param blank it will run any script type. --> <init-param> <param-name>executable</param-name> <param-value></param-value> </init-param>
2) 修改$CATALINA_HOME/conf/context.xml
<Context privileged="true"> ... </Context>
在原来的基础上将Context部分添加上
privileged="true"
3) 目录结构
|-tomcat |--webapps |---cgi-example |----WEB-INF |-----cgi |------first.py |------second.pl
4) 启动Tomcat
user@ubuntu:/opt/tomcat7/bin $./startup.sh
5) 访问路径
http://localhost:8080/cgi-example/cgi-bin/first.py
http://localhost:8080/cgi-example/cgi-bin/second.pl
附录
python first.py
#! /usr/bin/python print "content-type: text/html" print "" print "<html><head><title>Welcome</title></head>" print "<body><h1>Welcome to the output of a CGI under Tomcat</h1>" print "<p>The subject says all.</p>" print "</body></html>"
Perl second.pl
#! /usr/bin/perl print "content-type: text/html"; $now = localtime(); print "<h1>It is $now</h1>";
相关文章推荐
- IDEA 配置 tomcat 启动内存
- Tomcat7调试运行环境搭建与源代码分析入门
- TOMCAT源码分析(启动框架)
- tomcat6虚拟目录的配置
- 闲谈Tomcat性能优化
- tomcat7-maven-plugin部署项目到远程tomcat报错
- Tomcat无法启动A child container failed during start
- Tomcat6的配置参数
- tomcat根目录下文件
- Tomcat 的设计模式分析
- tomcat的安装和配置
- tomcat端口占用无法启动的解决方法
- 更改Eclipse下Tomcat的部署目录
- taglib definition not consistent with specificatio
- 【Nginx入门系列】第六章 Nginx+tomcat集群负载均衡部署
- 【Nginx入门系列】第五章 tomcat在linux下的安装和集群预部署
- liunx下tomcat的安装以及详解
- Web服务器父与子 Apache和Tomcat区别
- Tomcat输出catalina.out的大小控制
- IntelliJ IDEA JRebel Maven Tomcat 实现热部署