Windows下WEB伺服器的選擇與搭建

來源:互聯網
上載者:User

標籤:

  本文主要基於支援perl的web伺服器的選擇。

  一直基於web開發,伺服器都是linux下使用webmin搭建的,慚愧的說一句,這麼多年,也好好研究過WEB伺服器,單從這個角度,是不是可以反應出webmin架構和俺們產品的build做得還算OK呢,才可以讓大傢伙將更多的精力集中,自身產品的業務上,而不用每個人都更多花大量時間在一些早已成熟的技術上,如果每個產品都以這個思想來做,那麼這個社會將有更少的重複勞動,和更高效的產出,扯遠了,回來繼續關於Windows下搭建web伺服器。

  A long time ago, Windows included a simple program called Personal Web Server (PWS) which provided an easy little webserver to use with Perl. With the release of Windows ME and XP, PWS was discontinued and replaced with Internet Information Server, known as IIS. Last time I tried, which I freely admit was quite a while ago now, configuring IIS for use with Perl was not that easy. There are simpler ways of doing it.

  If you just want a simple webserver to test with, I recommend a different webserver than IIS. This webserver is free, and is well documented. You can find it at Aprelium. Look for the Abyss Web Server X1. It works very well and is much easier to set up than IIS. The exact configuration details are spelled out in the documentation for the X1 server so I won‘t repeat them here. But I think you‘ll find it is pretty easy to install and set up.

  If you want something more configurable and powerful, you can‘t go wrong with the Apache webserver, which is available for Windows just as readily as for Linux. Again, the exact configuration details are not provided here, since there is Apache documentation for this. However, if enough users ask for explicit instructions to be included here, start asking by email, and I‘ll add them in.

1       PWS(perlwerbserver)

         2000後不再維護和使用,使用方法參考文檔較少,初測發現windows下使用,服務經常會停止。不推薦使用。

install web server:https://www.gossland.com/perlcourse/default/install_pws.html

perlwebserver by 2000 year:http://perlwebserver.sourceforge.net/

2       Aprelium

         下載Abyss Web Server X1免費版本後,嘗試安裝,報錯,無法安裝成功,看來免費版本錯誤處理及冗錯做得不是太好,未做更多嘗試。

aprelium:http://www.aprelium.com/

3       基於apache的WEB伺服器

如今主流的Web伺服器軟體主要由IIS或Apache組成。IIS支援ASP且只能運行在Windows平台下,Apache支援PHP,CGI,JSP且可運行於多種平台,雖然Apache是世界使用排名第一的Web伺服器平台,但是眾所周知,Windows以易用而出名,也因此佔據不少的伺服器市場。本專題我們把Web伺服器劃分為Windows平台和Linux平台(包括各種Unix)。

 

簡易過程

  1、安裝apache WEB伺服器

  2、運行第一個apache WEB頁面

        開啟服務,管理->服務,運行apache。

    服務開啟後,通過瀏覽器訪問127.0.0.1,apache伺服器會預設去安裝目錄的htdocs目錄下開啟預設已存在的index.html。

  3、安裝perl解譯器

  4、配置apache允許開啟CGI頁面

    設定檔目錄,安裝目錄下的conf目錄,修改httpd.conf檔案,DirectoryIndex index.html index.cgi(加入index.cgi)

  5、運行第一個cgi頁面

    將程式放到apache安裝目錄的cgi-bin目錄下,通過web訪問http://127.0.0.1/cgi-bin/index.cgi即可。

index.cgi:#!c:/perl/bin/perl(perl的安裝目錄)use CGI qw(:standard);use strict; print header;print "<B>it works ! hello world</B>";

 

  6、使用模版方式,將html從CGI中分離

index.cgi:#!c:/perl/bin/perluse strict; print "Content-type: text/html\n\n";print &Template("../htdocs/index.html"); sub Template{  my $file;  my $HTML;  $file = $_[0] || die "Template: No template file specified.\n";  open (FILE,"<$file") || die "Template: Couldn‘t open $file:$!\n";  while (<FILE>) { $HTML .= $_; }  close(FILE);  #下面兩個語句實現的功能相同  $HTML =~ s/(\$\w+)/eval "$1"/ge;  #$HTML =~ s/\$(\w+)/${$1}/g;  return $HTML;}

 

 

參考文獻

WEB伺服器搭建:

http://school.cfan.com.cn/zhuanti/webserver/

apache WEB伺服器搭建:

http://carywu.blog.51cto.com/13185/9551

基於apache的perl實現動態網頁面:

http://www.oschina.net/question/17_71

CGI配合HTML模板使用:

http://www.linuxfly.org/post/335/

Windows下WEB伺服器的選擇與搭建

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.