Quantcast
Channel: Reza's Weblog
Viewing all articles
Browse latest Browse all 50

Configuring Apache VirtualHost

$
0
0

The complete configuration is as follows for CentOS 5.x, Tomcat 6.x and Apache 2.2.x. Looking at my previous post I am using mod_jl in order to direct DWR calls to Tomcat too, but you ignore this:

  • Download and install mod_jk Tomcat connector from Tomcat site (not mod_jk2 and other shit)
  • Load it in /etc/httpd/conf/httpd.conf: LoadModule jk_module modules/mod_jk.so
  • Uncomment this line: Include conf.d/*.conf in httpd.conf
  • httpd.conf file almost does not need any other changes
  • In conf.d directory we need two files: myconf.conf and workers.properties
  • workers.properties contains at least:
worker.list=worker1
worker.worker1.type=ajp13
worker.worker1.host=localhost
worker.worker1.port=8009
worker.worker1.lbfactor=1
worker.worker1.connection_pool_size=10
worker.worker1.connection_pool_timeout=600
worker.worker1.socket_keepalive=1
worker.worker1.socket_timeout=60   
  • myconf.conf will contain VirtualHosts by name (which is my case, mapping different names to one IP):
            JkWorkersFile /etc/httpd/conf.d/workers.properties
            NameVirtualHost :80
            <VirtualHost
:80>
                ServerName www.mysite.com
                DocumentRoot /home/reza/apache-tomcat-6.0.20/webapps/mycontext
                <Directory "/home/reza/apache-tomcat-6.0.20/webapps/mycontext">
                    Options Indexes FollowSymLinks
                    AllowOverrideone
                    Order deny,allow
                    DirectoryIndex index.html
                    Allow from all
                </Directory>
                JkMount /mycontext/* worker1
                JkMount /mycontext/dwr/* worker1
                JkMount /mycontext worker1
            </VirtualHost>
  • The DirectoryIndex specifically is important as index.html contains the following. Having index.html in document root is a good practice.
           <HTML>
            <HEAD>
            <meta http-equiv="refresh" content="0;URL='http://www.mysite.com/mycontext/'" />  
            </HEAD>
            </HTML>
  • Also make sure that the whole directory tree starting from home to mycontext and index.html indicated in <Directory> tag above is readable and executable by all; otherwise you will get this Apache error: You don't have permission to access / on this server ..


Viewing all articles
Browse latest Browse all 50

Trending Articles