煩惱歲月

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

          opencms中多站點的配置

          Posted on 2007-11-13 13:00 不需要解釋 閱讀(2728) 評論(3)  編輯  收藏 所屬分類: opencms
          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

          在作任何文件的配置修改之前,請最好作個備份!配置步驟如下:
          1. 在你的域名服務中設置你的域名,稍后安裝及配置過程中將會用到。我的域名是在/etc/hosts 文件中設置的:


          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目錄中的全部應用,關閉tomcat,把opencms.war包改為ROOT.war,拷入     /webapps目錄,因為tomcat默認的應用是ROOT,這樣就去除了路徑中的第一個opencms。啟動tomcat,按步驟安裝opencms??梢酝ㄟ^http://www.lxbing.com:8080/setup 也可以用http://Ip:8080/setup
          進行安裝。

          3. 安裝完畢后你可以通過http://Ip:8080/opencms/system/login進入opencms的工作區,可以看到還有一個/opencms存在于路徑中。
          找到 ${TOMCAT_HOME}/webapps/ROOT/WEB-INF/config/opencms-importexport.xml文件,編輯節點 staticexport/rendersettings 中的部分內容,去除上下文環境,因為現在opencms已經作為tomcat的默認應用了,說以它的默認上下文環境就是根目錄,編輯后的節點中的相關內容為:

          <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中的多個站點,在節點system/sites 中設置需要配置的站點(所謂站點就是opencms中的microsite文件類型),由于測試用的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>


          注意:在這種配置中,所以站點的 uri 都必須在 /site/default/目錄下,否則,會報錯,我沒嘗試過能否把/site/default/ 該為根目錄/ 或是其他意義的目錄,如何有人作過這方面的配置測試,希望能拿出來讓大家學習! 每個站點的域名必須是在你的域名服務中定義過的,否則,會報錯。

          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 中的虛擬主機<VirtualHost> ,apache監聽80端口,當

          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>


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

          ProxyPass          /opencms/ !

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


          將無法登錄opencms工作區,真確的配置為:

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

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


          在配置虛擬主機時應注意 ServerName,DocumentRoot,以及 /resources/, /export/,現在配置完成,可以通過域名訪問opencms中的站點了,但是apache和tomcat是怎么分別管理靜態,動態資源的,我還不大明白,是不是我的配置中有什么不妥的地方,請大家多多指教!

          Feedback

          # re: opencms中多站點的配置[未登錄]  回復  更多評論   

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

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

          預覽提示不能找到該頁面?

          # re: opencms中多站點的配置  回復  更多評論   

          2010-08-01 15:57 by PHPer
          這樣的配置是錯誤的:
          <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>
          應該是:
          <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中多站點的配置  回復  更多評論   

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

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          我實話告訴你們,我可是身經百戰了.bbs我見的多了,哪個版我沒灌過?你們要知道, 一塌糊 涂的triangle,PIC,SEX版,那比你們不知道厲害到哪里去了,我在那談笑風聲.你 們有一好就是無論在哪個版,什么話題都灌,但是灌來灌去的問題,都too simple, sometimes naive!你 們懂不懂呀?啊?所以說灌水啊,關鍵是要提高自己的知識水平.你 們啊,不要總想著弄個大坑,然后灌上十大,再把我羞辱一番……你們啊,naive!你們這 樣灌是不行地!~那你問我支持 不支持灌水,我說支持,我常來這裡灌,你說支持不支持?
          主站蜘蛛池模板: 郁南县| 涟水县| 称多县| 胶州市| 峡江县| 芦山县| 大悟县| 交口县| 通渭县| 荆州市| 海门市| 潼南县| 南郑县| 沧源| 鹤岗市| 中牟县| 定南县| 南乐县| 广西| 邹城市| 琼结县| 阜新| 兰西县| 无棣县| 韩城市| 格尔木市| 新疆| 西丰县| 洪洞县| 石楼县| 南开区| 和田市| 五原县| 无极县| 平罗县| 龙川县| 松桃| 平度市| 大同县| 岐山县| 富阳市|