Java運行環境配置之(Resin配置、域名邦定、IIS整合)

2005-12-27 11:05:27  作者:bluepoint  來源:71i.net 網友評論 0 條 論壇 <script src="../Hits.asp?ArticleID=5884" type="text/javascript"></script> 4898
  N久前,開始用Java做程序了,但一直被虛擬機的問題所困,讓我最難過的是不會邦定域名,找了好多網上的資料都不管用,真是鬱悶啊。

今天我給大家共享一下我的配置方法:

Resin 2.1.14 + Mysql 2.23 + J2sdk 1.4.2

需要軟件:

Resin 2.1.14 下載:http://www.caucho.com/download/index.xtp
MySQL 2.23 下載:http://www.mysql.com
J2sdk 1.4.2 下載:http://java.sun.com/j2se/1.4.2/download.html

一、MySQL的安裝
   1、解壓縮mysql.zip
    2、運行setup.exe安裝文件
   3、下一步,這裏只要選擇一下你安裝目錄
   4、安裝結束後,進入您的MySQL安裝目錄下的bin目錄,運行winmysqladmin.exe,稍等一會,它會要求您輸入用戶名與密碼(根據您的情況輸入)
   5、MySQL完成安裝

二、J2sdk的安裝(以下簡稱JDK)
   1、運行安裝文件
   2、下一步,同上(選擇目錄)
   3、安裝結束後,進入您的JDK安裝目錄,複製其它路徑(如: C:/j2sdk1.4.2)
   4、右擊“我的電腦”,“屬性”,“高級”,“環境變量”,增加一個系統變量,名稱:JAVA_HOME 值:上面要求複製的JDK安裝目錄(我的是: C:/j2sdk1.4.2),確定
   5、修改“系統變量path”在其後加一值: 爲JDK安裝目錄下的bin目錄,(如: C:/j2sdk1.4.2/bin),確定
   6、測試JDK,點擊“開始”,“運行”,“cmd”,“java”回車
   7、返回信息
插入代碼: 以下是引用片段:
C:/Documents and Settings/QiChao>java 
Usage: java [-options] class [args...] 
      (to execute a class) 
  or java [-options] -jar jarfile [args...] 
      (to execute a jar file) 

where options include: 
   -client    to select the "client" VM 
   -server    to select the "server" VM 
   -hotspot   is a synonym for the "client" VM [deprecated] 
          The default VM is client. 

   -cp <class search path of directories and zip/jar files> 
   -classpath <class search path of directories and zip/jar files> 
          A ; separated list of directories, JAR archives, 
          and ZIP archives to search for class files. 
   -D<name>=<value> 
          set a system property 
   -verbose[:class|gc|jni] 
          enable verbose output 
   -version   print product version and exit 
   -showversion print product version and continue 
   -? -help   print this help message 
   -X      print help on non-standard options 
   -ea[:<packagename>...|:<classname>] 
   -enableassertions[:<packagename>...|:<classname>] 
          enable assertions 
   -da[:<packagename>...|:<classname>] 
   -disableassertions[:<packagename>...|:<classname>] 
          disable assertions 
   -esa | -enablesystemassertions 
          enable system assertions 
   -dsa | -disablesystemassertions 
          disable system assertions 

C:/Documents and Settings/QiChao>
如果你看到以上信息,說明你安裝成功啦!

三、Resin的安裝

   很簡單,解壓resin-2.1.14.zip解壓到你想要的目錄

四、虛擬機測試

   啓動resin目錄下的bin/httpd.exe,等待啓動結束

   訪問http://127.0.0.1:8080
  
    如果您看到Resin歡迎頁就說明OK了

五、域名的配置

   打開conf/resin.conf(記事本方式)

   同Tomcat找到...元素,添加一個Host
插入代碼: 以下是引用片段:
<!--id 爲域名--> 
  <host id=’www.71i.net’> 
     <!--文件、目錄式配置,這裏爲項目路徑--> 
<app-dir>D:/Bluepoint Developers Program/exploded</app-dir> 
     <!--日誌文件,不要可註釋--> 
<access-log id=’logs/access.log’ format=’%h %l %u %t "%r" %s %b "%{Referer}i" "%{User-Agent}i"’ rollover-period=’1W’/> 
<!--出錯信息,不要可註釋--> 
<error-log id=’logs/error.log’/> 
<!--class文件路徑--> 
<classpath id=’WEB-INF/classes’ source=’WEB-INF/classes’ compile=’true’/> 
<!--禁止目錄訪問 打開--> 
<directory-servlet>none</directory-servlet> 
  </host>
這裏數據庫連接池、SESSION等用戶可以在項目中配置
插入代碼:
以下是引用片段:
<!--連接池配置方法--> 
<resource-ref> 
  <res-ref-name>jdbc/test</res-ref-name> 
  <res-type>javax.sql.DataSource</res-type> 
  <init-param driver-name="com.caucho.jdbc.mysql.Driver"/> 
  <init-param url="jdbc:mysql_caucho://127.0.0.1:3306/test"/> 
  <init-param user="root"/> 
  <init-param password="123456"/> 
  <init-param max-connections="20"/> 
  <init-param max-idle-time="30"/> 
</resource-ref>
六、與Windows Internet信息服務器同步運行

   1、建立一個新站點
   2、設置主目錄到“項目路徑”
   3、在IIS“ISAPI篩選器”中添加,篩選器名稱:scripts 可執行文件: 在“項目目錄”下建立一個“scripts”目錄,將Resin的libexec下的isapi_srun.dll文件考入其下,選擇他爲“可執行文件”
   4、在此站點下建立一個“虛擬目錄”,名稱爲“scripts”路徑爲“工程路徑”下的“scripts目錄”
   5、重起IIS,啓動Resin,瀏覽!!!

你將你的域名IP指向你的服務器,OK,指向成功後你訪問吧,呵呵!!

此文章由Bluepoint獨立完成,轉載請註明出處!
插入代碼: 以下是引用片段:
2005-12-27 添加以下內容: 
   上次忘了告訴大家如何在服務器上讓他自動運行了: 
   步驟:開始 ------ 運行 --------- CMD -------- 進入Resin/bin目錄 ------ 輸入 httpd -install 

    如:C:/resin 2.1.14/bin>httpd -install 
    你就會在系統的服務器發現 Resin web server 這個服務 

   要取消 請輸入 httpd - remove 

    如:C:/resin 2.1.14/bin>httpd -remove
 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章