Virtual Host + Apache httpd server + Tomcat + mod_jk connector
Articles,  Blog

Virtual Host + Apache httpd server + Tomcat + mod_jk connector


Hi in this screencast. We’ll see them how to implement the virtual host in apache forever with the Tomcat Now suppose we want [to] see the [virtual] question tomcat see my all the videos how we implement the virtual host and Target So what do we issue with the old one we should host in [Duncan] suppose we have Definite which will host in Target all website are located in single missions So suppose you have the big organization each organization want to maintain the server in one that’s being maintained the fifth setting one server But well Tomcat virtual office in town kid. We need [to] maintain all in single machine So it’s not possible for the peak our initiations Suppose this is my structure of the book we have many departments each department [has] different IP addresses Of each house [and] different different Tomcat service these are each only targets on [where] the [cassandra] [Christus] comes in how we process We have the big question because we can’t put the single Ip this is a different different iPs I need to register some public eye piece also So how do we achieve this Richard was concept now we need to put apache HTTP webserver in middle of this request processing so [apache] web server is [accept] all the requests and delegate to the appropriate department based on the request So this is our new structure the instruction we placed the apache web server so all the records comes to apache web server apart from the Delegate direct request service to appropriate departments Now how much server and the Tomcat selected communicate when you see here? Apache service here is working normal browser can communicate directly here. How a pi server can communicate with [these] storage servers Actually there is a one concept is a HP protocol through this protocol both of our service on the Tomcat server can communicate Now when you run down single Tomcat There’s lots of force are binded one put for shadow mode one for fahashi People for the hTTP requests were processed in this spot And one more option code is htTp if you want to need htTPs you enable the spots and one more code is Hp [port]? Usually we are not using this menu [before] anymore, but in this concept we mostly use Php port only We need to that model can communicate between the [apache] htTP server and [tomcats] our power Now steps these are the steps we need to call me for implement the virtual host in apache servers The first one is installed the apache server so I can insert the watch [JK] [let] [me] check a connector then configure the jk. Connector, and finally a pleasure the shadows concept in apache web server Now install the apache web server Now before that we need to download the hTTP server from internet when you search Hatch TPD download you will get the site link in you download the apache web server and Here we build this from source code, so download the source code so [I] downloaded [it] the file now I am going to extract it open the command Prompt [go] to the place down low and then comes here here [insult] script is flying funny darts has come figure – – prefix and We need to enable to model here prefix mean where we need to install the apache server we mentioned the user local apache This pays being going to install the apache server and while installing the apache server What are the module we need to enable it actually apply this to have lots of module now are we interested in to Model? Rate we use this video enable focusing. Maybe we used in next video for load balance inference some kind of possible combinations and When you put touchless country – – [hill] you will see that all the possible? Parameters in the place is lots of parameters, so we go it install mounted touch the skunk here We go to the file system broken Apache apaches begins over here when you can see all bin folder conjugation files Hd dogs everything is [simple] [now] [everything’s] [in] [these] places Now when you go to the modules listen got some modules are pre-installed Okay, now on second step is we need to install the jk, Connector. So in key download the jk, Connector, and we’ll case one When you go to the check-in time just search more Jk character download we can get the edge on download let’s go spread Here [ild] downloaded so they [extract] [it] In Jk. Connect x that is no one folder native means ur the native concrete by taunted Connector Now dot shucks configure with axe user local apache pin effects this file is already present We need to specify that pipe then this [mod] [take] [a] connector find this model Is instantly Share model then we can load the model at any time? Now we install the JK Connect back Now third step is we need to configure the JK character in [this] third strip we service two sub steps one first one is create the work construct properties file and Loads the configured education load under a [Table], JK character module actually when you seen in software in structure each department yet [Concerta] worker So in worker become properties file We need to specify them these Tomcat informations the first one is created a work custard prop this file, so let’s go and first give them sort of religious it Open the natives in Solo local apache and complication production here create the whole document the name is [large] properties Here in this file. We need to specify in this Format now what [care] dot one particular name. We can give me any name and type is which type? we are using a GP thirteen [with] [a] protocol name so a GP 13 and We need to mention the poor composed host is lan the departmental level Tomcat is specified attach IP address and port is not hatched it import you need to use each b. Port and Worker list is what are the list to be provided here? We need to specific [glue] comma Yeah, so in my last video. I only have the multiple Target instance running in single machine now I am going to use that now I have three Tomcat instances I have the script file Spar x again start [the] [phantom] supper. I am going to use that one Okay, now we need to start up [the] 3-ton caves. That’s from the first chunk it I want the internet and free running three Target in stresses Check my old video about the how to run the multiple talk and instructive in single machine now local host a 1001 Tomcat funny local host A Donate one Another Tomcat is running some other one if I put on small cage and Of course is to say to a to another page is honey This is what emotionally I put on default sample page now. We are running a localhost:8080 Eight one eight one eight two eight and three targets instance are hanging okay now We need to create the [walker] start up top [each] [pen] so here For peridot worker dot we can give any name so I’m giving counted 21.5 we are using the ag before to 81 3 version number now One dot [Tomcat] One dot coast now we are running this machine Local Khorsandi Protocol Otherwise we can [specify] the [where] this target instance is running actually so [knowing] what dot Tomcat one Boat here it is not h to put we use them as you put this is department. [ht] [P13] user type and The Port number is a G4 So when you see here, this is my Tomcat check the in [Souder] xML file Ok this is a htTP port h0 h0 actually we don’t want this one, and this is htTp port now. It is a disabled and This is an HB potter when you see here the protocol is a cheaper one [ring] And this is a port so we need to use that port So we know we don’t know [ok] the one worker is created now. We have three target instances for need to create totally three Tomcat workers All [are] type is a GP one change the value [two] and this one is If you can give any name let’s [motion] Now my all our post is talking about sternly, but [fort] isn’t going to change My instance is fearsome and check that [sounded] x modified This one is [knaves] [wrote] [in] Okay, now check the another instance three composition so that a commotion this thing eleven One three [workers] created. We need to give the list worker [not] list So I am typing Welcome dot list volta this mean. We’re down clip one pump it one two three That’s it now. What [come] down step up this file is creator. So the free pan one step is completed The second step is now we need to add the entry into the htTPd config file So then you go here This one coil httpd.conf inside this is a configuration file for apache server So we need to add some increase Now we have mod Jk file and Okay, now you need to add the module Or see the code now. We need to add the model Jk Model is already present, but it is not loaded so we need to specify [this] lower the module then second is the kingdom the Recently we created our custard from big file. We need to specify use this file so here Lower body and give any name now here is ek volume Now this we need to kill the where you can find out let’s go unfold the models [smash] one shaking doctor spoke When you see here is apache Modules there is a module data. So we need to expand this finally to low it then second in checking you can workers five Workers type space play that place we will put it in comic-con [cash] This type are included for some country Then some remaining modules see when you see here. This is log file entries. So we just copy paste to their locks a laxative This is nothing is changed suppose any this Modular Connector is barber this request [the] entries are stored in the [clock] [peg] So just this is a constant only need to copy the blog entries. We need to copy and paste it now [this] part is completed now The step is completed We go the next step next step is we need to get it into the htTPd to compare Now this entry Jk mode which comes to model only chicken model of you? So we added here only Now we are putting So let me check in Mount Slash Okay, now we need to create a folder and then and Now let’s check it here now our host first one department one Department to Department three, [okay] now. We have three three transit instances in out um that Context is one is [department] one the second term cap is contacts is stop department [to] and third one is Department three Now if you search Department two in this one you won’t get it In this term can have department one only means this term can department to one so [one] it’s like this Now we need to add this increase in HtTp [d] dot config file? so yeah [photos] Department [1] Any request contains [a] department one go to the witch worker? We already have 3 worker 3 workers now This is a first term [key] to the finding to [the] second campaign turton get it now department one The many requests how department one [me] It’s goes to the first term get the first term conveying is Tomcat one so this event Can’t get one Thanks for this probably [useful] now [contains] any requests have department [-] – then go to Target do and Department [ask] nearly 1/3 of [tonkin] [team] just to save it Then now go to user now we going to start apache server Fetching B Dot slash Magic control [for] the CtF stop apache started now go to the browser and Proposed actually apache learning aids report so party started now anyone asking here Department 1C Department one is coming here anyone asking Department to Department – that’s been my second [Tom] can see the target this Duncan is instance is coming Department 3 another Target, so when you see here Can you can ask questions like this? This will suppose to take this video suppose. I’m asking wrong kid come anyone anywhere amperior come is I am putting in host file, so it’s big. It’s the local host only saudi [caught] one one slash index dot htML So this apache web server. [I] [want] [to] check amount module check it out department one mean What need to do send it that this worker? with like this So while going here they remove the front end [they] only they send in [a] department one dot Index.html – so department one is say this context to the stump get context [so] take care everything suppose install Localhost when you type W dot funky calm? You will get same result because [anyway] round he not come under these are bring it again to the overflows from [Beaker] Okay, now this part is completed, but what we want we don’t want like this from killer comes to ass department one or [romkey] Dot-Com staff [department] – we don’t want like this. We want life is From period comes – that are extrema, but [ok] we mean it [-] something into converter this one – this [five] is for you So before that we need to obtain a richer first our final step we need to operate a wish list Now listen aids series which bought [quite] [a] service listen this already this line is there now we need to Going to implement this model virtual host module in this virtual rules. We mentioned that [forth] number eight zero find the port number and The server name is which serve running the business domain name actually this is actually is working It’s likely the template using the host Header field so we need to mention that which server name Then the Jack amount is be put before that we put outside. We need to bring it inside like this Let’s see In order that stifling and when you see here, we can hold it this value anywhere So I am putting here [to] [perform] They are giving input X means this directive specifies it bad our virtual host servers are we put it off which ethernet we have already have only one your Studies and same [fie] everything now we need to put the virtual host to this database So first start calling a pro man. We need to look at Okay, here, we put seven e and w dot My car, okay, then we need to put the jake amount to bring the table here checking [month] [E] [part] of the Moment one star Then what we need to do then Target one? Which worker need to take it [Tom] can work at one so just [drop] [it] This one is Christian and this is [t] 1 t 2 this one is below Dot and This is Department three and Target three save the file and Come down and remove the same keys Now go to the apache control and stop the server and start it again Now let’s see before the donkey step roncador comes, just department three Sporty, but now It’s not working shang comm 54 Event to See the same [one] is coming, but here when you access a department 1 or 3 You won’t get it this particular department is going to particular places only So here a part htTP server we mentioned that here the same kind of thing now anyone asking rom-Com then goes to this module Anyone asking Christian going to this module now wrong cannot come is going here here that person asking the wrong key becomes Less Department 1 then only goes to the Tomcat 1 Tomcat comes – Department 1 dot index.html, but I don’t want to seem like this. I want like this [from] [p.com] slash Index dot HtML Somehow we need to add this automatically instead of them. We manually entered So due to the purpose be using the period model period Module is the one engine is the target right? We need to add the rewrite [module] See here rewrite the same one need to add some extra code now rewrite engine is fun now This is log to generate the log file per unit and this is the important the Pr8 Rule Individual this is a regular expression if it’s matched we I am putting the starter D anything Something and anything comes [zip] from starting until to the end so anything comes inside Take capsule that one and append with Department [1] Now let’s see here now 3/8 Inch Not even taking this on now read a clock 21. I don’t want to log fine fine. Just take item 3 right [roll] [now] [read] [it] roll is started with the small and Slash Is just disappearing anything unique content is coming. This is the end [so] far end anything is can then just make it three four men one cash Dollar One what they captured here [its] abundant in this area and apply like we mention that this is the last rule and also through the Proxy here Instead of the formal one we just mentioned it star that dollar anything [slash] star, so this is a new input. Just [above] the end is to [please] everyone and This is not it three and [this] will [department] three this is a tea party to Now start and stop there, so let’s stop that study it again now Now take the cushion to [Crostinis] now. No [need] to [carry] anything enter Now Christian is [sent] [and] directly opens [in] Tomcat server and same thing is Logged on keep calm. It’s open the moderate coordinate [way] So this is the structure now it is in use it up now The person asked me roncador come only they not mentioned that Department one department to anything apache service Similar accused with the department one the small rate rule is update here Before you are it is processed the url is rewritten by the rewrite module the raided module check them request it’s come for me then put the [department] one appended and send it to the Tomcat one if it’s like that only when Christians coming they realize the model and sent to the tomcat [-] this light is always Which will host concept in apache server? Thank you for watching?

