Dynamic VirtualHost using mod_vhost_alias

Filed Under (Web) by jc on 25-03-2008

Tagged Under : , , , ,

I was looking into a solution for a customer and mod_vhost_alias came in handy.

Lets say you want to host blogs for several people and you want to host them on the following subdomain format: blogname.crazyblogs.com. Instead of having a separate virtual host for each one, you can do something like this:

<VirtualHost 123.111.222.123:80>
UseCanonicalName Off
VirtualDocumentRoot /var/www/%0/htdocs
ServerName *.crazyblogs.com
</VirtualHost>

Now, if you go to http://blog1.crazyblogs.com, it will look for a index file inside /var/www/blog1.crazyblogs.com/htdocs.

You can find further information on:

http://httpd.apache.org/docs/2.0/vhosts/mass.html#simple

http://httpd.apache.org/docs/2.0/mod/mod_vhost_alias.html

Tomcat 6 Intall

Filed Under (Installations, Web) by jc on 19-02-2008

Tagged Under : , , , , ,

This is a step by step stand alone installation of Tomcat 6

JDK Install:

fetch JDK @ http://java.sun.com/

# sh jdk-6u4-linux-i586-rpm.bin
accept license

set java home and path:

# JAVA_HOME=/usr/java/jdk1.6.0_04/
# export JAVA_HOME
# PATH=$JAVA_HOME/bin:$PATH
# export PATH
# which java

Make it happen at boot time:

# cd /etc/profile.d
# vi
/etc/profile.d/jdk.sh

add the following lines to jdk.sh:

export JAVA_HOME=/usr/java/jdk1.6.0_04/ #(or the the location to java home if different)
export PATH=$JAVA_HOME/bin:$PATH

Installing Tomcat From Binary:

wget http://www.signal42.com/mirrors/apache/tomcat/tomcat-6/v6.0.16/bin/apache-tomcat-6.0.16.tar.gz
Untar:

# tar -zxvf apache-tomcat-6.0.16.tar.gz

Move it to /opt/ or desired location
# mv apache-tomcat-6.0.16 /opt/

For security, lets make it run under a underprivileged user:
# useradd tomcat -d /opt/apache-tomcat-6.0.16/temp/

Adjust permissions:
# chown -R tomcat:tomcat /opt/apache-tomcat-6.0.16/

Test install
[root@localhost opt]# sudo -u tomcat /opt/apache-tomcat-6.0.16/bin/startup.sh

or use startup script:

#vi /etc/init.d/tomcat

use the following script:

http://www.linuxzone.org/scripts/tomcat.txt

Add it to chkconfig and turn it on:

# chkconfig --add tomcat
# chkconfig tomcat on

That is it! Let me know if missed anything.