1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Linux 2 domains 1 server

Discussion in 'Tech Support' started by moserbear, 26 Oct 2010.

  1. moserbear

    moserbear What's a Dremel?

    Joined:
    26 Oct 2010
    Posts:
    1
    Likes Received:
    0
    I have a server in which ubuntu is installed.

    apache2 , php , mysql are installed
    A CMS website is running in the server.

    Now I am told to install another website(jsp) which requires the following

    tomcat , jsp , wine , matlab framework and mysql (already installed). Well I can install this.

    The problem is how do i reference the next domain with the ip address.

    Is it possible??

    Is there any documentation for installing 2 websites with completely new domains on the same server using different server softwares ???

    Is there anything more that i need to know before starting. plz help . Thanks
     
  2. saspro

    saspro IT monkey

    Joined:
    23 Apr 2009
    Posts:
    9,637
    Likes Received:
    429
    Host headers are what you need
     
  3. Zoon

    Zoon Hunting Wabbits since the 80s

    Joined:
    12 Mar 2001
    Posts:
    6,073
    Likes Received:
    923
    How are you going to resolve the fact that you're going to have both apache and tomcat on the same device? They'll both try and use port 80.

    Usually you need either a seperate IP for each to bind to (in which case you don't need host headers really), or some kind of wrapper, which causes a performance hit, and you would use host headers for that :thumb:
     
  4. craigey1

    craigey1 Minimodder

    Joined:
    13 Jan 2003
    Posts:
    1,102
    Likes Received:
    1
    Apache & tomcat can both be configured to work on different ports, can't they? I thought Tomcat defaults to port 8080?
     
  5. Zoon

    Zoon Hunting Wabbits since the 80s

    Joined:
    12 Mar 2001
    Posts:
    6,073
    Likes Received:
    923
    They can, but then that adds the requirement of :8080 onto the end of the URL.
     
  6. FuzzyOne

    FuzzyOne

    Joined:
    19 Sep 2002
    Posts:
    1,850
    Likes Received:
    37
    You'll need to proxy requests through apache and take a hit on perf if you're not prepared to get another ip.

    Code:
    <VirtualHost 192.168.1.1:80>
            ServerName www.yourseconddomainname.com
            DocumentRoot /var/www/html
            DirectoryIndex index.html
            ProxyPass  /  http://www.yourfirstdomainname.com:81/
            ProxyPassReverse  /  http://www.yourfirstdomainname.com:81/
    </VirtualHost>
    
    Have a read of mod_proxy :)
     
  7. Chicken76

    Chicken76 Minimodder

    Joined:
    10 Nov 2009
    Posts:
    952
    Likes Received:
    32
    First of all, why would you want two web servers running on the same machine? I'm not familiar with Tomcat, but Apache could easily handle the two sites using name-based virtual hosts. (have a look at http://httpd.apache.org/docs/2.0/vhosts/)
    I'd say the time required to make both work would be better spent setting up the second site to run under Apache instead of Tomcat. (apache can work with jsp just as well. not familiar with matlab. wine? why would the site require wine?)

    If you absolutely must have the two servers running at the same time, you'll have to use a proxy. FuzzyOne already suggested how to use Apache for this. There's another solution: using a proxy like Squid. Make Apache and Tomcat run on ports 81 and 82 respectively (just examples) and Squid listen on port 80. Setting up Squid to fetch requests from those two ports based on the domain name shouldn't be very complicated. The advantage of this over FuzzyOne's solution is that the second site won't depend on the first one to run. You can easily stop or restart Apache if needed and this would not interfere with the other site. If Apache hangs for some reason (not very common, but ...), both sites would be unavailable, but if you use Squid, you can do whatever you want with each one of them (web server) without affecting the other.
     
  8. RichCreedy

    RichCreedy Hey What Who

    Joined:
    24 Apr 2009
    Posts:
    4,698
    Likes Received:
    172
    i cant help with webservers on linux based machines, but on my windows server 2008 box, i have static ip addresses, that route to 2 different port numbers for each of the websites i host on my machine.

    the routing is dealt with by the router (BT peered ip addresses)

    each website is bound to a different port.
     
  9. paisa666

    paisa666 I WILL END YOU!!!

    Joined:
    4 Mar 2009
    Posts:
    810
    Likes Received:
    42
    ofcourse you can configure wich port the server will use, its actually quite easy to configure two sites on one server.

    just use the host headers to point to the different locations of your site
     

Share This Page