89 Comments

  • Chirag Pandit

    Sir, I have my web application deployed with netbeans now how should I configure that using apache Tomcat? should i just copy the build folder next to webapps? or i have to do something else? please if possible then make a video on configuring the entire project into apache tomcat and virtual hosting it

    The entire web is filled with crap, if we search for anything related to Tomcat or JAVA J2EE except your channel and koushiks one once again thank you 🙂

  • amit bajaj

    hey Rama
    u did really very well as i have seen in this video .

    i just want to integrate tomcat and apache using mod-jk installed on different server.
    (in LAN)

    i have change host address in workers.properties but its not working.
    it would be so nice of you
    if could help me .

    email- [email protected]

  • ftwtf1

    I get the following error:

    httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
    (98) Address already in use: make_sock: could not bind to address [::]:80
    (98) Address already in use: make_sock: could not bind to address 0.0.0.0:80
    no listening sockets available, shutting down
    Unable to open logs.

    This happens when I try to execute the command ./apachectl start.

    Any thoughts on how to solve this? I really need this pls. Thanks!

  • Jefferson Francisco Jr.

    Sir thank you this tutorial. I just want to know If what will happen if the application is using a session and the instance of tomcat was stopped? Will it pass the session to other instance of tomcat?

  • Jefferson Francisco Jr.

    Sir thank you this tutorial. I just want to know If what will happen if the application is using a session and the instance of tomcat was stopped? Will it pass the session to other instance of tomcat?

  • SuperAaditya08

    nice work!!  I am new to servers and linux and learning a ot from you..  i have a query… if any one can help please..
    In apache access logs if i have to count  number of access attempts made to my server within a timestamp say from 12:15:00 to 12:50:00 on a perticular day ,,then how will i do so???  

  • karthik kumar

    is it possiable to install the above setup  on CentOS release 6.4 (Final) , please suggest asap ……….thank you

  • Sergey Zinovkin

    Hellow and thank you for your guide. But i`ve encountered some problems accessing ManagerApp HostManager and all other links on typical Apache Tomcat server page after following your guide till the end. So i get starting page of tomcat server on http:\localhost and can not access any links on it OR i can use http:\localhost:8080 and all works fine. But my goal was to let apache pass all connections coming from port 80 to Tomat server. Can you help me with that?

  • Tulsi Ram

    hi rama 
     thank you for sharing your knowledge with us  . Can i use this virtual host concept for communicating between web logic server  and apache httpd server 

  • Vennila Gunasekaran

    All part you said was very right and I have a doubt. I am already running my tomcat server with my applications. Now, How I Can proceed to this stage. In which port I need to install my Apache? I got struck. Can you help me please?

  • Gokul V

    Very nice tutorial, I have one doubt why we configuring all the tomcat to Apache server, why cant we use three tomcat server itself for this three different domain. somehow we need three tomcat server for three departments then they can directly contact tomcat itself rite, what the use of configure to Apache server.

  • Abhishek Kumar Srivastava

    hi rama , nice tutorial … i got everything working except the last part of virtual host
    on setting the exact setup when i am trying with the domain-name/department1 then it is sending me to some other real time domain …
    plz send your suggestions on this    [email protected]

  • Anthony Gomez

    Hi Rama,

    Thank you very much for sharing this kind of knowledge, this is very helpful just like me that starting to learn on this, very appreciate it.

  • Anthony Gomez

    Hi Ramki,

    Do you have any video about configuration of apache web server run in multiple instances on the same server, i have 1 working web server, but when i have created another 1 one, im getting isssue, actually my goal here is created 2 web server run and more instances and configure it as a load balancer.

    Appreciate it if you have any video with regarding on this one

    Thanks

  • Sreenivasa Rao Gopisetti

    Hi Ramki,

    Thank you . It is nice explanation.
    Have an requirement as bellow.

    I want configure different  subdomains to the same back end application.

    Example:  
    my application deployed on Tomcat is  let us say  example.com

    I want to redirect all   app1.example.com, app2.example.com and app3.example.com
    to example.com

    Is this something possible?

    Thanks

  • Passionate Developer

    Sir Thank you for the Great Explanation
    Sir till the VirtualHost concept iit is clear
    but after that it is not clear as we are using the www.domain_name.com
    I have a doubt
    can you please explain how did we get the domain www.ramki.com do we need to have one registered?

  • karni Mohammed Fazil

    Hi Rama Krishna, its nice tutorial. I could follow all except the last part (Virtual hosts) domain/department1/index.html not working for me. Looks like the issue is similar to the one explained by Anup Ash. Please let me know how to fix this. Contact me on [email protected]

  • Mahmudul Islam

    Hi, Thank you very for this simple but great tutorial. You are a good teacher.
    I am facing a problem here. In one of the 3 websites, one have resources that comes from "/assets/css/" (i.e. /assets/css/style.css). Before rewriting the url, when I browse the website entering "www.mahmudul.com/department2", everything worked well. Resources are loading, the website is good. But when rewriting url, I made it "www.mahmudul.com". Here is the configuration,

    <VirtualHost *:80>
    ServerName www.ruzdi.com

    RewriteEngine on
    RewriteRule ^/(.*)$ /department2/$1 [l,PT]
    JkMount /* tomcat2
    </VirtualHost>

    now location of resources changed. It is showing "/department2/assets/css" instead this "/assets/css/", so js, css and other resources are not loading but my page contents are coming. Location of the resources must show "/assets/css/", because it is configured in tomcat application, not "/department2/assets/css/". Please tell me, how can i solve this.

  • errabelly rakesh

    Thank's for the tutorial….This helped me a lot and i got precise clarity on virtual host in webserver level. Since your tutorials are not complex , it is easy to understand …………Can you please make a video on SSL in apache webserver level..Thanks in advance.

  • HANU K

    awesome. verified many tutorials and none of them had provided detailed insight into these concepts at one place. great walk-through of each and every step involved. made completely easy to understand whole setup. Great work.

  • Shyantan Deb

    I have installed but the problem i am facing that one of my site is having ssl and another is not. So, should i Install the ssl on Apache or on Tomcat??

    Please help me out

  • nagendra peethani

    hi…Rama krishnan nice tutorial. could u please make video with apache2 instead of httpd ,i did not get any resources regarding redirection of tomcat on apache 2 server on debian 8 linux

  • Mosab Hashim

    Mr.Roma i run the command "./configure –prefix=/usr/local/apache –enable-rewrite=shared –enable-proxy=shared" then i checked the apache directory i found it empty .. i run it again and again still the apache directory is empty .. please help .. thank you

  • kunal chavan

    How to configure mod_JK for both http and https for multiple tomcats? What changes to be done in workers.properties and tomcat?

  • Mukesh Singh

    Hi this video is very nice and the jk_mod is working for my 3 tier architecture very well. Now, the thing I wanted to know is about mod_proxy.so module, can you make a video on this module to connect to the 2nd tier app server (tomcat). Thanks in advance.

  • Ashish Purohit

    thanku bro but how to configure for https if we load for https it ask certificate twice instead of one when we request it ask first for apache and second time for tomcat

  • chytra k

    Do you know , how to loadbalance a URL that has, a context say /foo/abc somewhere in it(not exactly after domain name) ? jkmount does not permit to use ^/foo/abc/* , do we have to use location handler ?

  • Erick Torrero

    Very clear
    Although I have a question, which server's resources will consume on each request?
    The main server
    Or one of the sub servers?

  • Erick Torrero

    Thank you so much, it helped me a lot . but I'm facing a problem, my webapp shows on the url the original webapp name, and without it doesn't work my app, can you help me? can I shared my config with you?

  • Muhammed Øwãìž

    I did exactly what you have shown.After successfully executing –configure No folder is generated in /usr/local.Please help

Leave a Reply

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