☑️ New! Host Java Web Applications | 02 Configure Apache Web Server With Tomcat And Deploy
Articles,  Blog

☑️ New! Host Java Web Applications | 02 Configure Apache Web Server With Tomcat And Deploy


Hello everyone so in this video we are
going to check about how we can configure Apache web server with Tomcat
so that our java web application can work with Tomcat alright so in this
diagram as you can see what happens is when when you basically type in your
website which in my cases www.upyourcode.com the control actually
goes to Apache on the port 80 alright now what happens is we need a mechanism
through that we can transfer the control from Apache to Tomcat in order to do
that we need a module which that module is called as Apache ajp connector so
what we are going to do is we are going to configure and install this connector
so that the control can be redirected from Apache to Tomcat now to do this
first of all now we need to log in to our VPS using putty as I have logged
in we need to log in with root account in our putty
alright so for that there is a command called sudo su – if it’s asking for your
password you can put in your password now if it’s still not able to log in
what you can do is you can go to your virtual private server dashboard and change
one setting here it says admin access disabled so what you can do is you can
click on change and it’s already ticked so click on save and then click on OK
now if you try to do it, it should work yes and now you are logged in with root
account so the very first step is that we need to install Java
so the basic place where we can install Java is /usr and we can make a
directory here which is mkdir java you can go inside the directory and then you
can go to the document that I have provided and I have provided the link to
download so we will download the latest version of Java which is Java 9 so it will
open let’s click on accept and we are going
to download the Linux version so what do you do is click on this and then click
on cancel and right click here and click on copy link address now why I’m doing
this I will tell you in a while so go back to your putty and then type
in a command called wget and paste that link enter so actually as you can
see the Java is pretty big in size which is like over 300 MB so you know
how to transfer Java from local to your VPS it will take a lot of time if we do
it through FileZilla so using this way it becomes a bit faster as you can see
you are getting 10 Mbps about the download speed so it’s downloaded now
what are you gonna do is you have to run a command called move which is mv and then
copy this thing and give a space and then copy till gz and then enter
so you will find it in proper shape now you have extracted so what you can do is
tar -xf and then this file now what we need to do is we need to add Java in our
but for that you to open this file go to the end and delete this last line and
insert go back to document and just copy-paste this thing into this file and
save the file now we have to download Tomcat as well so go to this link open
it and your browser right click on this one and copy link address and here we’re
going to install Tomcat at a particular location which is /opt and they’re going
to make a folder you can make any name as you are liking I
going to make a folder which is mkdir code cd code and here I will put Tomcat so we can put wget and it will download here as you can see it has come we can
extract it it’s extracted now also we need to download that Apache connector
which will help us in configuring the Apache and the Tomcat together we can
make a directory called downloads where we can actually download all the stuff
that we need to download here so this is a command to download that connector so its downloaded, we can extract it. We need to go to this particular directory and then we need to run this command so if
in case you’re getting this error this basically means that some of the
packages which are required by apxs are not installed in your VPS so you have to
go through a process that I’m going to tell if you’re not getting this error
then it is good to go so in order to go ahead with this error message what you
to do is we need to check some packages and install those packages [Music] so once all these packages are installed, we need to go back to the directory of
connector which is this one so cd /opt code downloads and then we need to go to
CD Tomcat connector native and then again run this command and this time
this command will work properly so that’s done now in order to check
whether our installer is installed properly or not we can go to this
directory and ll now here we need to check for modjk so as you can see
modjk has come which means our connector is successfully installed. Now
the next step is that we need to go to this directory and then we need to create a file called workers.properties and in that file we need to paste this. Now what
this contains is that it contains your ajp port that you will mention in your
Tomcat and your public IP address and these static values and now this can be
anything I am just mentioning the same as domain you can save the file. Now what we need to do is we need to go to this particular file go to the end of the
file and we to piece some things here now
what this will do is once Apache is loaded it will also load the connector
thing for us so you can just copy paste this lines at the end of the file and
save the file now we need to open that file again and go up a little bit where
we can see virtual horsewhipped a report with our
domain yeah so this is the place so what we need to do is first of all we need to comment this particular line because right now what is happening that control is directly going to this directory we have to stop
it and then actually directed to our desired location so what we’ll do is
we’re now going to copy from here to here and paste it there and save the
file now the next step is that we need to restart Apache now you can restart
about it by doing service httpd stop and then click on start. Now if we check
your website it will go to this page which means it is successfully
configured now the only thing you have to do is you have to start your Tomcat
with your war file then it will work now once Apache is started we need to
actually open FileZilla and then log in with our public IP
address and the username that we created [email protected]
okay and the password in the port remains 21 and you can click on connect
it will connect and this is your remote site and your this is your local so what
you can do is you can put your war from here to here. So once that is
transferred you can go back to putty and you can go to a directory called /home/upyourwork1 and here you can see that war file we can put this farm
file to tomcat web apps which is /opt/code/apache/webapps, you can goto Tomact to check it came or not it has come so you can now start Tomcat and
check what happens you can check the logs it seems it
started now if you refresh it, it should work yes it seems to be working so as
you can see the website has loaded your web application has loaded so this is
the basic process where you can configure your Apache with Tomcat and
load your web application in virtual private server

