Created
March 12, 2014 06:15
-
-
Save amolkhanorkar/9501794 to your computer and use it in GitHub Desktop.
Apache tomcat setup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Apache tomcat setup | |
Pre-requisites | |
JDK (java) should be install. | |
1. To Install Java | |
Download tarball package. | |
Goto the downloaded directory. Extract tarball jdk-6u31-linux-x64.tar.gz | |
sudo tar-xzf jdk-6u31-linux-x64.tar.gz -C /opt | |
Set Environment variable | |
vim /etc/profile | |
. | |
. | |
. | |
JAVA_HOME=<path-to-jdk-extracted-directory> | |
export JAVA_HOME | |
PATH=$JAVA_HOME:$PATH | |
:wq! | |
2. Configure tomcat | |
Download Tomcat binary distribution from http://tomcat.apache.org/download-70.cgi, then extract it | |
tar -zxf <path-to-tomcat-tarball> -C /opt/ | |
Start tomcat server | |
cd /opt/<tomcat-dir>/bin | |
./startup.sh | |
Open http://localhost:8080, 8080 is default for tomcat | |
3. Create virtualhost in tomcat | |
Goto the tomcat root directory | |
cd /opt/<tomcat-root-directory> | |
vim conf/server.xml | |
. | |
. | |
<Engine....> | |
<Host name="localhost" appBase="webapps" aunpackWARs="true" autoDeploy="true"> | |
. | |
. | |
. | |
</Host> | |
<!-- Custom Virtual host --> | |
<Host name="abc.example.com" appBase="sample" unpackWARs ="true" autoDeploy="true"> | |
<Context path="" docBase="/opt/apache-tomcat-7.0.40/sample.war"/> | |
</Host> | |
</Engine> | |
:wq! | |
Restart Apache tomcat server | |
cd /opt/<tomcat-dir>/bin | |
./shutdown.sh | |
./startup.sh | |
now open url http://abc.example.com:8080 | |
Integrate tomcat with apache | |
Install apache-jk module | |
sudo apt-get install libapache2-mod-jk | |
Now create our /etc/apache2/workers.properties file for Apache | |
# Define 1 real worker using ajp13 | |
worker.list=worker1 | |
# Set properties for worker (ajp13) | |
worker.worker1.type=ajp13 | |
worker.worker1.host=localhost | |
worker.worker1.port=8009 | |
Now set workers file to jk module in Apache. | |
vim /etc/apache2/mods-available/jk.conf | |
JkWorkersFile /etc/apache2/mods-available/jk.conf | |
:wq! | |
Now create virtual host | |
vim /etc/apache2/sites-available/example.com.conf | |
<virtualhost *:80> | |
servername abc.example.com | |
documentroot /opt/apache-tomcat-7.0.40/sample.war | |
jkmount /* worker1 | |
</virtualhost> | |
Enable virtualhost | |
sudo ln -s /etc/apache2/sites-available/dbc.example.com.conf /etc/apache2/sites-enable/. | |
Restart apache server | |
sudo /etc/init.d/apache2 restart |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment