Freebsd 搭建 jsp+resin網站開發環境平台筆記

一、先安裝diablo-jdk1.5版本

1、下載diablo-jdk1.5

  • pkg_add diablo-jdk1.5
  • 安裝javavmwrapper

# cd /usr/ports/java/javavmwrapper

# make install clean

二、安裝resin3

1、cd /usr/ports/www/resin3

2、make WITH_APACHE2=yes install clean

 

The Resin Apache module mod_caucho has been activated in the Apache

configuration file, where you should also add a line to specify the location of

the Resin configuration server, for example:

<IfModule mod_caucho.c>

ResinConfigServer localhost 6802

</IfModule>

Resin is now installed in /usr/local/resin3

You may want to activate it in /etc/rc.conf:

隨機啟動resin3

resin3_enable=”YES”

Then start it:

手動 啟動 resin3

/usr/local/etc/rc.d/resin3.sh start

三、訪問http://ip:8080/可以看到resin的首頁

四、編寫測試jsp代碼

vi test.jsp 並放到/usr/local/resin3/webapps/ROOT/下面

 

###################test.jsp##########################

<%@page language=”java”%>

2+2=<%=2+2%>

<head>

<%@page language=”java”%>

2+2=<%=2+2%>

</head>

<body>

http://ip:8080/test.jsp 如果看到 2+2=4 2+2=4  就代表jsp測試環境建好.

Apache 跟resin的整合

這時按照提示修改 httpd.conf 文件,在最下面填加:
<IfModule mod_caucho.c>
ResinConfigServer localhost 6802
</IfModule>
註:httpd.conf中還有一項需要修改,就是 Servername 這項,改成 Servername  localhost 即可
(2)修改resin3.sh文件:
cd /usr/local/etc/rc.d
ee resin3.sh
找到 resin3_enable=${resin3_enable:-“NO”} 這一行,改成 resin3_enable=${resin3_enable:-“YES”},保存退出
輸入:
./resin3.sh start
(3)重啟 apache
cd /usr/local/etc/rc.d/
./apache22.sh restart
(4)JSP網頁測試
http://IP/index.jsphttp://IP:8080/index.jsp
如果想在輸入網址的時候不用加 index.jsp 在 httpd.conf 中加入 index.jsp 的索引即可
三、如果自動啟動 resin
安裝完 resin 後,它會提示你在 rc.conf 中加入 resin3_enable=”YES” ,可我試過,加入之後並不能自動隨系統啟動 resin,還需要手動啟動才可,所以這個不用加入到 rc.conf 中去,並用如下方法解決:
cd /etc
ee rc.local (沒有的話就自己建立這個文件)
輸入:
/usr/local/etc/rc.d/resin3.sh start
然後重啟
reboot
可以輸入 top 查看,如果有 java ,說明已經啟動成功!
四、防火牆IPFW的設置
如果裝有IPFW防火牆,一定要在規則中填加 ipfw add 10006 allow tcp from any to me 8080 in 規則,否則無法實現 JSP 功能的調用。(在關掉resin的8080端口的webserver功能後,就不用加)
本例已經本人測試通過,當然朋友們在安裝的時候可能還會遇到其它的問題,歡迎我們一起討論,把所有的問題都解決掉。

補充:
以上的安裝有一個問題,就是Resin完全接管apache的功能,成獨立的webserver,如果想要apache和resin分管html、php和jsp的話,還要接着改一下:

1、可以關掉resin的8080端口,直接通過http://localhost/index.jsp的方式訪問,這時apache只是起到轉發的功能,當然在訪問靜態頁面或php頁面的時候,還是通過apache來執行的
我用的是resin3.0.19版,低於此版的朋友可對照做相應修改
cd /usr/local/etc/resin3
ee resin.xml
找到:
<!– The http port –>
<http server-id=”” host=”*” port=”8080″/>
將其改為:
<!– The http port
<http server-id=”” host=”*” port=”8080″/>
–>
也就是把這行給注釋掉,這樣就不啟用resin的webserver功能。

2、還是這個文件,接着找到下面這行:
<srun server-id=”” host=”127.0.0.1″ port=”6802″/>
將其改為:
<srun server-id=”” host=”localhost” port=”6802″/>
這個是關鍵的,如果不改,則只能通過8080才能訪問jsp頁面(8080沒有關掉的情況下),這個就是和你的httpd.conf中的 “ServerName   localhost” 和 “ResinConfigServer localhost 6802”相對應,原來我也是沒改,一直搞不好,改之後,重啟resin和apache.

 

口令管理增強方法

可以使用如下命令及其參數來增強對用戶密碼的管理:
1)passwd -n 30 user #強迫用戶每30天修改一次密碼;
2)passwd -f user #強迫用戶在下一次登錄時修改口令;
3)passwd -n 2 -x 1 user #禁止用戶修改口令;
4)passwd -l user #封鎖用戶賬號,禁止登錄。

以下文章點擊率最高

Loading…

     

如果這文章對你有幫助,請掃左上角微信支付-支付寶,給於打賞,以助博客運營