|
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 作者 | 正文 | ||||||||||||||||||||||||||||||
|
最后更新时间:2008-01-21
一. 下载与安装JBoss
在本文中,我们下载的JBoss版本为:4.2.1.GA。 下载地址: 在如上的下载页中下载JBoss-4.2.1.GA.zip文件。 下载完成后,将其解压缩后即可完成安装,解压缩后将其放置到一个不带空格的目录(若目录带有空格,例如:C:"Program Files,日后可能会产生一些莫名的错误),eg:E:"JBoss4.2.1。同时在“环境变量设置”中设置名为JBOSS_HOME的环境变量,值为JBoss的安装路径,如下图所示: 在此,JBoss的安装工作已经结束,可通过如下方式测试安装是否成功: 运行JBoss安装目录"bin"run.bat,如果窗口中没有出现异常,且出现:10:16:19,765 INFO [Server] JBoss (MX MicroKernel) [4.2.1.GA (build: SVNTag=JBoss_4_2_1_GA date=200707131605)] Started in 30s:828ms字样,则表示安装成功。 我们可以通过访问: http://localhost:8080/ 进入JBoss的欢迎界面,点击JBoss Management下的JMX Console可进入JBoss的控制台。 若启动失败,可能由以下原因引起: 1) JBoss所用的端口(8080,1099,1098,8083等)被占用。一般情况下为8080端口被占用(例如,Oracle占用了8080端口),此时需要修改JBoss的端口,方法为进入JBoss安装目录"server"default"deploy"jboss-web.deployer目录,修改其下的server.xml目录,在此文件中搜索8080,将其改成你想要的端口即可(例如8088); 2) JDK安装不正确; 3) JBoss下载不完全。 二. JBoss 的目录结构说明
三. JBoss 的配置 1. 日志文件设置 若需要修改JBoss默认的log4j设置,可修改JBoss安装目录"server"default"conf下的jboss-log4j.xml文件,在该文件中可以看到,log4j的日志输出在JBoss安装目录"server"default"log下的server.log文件中。对于log4j的设置,读者可以在网上搜索更加详细的信息。 2. web 服务的端口号的修改 这点在前文中有所提及,即修改JBoss安装目录"server"default"deploy"jboss-web.deployer下的server.xml文件,内容如下: <Connector port="8080" address="${jboss.bind.address}" maxThreads="250" maxHttpHeaderSize="8192" emptySessionPath="true" protocol="HTTP/1.1" enableLookups="false" redirectPort="8443" acceptCount="100" connectionTimeout="20000" disableUploadTimeout="true" /> 将上面的8080端口修改为你想要的端口即可。重新启动JBoss后访问:http://localhost/:新设置的端口,可看到JBoss的欢迎界面。 3. JBoss 的安全设置 1) jmx-console 登录的用户名和密码设置 默认情况访问 http://localhost:8080/jmx-console 就可以浏览jboss的部署管理的一些信息,不需要输入用户名和密码,使用起来有点安全隐患。下面我们针对此问题对jboss进行配置,使得访问jmx-console也必须要知道用户名和密码才可进去访问。步骤如下: i) 找到JBoss安装目录/server/default/deploy/jmx-console.war/WEB-INF/jboss-web.xml文件,去掉<security-domain>java:/jaas/jmx-console</security-domain>的注释。修改后的该文件内容为: <jboss-web> <!-- Uncomment the security-domain to enable security. You will need to edit the htmladaptor login configuration to setup the login modules used to authentication users.--> <security-domain>java:/jaas/jmx-console</security-domain> </jboss-web> ii)修改与i)中的jboss-web.xml同级目录下的web.xml文件,查找到<security-constraint/>节点,去掉它的注释,修改后该部分内容为: <!-- A security constraint that restricts access to the HTML JMX console to users with the role JBossAdmin. Edit the roles to what you want and uncomment the WEB-INF/jboss-web.xml/security-domain element to enable secured access to the HTML JMX console.--> <security-constraint> <web-resource-collection> <web-resource-name>HtmlAdaptor</web-resource-name> <description>An example security config that only allows users with the role JBossAdmin to access the HTML JMX console web application </description> <url-pattern>/*</url-pattern> <http-method>GET</http-method> <http-method>POST</http-method> </web-resource-collection> <auth-constraint> <role-name>JBossAdmin</role-name> </auth-constraint> </security-constraint> 在此处可以看出,为登录配置了角色JBossAdmin。 iii) 在第一步中的jmx-console安全域和第二步中的运行角色JBossAdmin都是在login-config.xml中配置,我们在JBoss安装目录/server/default/config下找到它。查找名字为:jmx-console的application-policy: <application-policy name = "jmx-console"> 在此处可以看出,登录的角色、用户等的信息分别在props目录下的jmx-console-roles.properties和jmx-console-users.properties文件中设置,分别打开这两个文件。 其中jmx-console-users.properties文件的内容如下: # A sample users.properties file for use with the UsersRolesLoginModule admin=admin 该文件定义的格式为:用户名=密码,在该文件中,默认定义了一个用户名为admin,密码也为admin的用户,读者可将其改成所需的用户名和密码。 jmx-console-roles.properties的内容如下: # A sample roles.properties file for use with the UsersRolesLoginModule admin=JBossAdmin, HttpInvoker 该文件定义的格式为:用户名=角色,多个角色以“,”隔开,该文件默认为admin用户定义了JBossAdmin和HttpInvoker这两个角色。 配置完成后读者可以通过访问: http://localhost:8088/jmx-console/ ,输入jmx-console-roles.properties文件中定义的用户名和密码,访问jmx-console的页面。 2) web-console 登录的用户名和密码设置 默认情况下,用户访问JBoss的web-console时,不需要输入用户名和密码,为了安全起见,我们通过修改配置来为其加上用户名和密码。步骤如下: i)找到JBoss安装目录"server"default"deploy"management"console-mgr.sar"web-console.war"WEB-INF"jboss-web.xml文件,去掉<security-domain>java:/jaas/web-console</security-domain>的注释,修改后的文件内容为: <?xml version='1.0' encoding='UTF-8' ?> <!DOCTYPE jboss-web PUBLIC "-//JBoss//DTD Web Application 2.3V2//EN" "http://www.jboss.org/j2ee/dtd/jboss-web_3_2.dtd"> <jboss-web> <!-- Uncomment the security-domain to enable security. You will need to edit the htmladaptor login configuration to setup the login modules used to authentication users.--> <security-domain>java:/jaas/web-console</security-domain> <!-- The war depends on the --> <depends>jboss.admin:service=PluginManager</depends> </jboss-web> ii)打开i)中jboss-web.xml同目录下的web.xml文件,去掉<security-constraint>部分的注释,修改后的该部分内容为: <!-- A security constraint that restricts access to the HTML JMX console to users with the role JBossAdmin. Edit the roles to what you want and uncomment the WEB-INF/jboss-web.xml/security-domain element to enable secured access to the HTML JMX console.--> <security-constraint> <web-resource-collection> <web-resource-name>HtmlAdaptor</web-resource-name> <description>An example security config that only allows users with the role JBossAdmin to access the HTML JMX console web application </description> <url-pattern>/*</url-pattern> <http-method>GET</http-method> <http-method>POST</http-method> </web-resource-collection> <auth-constraint> <role-name>JBossAdmin</role-name> </auth-constraint> </security-constraint> iii)打开JBoss安装目录"server"default"conf下的login-config.xml文件,搜索web-console,可找到如下内容: <application-policy name = "web-console"> <authentication> <login-module code="org.jboss.security.auth.spi.UsersRolesLoginModule" flag = "required"> <module-option name="usersProperties">web-console-users.properties</module-option> <module-option name="rolesProperties">web-console-roles.properties</module-option> </login-module> </authentication> </application-policy> 在文件中可以看到,设置登录web-console的用户名和角色等信息分别在login-config.xml文件所在目录下的web-console-users.properties和web-console-roles.properties文件中,但因为该目录下无这两个文件,我们在JBoss安装目录"server"default"conf"props目录下建立这两个文件,文件内容可参考在“jmx-console登录的用户名和密码设置”中的两个相应的配置文件的内容,web-console-users.properties文件的内容如下: # A sample users.properties file for use with the UsersRolesLoginModule admin=admin web-console-roles.properties文件的内容如下: # A sample roles.properties file for use with the UsersRolesLoginModule admin=JBossAdmin,HttpInvoker 因为此时这两个文件不与login-config.xml同目录,所以login-config.xml文件需进行少许修改,修改后的<application-policy name = "web-console">元素的内容为: <application-policy name = "web-console"> <authentication> <login-module code="org.jboss.security.auth.spi.UsersRolesLoginModule" flag = "required"> <module-option name="usersProperties">props/web-console-users.properties</module-option> <module-option name="rolesProperties">props/web-console-roles.properties</module-option> </login-module> </authentication> </application-policy> 四. 在MyEclipse 中配置JBoss 笔者的MyEclipse版本:5.1.1 GA JBoss版本:4.2.1 GA JDK版本:1.5 进入Window-> Preferences-> MyEclipse -> Application Servers -> JBoss4,进行如下设置: 选择JBoss 4下的JDK设置所用的JDK. 设置完成后,部署程序时,会发现多出JBoss 4部署的选择,如下图所示: 同时在 声明:JavaEye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
|
|||||||||||||||||||||||||||||||
| 返回顶楼 | |||||||||||||||||||||||||||||||
|
最后更新时间:2008-01-21
linux上安装jboss
解压jboss到一个目录中如:/usr/local/jboss,然后添加"/usr/local/jboss"到路径中,并设置jboss_home="/usr/local/jboss" 然后执行run.sh,打开浏览器http://localhost:8080,如果有测试页显示,说明安装成功! 注意:设置环境变量时,很容易出问题,因为linux主要是面向多用户,它的环境变量一种是全局的,一种是面向用户的,要注意不同的情况采取相应的方法设置,有两种设置方法: 第一种方法:(针对用户的,假定用户为root) 在用户主目录下有一个 /root/.bashrc 文件,可以在此文件中加入 PATH 的设置如下: export PATH=”$PATH:/your path1/:/your path2/…..” 注意:每一个 path 之间要用 “:“ 分隔。 注销重启 X 就可以了。 第二种方法:(全局的) 在 /etc/profile中增加。 PATH="$PATH:/usr/local/arm/2.95.3/bin" export PATH |
|||||||||||||||||||||||||||||||
| 返回顶楼 | |||||||||||||||||||||||||||||||
|
最后更新时间:2008-04-07
受益.受益了.
|
|||||||||||||||||||||||||||||||
| 返回顶楼 | |||||||||||||||||||||||||||||||
浏览 2069 次






