欧美三区_成人在线免费观看视频_欧美极品少妇xxxxⅹ免费视频_a级毛片免费播放_鲁一鲁中文字幕久久_亚洲一级特黄

讓Tomcat支持PHP

系統(tǒng) 1992 0
  在負(fù)責(zé)一個(gè)采用JSP動(dòng)態(tài)網(wǎng)頁(yè)技術(shù)的網(wǎng)站時(shí),剛好手頭有PHP寫(xiě)的一部分功能,所以就很直接地想到讓Tomcat支持PHP。Tomcat也是Apache出的,難道就只支持JSP嗎?到底能否在Tomcat上用PHP呢?上網(wǎng)搜索了一番,很快有了第一個(gè)問(wèn)題的答案:Tomcat可以支持CGI,如Perl(具體設(shè)置見(jiàn)附文)。但繼續(xù)搜索,卻遲遲無(wú)法找到讓Tomcat使用PHP的方法,一般都是采取裝Apache和Tomcat共存的方法來(lái)搭建所謂的支持PHP+JSP的Web平臺(tái)。
  當(dāng)然,其實(shí)PHP本身也支持CGI方式的使用,所以就自己動(dòng)手試了一試(在Windows操作系統(tǒng)上):先按照附文的做法讓Tomcat支持CGI,然后再改web.xml,在servlet-name為cgi的一段配置中加上:
???? < init-param >
????????
< param-name > executable </ param-name >
????????
< param-value > php </ param-value >
????
</ init-param >
并把PHP安裝路徑加入Path,這樣Tomcat就能運(yùn)行到PHP.exe了。重啟Tomcat后,在WEB-INF目錄下新建一個(gè)cgi目錄,把php文件放在這里,然后訪問(wèn)時(shí)用虛擬映射出來(lái)的cgi-bin目錄來(lái)訪問(wèn)這些PHP文件。
  但是如果對(duì)PHP文件不加任何改動(dòng)的話,可能會(huì)發(fā)現(xiàn)什么輸出都沒(méi)有。需要在PHP文件頭部加一行,輸出兩個(gè)回車:
echo? " \n\n " ;
原因不太清楚。可能在等待Content-type輸入,或是Perl的cgi程序風(fēng)格。
  但這樣配置,PHP(4.1.0以上版本)中$_REQUEST、$_GET、$_POST等變量就無(wú)法用了,只能從服務(wù)器變量或環(huán)境變量中獲取QueryString了:$_SERVER["QUERY_STRING"]、$_ENV["QUERY_STRING"]。也許不支持表單的POST提交了……具體還沒(méi)試過(guò)。
  由于對(duì)Tomcat不熟悉,所以這些只是在現(xiàn)在方法上的小修小補(bǔ),可能有好的做法,還希望大家不吝指教!

附:
Using CGI Scripts with Tomcat
Tomcat is primarily meant to be a servlet/JSP container, but it has many capabilities rivalling a traditional web server. One of these is support for the Common Gateway Interface (CGI), which provides a means for running an external program in response to a browser request, typically to process a web-based form. CGI is called "common" because it can invoke programs in almost any programming or scripting language: Perl, Python, awk , Unix shell scripting, and even Java are all supported options. However, you probably wouldn't run a Java application as a CGI due to the start-up overhead; elimination of this overhead was what led to the original design of the servlet specification. Servlets are almost always more efficient than CGIs because you're not starting up a new operating-system-level process every time somebody clicks on a link or button.
Tomcat includes an optional CGI servlet that allows you to run legacy CGI scripts; the assumption is that most new back-end processing will be done by user-defined servlets and JSPs.
To enable Tomcat's CGI servlet, you must do the following:
  1. Rename the file servlets-cgi.renametojar (found in CATALINA_HOME/server/lib/ ) to servlets-cgi.jar , so that the servlet that processes CGI scripts will be on Tomcat's CLASSPATH .
  2. In Tomcat's CATALINA_BASE/conf/web.xml file, uncomment the definition of the servlet named cgi (this is around line 241 in the distribution).
  3. Also in Tomcat's web.xml , uncomment the servlet mapping for the cgi servlet (around line 299 in the distributed file). Remember, this specifies the HTML links to the CGI script.
  4. Either place the CGI scripts under the WEB-INF/cgi directory (remember that WEB-INF is a safe place to hide things that you don't want the user to be able to view, for security reasons), or place them in some other directory within your context and adjust the cgiPathPrefix initialization parameter of the CGIServlet to identify the directory containing the files. This specifies the actual location of the CGI scripts, which typically will not be the same as the URL in the previous step.
  5. Restart Tomcat, and your CGI processing should now be operational.
The default directory for the servlet to locate the actual scripts is WEB-INF/cgi . As has been noted, the WEB-INF directory is protected against casual snooping from browsers, so this is a good place to put CGI scripts, which may contain passwords or other sensitive information. For compatibility with other servers, though, you may prefer to keep the scripts in the traditional directory, /cgi-bin , but be aware that files in this directory may be viewable by the curious web surfer. Also, on Unix, be sure that the CGI script files are executable by the user under which you are running Tomcat.

讓Tomcat支持PHP


更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號(hào)聯(lián)系: 360901061

您的支持是博主寫(xiě)作最大的動(dòng)力,如果您喜歡我的文章,感覺(jué)我的文章對(duì)您有幫助,請(qǐng)用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點(diǎn)擊下面給點(diǎn)支持吧,站長(zhǎng)非常感激您!手機(jī)微信長(zhǎng)按不能支付解決辦法:請(qǐng)將微信支付二維碼保存到相冊(cè),切換到微信,然后點(diǎn)擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對(duì)您有幫助就好】

您的支持是博主寫(xiě)作最大的動(dòng)力,如果您喜歡我的文章,感覺(jué)我的文章對(duì)您有幫助,請(qǐng)用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長(zhǎng)會(huì)非常 感謝您的哦!!!

發(fā)表我的評(píng)論
最新評(píng)論 總共0條評(píng)論
主站蜘蛛池模板: 午夜爱爱爱爱爽爽爽网站免费 | 国产精品国产精品国产专区不卡 | 久久日本精品99久久久久 | 久久久午夜精品 | 欧美视频区| 久久国产精品久久 | 国产精品成人不卡在线观看 | 欧美另类视频一区二区三区 | 久久精品国产久精国产 | 五月色播影音在线观看 | 天天色影 | 国产欧美综合精品一区二区 | 黑人巨大videosjapan高清 婷婷在线免费观看 | 精品久久久久久 | 日韩久久一级毛片 | 日本黄色网址大全 | www操操| 久久久婷 | 亚洲人人精品 | 欧美精品九九99久久在观看 | 色婷婷久久久 | 日本一区午夜爱爱 | 黄色片视频观看 | 热国产热综合 | 欧美精品亚洲 | 国产成人精品日本亚洲麻豆 | 久久综合综合久久 | 草草国产成人免费视频 | 成人一区专区在线观看 | 国产精品毛片久久久久久久 | 国产成人综合自拍 | 国产国产成人久久精品杨幂 | 自拍偷拍av | 日韩精品视频在线免费观看 | 欧美日韩大尺码免费专区 | 久久88香港三级 | 久久成年人视频 | 久章操 | 老司机免费福利视频无毒午夜 | 成人欧美一区在线视频在线观看 | aaaaaaa片毛片免费观看 |