20 Comments

  • AHZAM MATIN

    Hi Great tutorial for hosting the java app on linux vps.

    Can you tell me or make a video on how to host a java website on windows vps and access it through a domain name.

  • Ravivarma K

    hi great tutorial
    i faceing problesm i just followe all the steps tomcat is also running fine. i diployed my war into tomcat webapps folder. but when i am accessing my domine its showing 404 error

  • Kevin Tiba

    After configuration, I got a 500 error. Do you have a solution to that? I feel like the mistake comes from the vim workers.properties files. Can we have more details about each attribute?

  • Ravivarma K

    i have a big issue. my service httpd stooping automatically. i have to start it again and again to keep my website running. you have any idea what causing this problem.

  • Ahmer Ali Qaiser

    I have like 30 websites running on my Godaddy server, if I follow your sets than my other php websites will get effected ?? please let me know

  • Muhammad Siddique

    This is a best tutorial but i face some problem. Whenever apache is run rebuild then httpd.conf file reset.
    So please tell me how to solve it?

  • Riyaz Parve

    Hi,

    First of all I would like to thank you for showing setup in dept and step by step, which is easy to follow.

    I have followed the all the steps but still I am getting error while starting httpd.
    httpd: Syntax error on line 27 of /usr/local/apache/conf/httpd.conf: Syntax error on line 14 of /etc/apache2/conf.modules.d/800-mod_security2.conf: Cannot load modules/mod_security2.so into server: /usr/local/apache/modules/mod_security2.so: undefined symbol: apr_crypto_block_cleanup

    So I commented this line 14 of /etc/apache2/conf.modules.d/800-mod_security2.conf.
    Now I am getting AH00534: httpd: Configuration error: More than one MPM loaded.

    I have to comment line 2 LoadModule mpm_worker_module modules/mod_mpm_worker.so of /etc/apache2/conf.modules.d/000_mod_mpm_worker.conf or else httpd won't start.
    Kindly help if there is any article of link to do this setup correctly I can't any article for it on godaddy or youtube.

  • Sushith Sunil

    when i put the command
    service httpd stop

    its throwing an error
    Redirecting to /bin/systemctl stop httpd.service

    how can i resolve this problem.

  • Hemapriya Subramaniam

    Thanks for the post. Iam deploying War file in tomcat , i am able to access the site only with portnumber. Eg www.domainname.com:8080/sample this works but without port number it shows HTTP Status 404 – Not Found . Can you please advise how to map it to port 80 so that i can just use my domain name to access the site

  • Mouad Chafai

    Hello. Thank you for this riche tutorial. I've a godaddy vps like this one. And i need to put my application in subdomaine. So what shoold i change and how to.
    Thank you.
    Wish part in the doc file ? Wich line.

  • HARSHIT KUMAR

    n you please help me with hosting?
    I have made an dynamic web project in eclipse oxygen using tomcat9.0 . It contains files with these extensions, .war, .jar. .jsp, .html, .css, .js, .xml, .java and backend mysql connectivity.
    How can I host on go daddy?

    Also one more thing. How will the server know which file to run as first one. Is it the index.jsp that runs as the domain name is entered in chrome. I want login.jsp to run.
    For example, I have a domain xyz123.com (not real) then if I enter this in chrome search bar then contents of login.jsp should appear.
    Please make a video step by step ASAP. I have completed my project and want it to host.

  • Kartavya Goswami

    Hey,
    I got this error when I tried to run this command – service httpd start
    Starting httpd: AH00526: Syntax error on line 829 of /etc/apache2/conf/httpd.conf:

    JkRequestLogFormat takes one argument, The mod_jk module request log format string

    Can you please help me?

  • HARSHIT KUMAR

    I am now able to host complete webapp on jelastic.com. Just the thing is that it is too expensive around 1800/month. There are tutorials given on jelastic official Pass channel but they result in some errors which I have rectified. You can make videos regarding this but on a cheaper host costing around 800-1000/month. Bye the way thank you for your support. These videos really helped me understand how does vps hosting works.

  • Nesaraj Nesaraj

    wget http://redrockdigimark.com/apachemirror//httpd/httpd-2.4.28.tar.gz —this command doesn't work. i think the file doesnt exist in the given link… can u please explain wat r we trying to download in this step so that i can find an alternate link or if u can provide an existing link that'll be gr8

  • Kartavya Goswami

    Hi.
    Thank you so much for providing a great tutorial.!
    I followed your all steps but I got HTTP Status 404 – Not Found error. Same as @Ravivarma K
    Can you please tell me what should I change.

Leave a Reply

Your email address will not be published. Required fields are marked *