煩惱歲月

          付出總是有回報(bào)的 take action follow your heart , or follow your head
          posts - 40, comments - 5, trackbacks - 0, articles - 4

          opencms中多站點(diǎn)的配置

          Posted on 2007-11-13 13:00 不需要解釋 閱讀(2728) 評(píng)論(3)  編輯  收藏 所屬分類: opencms
          opencms官方文檔中有一篇關(guān)于整合opencms,Apache,tomcat管理多站點(diǎn)的文章--“Integrating OpenCms, Tomcat and the Apache webserver with mod_proxy”,這些天按照文檔說(shuō)明自己動(dòng)手配置了一下,現(xiàn)在把心得體會(huì)寫出來(lái),以供opencms的研究者,使用者參考,批評(píng)指正。
            
          官方文檔的主旨是:運(yùn)用Apache的Mod_proxy實(shí)現(xiàn)opencms的動(dòng)態(tài)靜態(tài)資源分離,由apache直接存儲(chǔ)靜態(tài)資源,tomcat處理請(qǐng)求中的動(dòng)態(tài)資源,并去除前綴/opencm/opencms,我的配置測(cè)試環(huán)境是:
           tool  version
           gentoo linux
           2.6
           apache  2.0
           tomcat  5.5
           mysql  4.1
           opencms  6.2

          在作任何文件的配置修改之前,請(qǐng)最好作個(gè)備份!配置步驟如下:
          1. 在你的域名服務(wù)中設(shè)置你的域名,稍后安裝及配置過(guò)程中將會(huì)用到。我的域名是在/etc/hosts 文件中設(shè)置的:


          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



          2. 清除tomcat下/webapps目錄中的全部應(yīng)用,關(guān)閉tomcat,把opencms.war包改為ROOT.war,拷入     /webapps目錄,因?yàn)閠omcat默認(rèn)的應(yīng)用是ROOT,這樣就去除了路徑中的第一個(gè)opencms。啟動(dòng)tomcat,按步驟安裝opencms。可以通過(guò)http://www.lxbing.com:8080/setup 也可以用http://Ip:8080/setup
          進(jìn)行安裝。

          3. 安裝完畢后你可以通過(guò)http://Ip:8080/opencms/system/login進(jìn)入opencms的工作區(qū),可以看到還有一個(gè)/opencms存在于路徑中。
          找到 ${TOMCAT_HOME}/webapps/ROOT/WEB-INF/config/opencms-importexport.xml文件,編輯節(jié)點(diǎn) staticexport/rendersettings 中的部分內(nèi)容,去除上下文環(huán)境,因?yàn)楝F(xiàn)在opencms已經(jīng)作為tomcat的默認(rèn)應(yīng)用了,說(shuō)以它的默認(rèn)上下文環(huán)境就是根目錄,編輯后的節(jié)點(diǎn)中的相關(guān)內(nèi)容為:

          <rfs-prefix>/export</rfs-prefix>

          <vfs-prefix>${SERVLET_NAME}</vfs-prefix>

          <userelativelinks>false</userelativelinks>

          <exporturl>http://127.0.0.1:8081${SERVLET_NAME}/handle404</exporturl>


          4. 修改${TOMCAT_HOME}/webapps/ROOT/WEB-INF/config/opencms-system.xml 文件,配置opencms中的多個(gè)站點(diǎn),在節(jié)點(diǎn)system/sites 中設(shè)置需要配置的站點(diǎn)(所謂站點(diǎn)就是opencms中的microsite文件類型),由于測(cè)試用的opencms是新安裝的,所以我以oepncms中的/default/,/demopages/,/alkacon-documentation/ 為例,具體配置如下:

          <sites>

            <workplace-server>http://www.lxbing.com</workplace-server>   

            <default-uri>/sites/default/</default-uri>

            <site server="http://www.lxbing.com" uri="/sites/default/"/>

            <site server="http://www.example.com"

                       uri="/sites/default/demopages/"/>

            <site server="http://www.doc.com"

                        uri="/sites/default/alkacon-documentation/"/>

          </sites>


          注意:在這種配置中,所以站點(diǎn)的 uri 都必須在 /site/default/目錄下,否則,會(huì)報(bào)錯(cuò),我沒(méi)嘗試過(guò)能否把/site/default/ 該為根目錄/ 或是其他意義的目錄,如何有人作過(guò)這方面的配置測(cè)試,希望能拿出來(lái)讓大家學(xué)習(xí)! 每個(gè)站點(diǎn)的域名必須是在你的域名服務(wù)中定義過(guò)的,否則,會(huì)報(bào)錯(cuò)。

          5. 配置 ${TOMCAT_HOME}/conf/ 中的server.xml 文件.
           

          <Server port="8005" shutdown="SHUTDOWN" debug="0">

             <Service name="Tomcat-Standalone">

             <!-- Define a connector for the "public visible" server name--> 

             <Connector port="8081" minProcessors="5" maxProcessors="75"  

               proxyName="www.lxbing.com" proxyPort="80" enableLookups="true"

               redirectPort="8443" acceptCount="100" debug="0"

               connectionTimeout="20000" useURIValidationHack="false"

               disableUploadTimeout="true" />

             <Connector port="8082" maxThreads="150" minSpareThreads="25"

               maxSpareThreads="75" enableLookups="false" redirectPort="8443"

               acceptCount="100" proxyName="www.example.com" proxyPort="80"

               debug="0" connectionTimeout="20000"

               disableUploadTimeout="true"  />

             <Connector port="8088" maxThreads="150" minSpareThreads="25"

               maxSpareThreads="75" enableLookups="false" redirectPort="8443"

               acceptCount="100" proxyName="www.doc.com" proxyPort="80"

               debug="0" connectionTimeout="20000"

               disableUploadTimeout="true" />

               <Engine name="Standalone" defaultHost="localhost" debug="0"> 

                  <Host name="localhost" debug="0" appBase="webapps"  

                        unpackWARs="true" autoDeploy="true">

                   <!-- You can change "unpackWARs" and "autoDeploy" to false

                   after the installation is finished -->

                   <Logger className="org.apache.catalina.logger.FileLogger"

                        directory="logs" prefix="localhost_log." 

                      suffix=".txt" timestamp="true"/>

                  </Host>

               </Engine>

             </Service>

          </Server>


          6. 配置 /etc/Apaches2/中的 httpd.conf文件,使用能支持mod_proxy模塊

          LoadModule alias_module modules/mod_alias.so LoadModule proxy_module modules/mod_proxy.so LoadModule proxy_http_module modules/mod_proxy_http.so


          7. 配置apache 中的虛擬主機(jī)<VirtualHost> ,apache監(jiān)聽(tīng)80端口,當(dāng)

          NameVirtualHost *:80

          <VirtualHost *:80>
              <Directory "/var/lib/tomcat-5.5/webapps/ROOT/">
                  Order allow,deny Allow from all
              </Directory>
              ServerName www.example.com
              ServerAdmin webmaster@alkacon.com
              DocumentRoot "/var/lib/tomcat-5.5/webapps/ROOT/"
              ErrorLog logs/error.log
              # Log only non-redirect requests in "normal" log file
              SetEnvIf Request_URI "\/opencms\/*" redirect
              CustomLog logs/localhost-access.log common env=!redirect    

              ProxyPass           /opencms/     http://www.example.com/
              RedirectPermanent  /opencms/     http://www.example.com/

              ProxyPass         /resources/  http://localhost:8082/resources/
              ProxyPass        /export/      http://localhost:8082/export/

              ProxyPass              /       http://localhost:8082/opencms/
              ProxyPassReverse      /        http://localhost:8082/opencms/ </VirtualHost>


          <VirtualHost *:80>
              <Directory "/var/lib/tomcat-5.5/webapps/ROOT/">
                   Order allow,deny Allow from all
              </Directory>
              ServerName www.lxbing.com
              ServerAdmin webmaster@alkacon.com
              DocumentRoot "/var/lib/tomcat-5.5/webapps/ROOT/"  
              ErrorLog logs/error.log
              # Log only non-redirect requests in "normal" log file
              SetEnvIf Request_URI "\/opencms\/*" redirect
              CustomLog logs/localhost-access.log common env=!redirect    

              ProxyPass          /opencms/     http://www.lxbing.com/
              RedirectPermanent  /opencms/     http://www.lxbing.com/

              ProxyPass       /resources/  http://localhost:8081/resources/       ProxyPass        /export/    http://localhost:8081/export/

              ProxyPass          /          http://localhost:8081/opencms/
              ProxyPassReverse  /           http://localhost:8081/opencms/ </VirtualHost>

          <VirtualHost *:80>
              <Directory "/var/lib/tomcat-5.5/webapps/ROOT/">  
                  Order allow,deny Allow from all
              </Directory>
              ServerName www.doc.com
              ServerAdmin webmaster@alkacon.com
              DocumentRoot "/var/lib/tomcat-5.5/webapps/ROOT/"
              ErrorLog logs/error.log
              # Log only non-redirect requests in "normal" log file
              SetEnvIf Request_URI "\/opencms\/*" redirect
              CustomLog logs/localhost-access.log common env=!redirect

              ProxyPass          /opencms/ !
              RedirectPermanent  /opencms/ http://www.doc.com/

              ProxyPass      /resources/   http://localhost:8088/resources/
              ProxyPass      /export/      http://localhost:8088/export/

              ProxyPass            /       http://localhost:8088/opencms/
              ProxyPassReverse    /        http://localhost:8088/opencms/ </VirtualHost>


          在這個(gè)配置中,www.lxbing.com 代理的是 http://localhost:8081/opencms/,這個(gè)頁(yè)面有一個(gè)鏈接到opencms登錄頁(yè)面的鏈接,如果按照官方文檔中的說(shuō)明配置為:

          ProxyPass          /opencms/ !

          RedirectPermanent /opencms/  http://${DOMAIN_NAME}/


          將無(wú)法登錄opencms工作區(qū),真確的配置為:

          ProxyPass          /opencms/ http://${DOMAIN_NAME}/

          RedirectPermanent  /opencms/ http://${DOMAIN_NAME}/


          在配置虛擬主機(jī)時(shí)應(yīng)注意 ServerName,DocumentRoot,以及 /resources/, /export/,現(xiàn)在配置完成,可以通過(guò)域名訪問(wèn)opencms中的站點(diǎn)了,但是apache和tomcat是怎么分別管理靜態(tài),動(dòng)態(tài)資源的,我還不大明白,是不是我的配置中有什么不妥的地方,請(qǐng)大家多多指教!

          Feedback

          # re: opencms中多站點(diǎn)的配置[未登錄](méi)  回復(fù)  更多評(píng)論   

          2009-11-08 00:26 by Bruce
          非常感謝你的文章。

          我按照這份文檔配置完成后,為什么不能預(yù)覽?

          預(yù)覽提示不能找到該頁(yè)面?

          # re: opencms中多站點(diǎn)的配置  回復(fù)  更多評(píng)論   

          2010-08-01 15:57 by PHPer
          這樣的配置是錯(cuò)誤的:
          <rfs-prefix>/export</rfs-prefix>
          <vfs-prefix>${SERVLET_NAME}</vfs-prefix>
          <userelativelinks>false</userelativelinks>
          <exporturl>http://127.0.0.1:8081${SERVLET_NAME}/handle404</exporturl>
          應(yīng)該是:
          <rfs-prefix>${CONTEXT_NAME}/export</rfs-prefix>
          <vfs-prefix>${CONTEXT_NAME}</vfs-prefix>
          <userelativelinks>false</userelativelinks>
          <exporturl>http://127.0.0.1:8081${CONTEXT_NAME}/handle404</exporturl>

          # re: opencms中多站點(diǎn)的配置  回復(fù)  更多評(píng)論   

          2010-08-01 15:57 by PHPer
          或者你看看這里:
          http://www.bng-galiza.org/opencms/opencms/alkacon-documentation/howto_apache_httpd/mod_proxy.html

          只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           
          我實(shí)話告訴你們,我可是身經(jīng)百戰(zhàn)了.bbs我見(jiàn)的多了,哪個(gè)版我沒(méi)灌過(guò)?你們要知道, 一塌糊 涂的triangle,PIC,SEX版,那比你們不知道厲害到哪里去了,我在那談笑風(fēng)聲.你 們有一好就是無(wú)論在哪個(gè)版,什么話題都灌,但是灌來(lái)灌去的問(wèn)題,都too simple, sometimes naive!你 們懂不懂呀?啊?所以說(shuō)灌水啊,關(guān)鍵是要提高自己的知識(shí)水平.你 們啊,不要總想著弄個(gè)大坑,然后灌上十大,再把我羞辱一番……你們啊,naive!你們這 樣灌是不行地!~那你問(wèn)我支持 不支持灌水,我說(shuō)支持,我常來(lái)這裡灌,你說(shuō)支持不支持?
          主站蜘蛛池模板: 双桥区| 榆林市| 甘洛县| 太保市| 醴陵市| 津南区| 辽阳市| 德保县| 涪陵区| 安徽省| 建平县| 垣曲县| 夏河县| 建水县| 平湖市| 行唐县| 汕头市| 宁城县| 成都市| 侯马市| 清镇市| 三江| 株洲市| 永靖县| 宿迁市| 吴堡县| 高尔夫| 延吉市| 楚雄市| 吴旗县| 西青区| 昌图县| 翁牛特旗| 临邑县| 沾化县| 遂川县| 明溪县| 福清市| 凉城县| 台北市| 类乌齐县|