Posted by
Bean
at
04:02
0
comments
Welcome to my blog! Hello, welcome to my blog spaces,wish you enjoy yourself here, and benefit from here, and leave your opinion here !
opencms官方文档中有一篇关于整合opencms,Apache,tomcat管理多站点的文章--“Integrating OpenCms, Tomcat and the Apache webserver with mod_proxy”,这些天按照文档说明自己动手配置了一下,现在把心得体会写出来,以供opencms的研究者,使用者参考,批评指正。
官方文档的主旨是:运用Apache的Mod_proxy实现opencms的动态静态资源分离,由apache直接存储静态资源,tomcat处理请求中的动态资源,并去除前缀/opencm/opencms,我的配置测试环境是:
| tool | version |
| gentoo linux | 2.6 |
| apache | 2.0 |
| tomcat | 5.5 |
| mysql | 4.1 |
| opencms | 6.2 |
127.0.0.1 localhost localhost.localdomain 192.168.0.136 www.lxbing.com 192.168.0.136 ww.example.com 192.168.0.136 www.doc.com |
|
uri="/sites/default/demopages/"/> uri="/sites/default/alkacon-documentation/"/>
|
|
LoadModule alias_module modules/mod_alias.so LoadModule proxy_module modules/mod_proxy.so LoadModule proxy_http_module modules/mod_proxy_http.so |
NameVirtualHost *:80
ProxyPass /opencms/ http://www.example.com/ ProxyPass /resources/ http://localhost:8082/resources/ ProxyPass / http://localhost:8082/opencms/
ProxyPass /opencms/ http://www.lxbing.com/ ProxyPass /resources/ http://localhost:8081/resources/ ProxyPass /export/ http://localhost:8081/export/ ProxyPass / http://localhost:8081/opencms/
ProxyPass /opencms/ ! ProxyPass /resources/ http://localhost:8088/resources/ ProxyPass / http://localhost:8088/opencms/ |
ProxyPass /opencms/ ! RedirectPermanent /opencms/ http://${DOMAIN_NAME}/ |
ProxyPass /opencms/ http://${DOMAIN_NAME}/ RedirectPermanent /opencms/ http://${DOMAIN_NAME}/ |
Posted by
Bean
at
04:00
0
comments
one of the most important facilities in Apache is the ability to run 'Virtual Host',the term Virtual Host refers to the practice of maintaining more than one server on one machine,it is essential way to deploy multiple web services - eache of them with different host name and urls,Example, many companies desired to share a web server of containning multiple domains for different applications(wwww.example1.com for a applicaton,and www.example2.com for the other application),without desiring the vistor to know any extra path information(IP,port etc),because of high security request.by this way,you don't need to by more new machine for every application,it can highly improve optimization of the server.
In this issues we explain how to go about setting up a virtual host on your machine, what you need to do to get the hostname working, and how to configure Apache.Of course, we assume that you have already installing and running Tomcat and Apache servers in your computer.There has two method to implement 'Virtual Host', name-based or IP-based virtual hosts.
Apache was one of the first servers to support IP-based virtual hosts right out of the box. Versions 1.1 and later of Apache support both, IP-based and name-based virtual hosts (vhosts). The latter variant of virtual hosts is sometimes also called host-based or non-IP virtual hosts.
| server | version |
| gentoo linux | 2.6 |
| Apache | 2.0 |
| Tomcat | 5.0 and 5.5 |
Note
Creating virtual host configurations on your Apache server does not magically cause
DNS entries to be created for those host names. You must have the names in DNS, resolving
to your IP address, or nobody else will be able to see your web site. You can put entries
in your hosts file for local testing, but that will work only from the machine with those
hosts entries.
192.168.0.136 www.lxbing.com
192.168.0.136 www.example.com
192.168.0.136 www.example1.com
"8080" maxHttpHeaderSize="8192"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75" proxyName="www.example1.com" proxyPort="80"
enableLookups="false" redirectPort="8443" acceptCount="100"
debug="0" connectionTimeout="20000"
disableUploadTimeout="true" />
"8081"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75" proxyName="www.lxbing.com" proxyPort="80"
enableLookups="false" redirectPort="8443" acceptCount="100"
debug="0" connectionTimeout="20000" useURIValidationHack="false"
disableUploadTimeout="true" />
"8082"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75" proxyName="www.example.com" proxyPort="80"
enableLookups="false" redirectPort="8443" acceptCount="100"
debug="0" connectionTimeout="20000" useURIValidationHack="false"
disableUploadTimeout="true" />
"8009"
enableLookups="false" redirectPort="8443" debug="0"
protocol="AJP/1.3" />
Apache provide a mode called mod_proxy,which can enable apache to service like a proxy server.thus, we can deliver the specific request to Tomcat server. it needn't to be configed like web connector mod_jk, in order to active this,we should do some configuration as follow:
LoadModule alias_module modules/mod_alias.so
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
NameVirtualHost *:80
"/var/www/localhost/htdocs/">
Order allow,deny
Allow from all
ServerName www.example.com
ServerName www.lxbing.com
ServerName www.example2.com
DocumentRoot "/var/www/localhost/htdocs/"ProxyPass /xwiki http://192.168.0.136:8081/xwiki
ProxyPassReverse /xwiki http://192.168.0.136:8081/xwikiProxyPass /example http://192.168.0.136:8082/example
ProxyPassReverse /example http://192.168.0.136:8082/exampleProxyPass /example2 http://192.168.0.136:8080/example2
ProxyPassReverse /example2 http://192.168.0.136:8080/example2
ProxyPass told apache to delive url-request (example:http://192.168.0.136/xwiki) to tomcat,which is listenning different port,corresponding to different applications in tomcat. Above is my configuration in my apache and tomcat for testing, and below is offical configuration, it defined different virtual-host in individual node:
Server configuration
# Ensure that Apache listens on port 80
Listen 80# Listen for virtual host requests on all IP addresses
NameVirtualHost *:80
DocumentRoot /www/example1
ServerName www.example1.com# Other directives here
DocumentRoot /www/example2
ServerName www.example2.org# Other directives here
NameVirtualHost *:80or
NameVirtualHost www.****.com
After finish these config ,reboot apache and tomcat. you can visit the applications via proxy server apache.like this http://192.168.0.136/xwiki, it autom turn to wwww.lxbing.com/xwiki. it works well.
if there are multiple application in differnt computers, and a single Apache in a computer communicate to DNS, a request for a application in the other computer, what can we do? in this case, we have deliver the request from one proxy server to the other proxy server, to bring it into effect ,we must config the subproxy server frist, then config main proxy server to listen subproxy server. the mothod of configuration for subproxy is the similar with whan I references before. Now we are focus on the configuration of main proxy server.
In this example of totoring, we have three servers,main proxy server:192.168.0.9 with apache communicating to DNS, subproxy server: 192.168.0.136 with a application xwiki (we do the proxy before with it),192.168.0.4 with a application tsalex.
192.168.0.4 www.alexcaro.com
192.168.0.9 www.xiancaro.com
192.168.0.136 www.lxbing.com
NameVirtualHost *:80
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
var/www/localhost/htdocs>
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
ProxyRequests Off
ProxyVia OnProxyPass /tsalex http://www.alexcaro.com/tsalex
ProxyPass /xwiki http://www.lxbing.com/xwiki
DocumentRoot /var/www/localhost/htdocs
DirectoryIndex index.php index.html index.htm
LogLevel warn
HostNameLookups off
when a request to main proxy server apache in server 192.168.0.9 with a contents /tsalex, the main proxy server delived it to subproxy server apache 192.168.0.4 (domain name www.alexcaro.com) and reply http://www.alexcaro.com/tsalex to the request. if a request with content is /xwiki, it will be turned to subproxy server in 192.168.0.136 and return http://www.lxbing.com/xwiki.
Apache's proxy features are divided into several modules in addition to mod_proxy: mod_proxy_http, mod_proxy_ftp and mod_proxy_connect. Thus, if you want to use one or more of the particular proxy functions, load mod_proxy and the appropriate module(s) into the server (either statically at compile-time or dynamically via the LoadModule directive).
In addition, extended features are provided by other modules. Caching is provided by mod_cache and related modules. The ability to contact remote servers using the SSL/TLS protocol is provided by the SSLProxy* directives of mod_ssl. These additional modules will need to be loaded and configured to take advantage of these features.
http://httpd.apache.org/docs/2.0/mod/mod_proxy.html
http://lamp.linux.gov.cn/Apache/ApacheMenu/mod/mod_proxy.html
for finishing the configuration,I accept some help from others ,thanks to haitao jiang,jim and members of alexandria. the documents below you can consult, if you have interesting in doing the configuration work
http://lamp.linux.gov.cn/Apache/ApacheMenu/index.html
http://tomcat.jaxwiki.org/proxy-howto.html
http://httpd.apache.org/docs/1.3/vhosts/ip-based.html
http://httpd.apache.org/docs/2.0/vhosts/examples.html
Posted by
Bean
at
03:59
0
comments
gentoo中很多工具都是通portage中的境象文件与相应站点联系起来的,你可以通过emerge命令自动完成"下载工具的源代码-编译-生成可执 行文件-安装" 这一系列动作.而随着时间的进展,可能官方站点对portage中的文件进行了更新,你本机上的portage如果未能和其同步,在你试图从新安装工具 时,可能会遇到麻烦,或是无法安装新版本的工具.
gentoo 系统中/etc/make.conf文件中设定了同步
# These settings were set by the catalyst build script that automatically built this stage
# Please consult /etc/make.conf.example for a more detailed example
CFLAGS="-march=athlon-xp -O2 -pipe -fomit-frame-pointer"
CHOST="i686-pc-linux-gnu"
CXXFLAGS="${CFLAGS}"
USE="X -xdm -kdm kde qt alsa hal -gnome gtk curl eds java -ldap -mozilla -nas xml2 zlib"
#MAKEOPTS="-j21"
#FEATURES="distcc buildpkg"
#CCACHE_SIZE="2G"
#DISTCC_DIR="/tmp/distcc"
LINGUAS="zh_CN hy"
SYNC="rsync://rsync.namerica.gentoo.org/gentoo-portage"
RSYNC_EXCLUDEFROM="/etc/portage/rsync_excludes"
这 里设定本机portage与官方站点同步,你也可以设定与局域网内某台机器同步,最好是网内的机器和服务器同步,服务器与官方站点同步,这样更新 portage相对比较快,因为如果网速较慢各台机子都与站点同步,更新起来很慢,如果只要服务器与官方站点同步,随时保持服务器上的portage是最 新的,网内的机器就可以随时快速更新portage了.
网内的机子要与其他机子同步,只需修改:SYNC="rsync://rsync.namerica.gentoo.org/gentoo-portage"
SYNC="rsync://192.168.0.xxx/gentoo-portage"
然后执行命令:
#emerge sync
Posted by
Bean
at
03:58
0
comments
前些日子,在gentoo下部署了一个j2ee项目:在两天独立的主机上部署OpenCms,一台做应用服务器,另一台做数据库服务器.我的环境是 jdk5.0+tomcat5+mysql4.1.以前多次在一台主机上做过opencms的部署,很顺手! 在两台主机上安装还是头一次,本想应该没什么难度,但是在链接mysql数据库时老是无法链接到远程机,原来默认情况下mysql安装中为了安全因素,没 有赋予root用户远程访问权限,必须为mysql手动创建一个远程访问用户,然后通过次用户的参数实现opencms远程链接mysql .
首先,以root进入mysql,创建远程访问用户remote,这个用户除了有远程访问权限外,还据有于root相同的其他权限.
$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 67 to server version: 4.0.18
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>
mysql> GRANT ALL ON *.* TO remote@'%' IDENTIFIED BY 'secret' WITH GRANT OPTION;
Query OK, 0 rows affected (0.04 sec)
mysql>
然后些改mysql配置文件让它监听外部ip端口,些改 /etc/mysql/my.cnf 文件中的一下部分:
# keep secure by default!
bind-address = 127.0.0.1
port = 3306
把 bind-address改为本机的实际ip.
详细信息请参考http://forums.gentoo.org/viewtopic-t-365627-highlight-connect+mysql+remote+client.html
Posted by
Bean
at
03:56
0
comments