Find the answer to your Linux question:
Results 1 to 9 of 9
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Post port address resolution?


    hi guys im new to this web site so thnx in advance

    I am using two websites and hosting them on same ip address using apache and i am using two ports, port 80 & 8080. office.com on port 80 and office1.com on port 8080.

    if i am trying to open office1.com im getting office.com]Office - Office.com and if im using office1.com:8080then im able to open right website.

    so plz can you tell me is there any way by which i can access office1.com without adding port number and i want to host both on same ip address.

  2. #2
    Just Joined!
    Join Date
    Dec 2010
    Location
    Naguabo, Puerto Rico
    Posts
    3

    Default http port is 80

    Hi there:

    Default port for web service (http) is 80. If you type a web site address without specifying the port number, the default Port will be 80. Maybe that's why when you specified the 8080 in the office1.com address, you were shown the correct page.

  3. #3
    Just Joined!
    Join Date
    Dec 2009
    Location
    California
    Posts
    98
    Yeah, tmarrero is right.

    What you want to do is use virtual hosts...
    For example, I host about 15 different websites all on the same IP address. The trick is that browsers pass along in the http request, the name of the site they are trying to access, so apache (and most other web servers) and demultiplex to the right place.

    Here is the process:
    Make sure both office.com and office1.com point to the same IP address in DNS or in your hosts file or whatever.
    Add the following to httpd.conf:

    NameVirtualHost *:80
    <VirtualHost *:80>
    ServerName office.com
    DocumentRoot "/opt/apacheTenants/office/"
    </VirtualHost>
    <VirtualHost *:80>
    ServerName office1.com
    DocumentRoot "/opt/apacheTenants/office1/"
    </VirtualHost>

    If apache won't start when you add this, then there is probably something conflicting in /etc/httpd/conf.d, so just locate the Include conf.d/*.conf

  4. $spacer_open
    $spacer_close
  5. #4

    Unhappy @abarclay

    dude thnx for ur reply but i already tried this and it didnt work without port number not able to open office1.com

  6. #5
    Just Joined!
    Join Date
    Dec 2009
    Location
    California
    Posts
    98
    Are you entering office.com or www.office.com into your browser?

    If you want to use the www one, you will need to add:
    ServerAlias www.office.com
    to each of the stanzas.

    When you restart httpd, check the logs to make sure it's not complaining about a mis-configuration.

  7. #6
    well im using www here this is site not allowing me to add www before office.com

    and my main problem is im using office1.com:8080 if im not using 8080 office.com opens in front of me andi jst dont want to use port no. 8080 along with office1.com. So can u suggest me any way out of this

  8. #7
    office.com is owned by Microsoft.

  9. #8
    Just Joined!
    Join Date
    Dec 2009
    Location
    California
    Posts
    98
    The following httpd.conf is fully functional and does what you want. I've stripped all unnecessary features out, but this will prove that it works. You can add back in what you need. You need to check error.log each time you start apache to make sure that your directives are ok.

    Put the following in /tmp/httpd.conf
    -----
    ServerRoot "/etc/httpd"
    Listen 80
    User apache
    Group apache
    LoadModule autoindex_module modules/mod_autoindex.so
    LoadModule dir_module modules/mod_dir.so
    DirectoryIndex index.html
    NameVirtualHost *:80
    <VirtualHost *:80>
    ServerName site1.com
    ServerAlias www.site1.com
    DocumentRoot "/tmp/site1/"
    </VirtualHost>

    <VirtualHost *:80>
    ServerName site2.com
    ServerAlias www.site2.com
    DocumentRoot "/tmp/site2"
    </VirtualHost>
    -----

    Need to create directories for both sites
    # mkdir /tmp/site1 /tmp/site2

    Need to create the index.html files in each site:

    /tmp/site1/index.html
    ---
    This is site1
    ---

    /tmp/site2/index.html
    ---
    This is site2
    ---

    Started apache as follows:
    # /usr/sbin/httpd -f /tmp/httpd.conf


    Add site1.com and site2.com to /etc/hosts ON THE MACHINE WHERE YOU WILL BE RUNNING THE BROWSER.

    ----
    192.168.37.12 site1.com www.site1.com site2.com www.site2.com
    ----

    Now you will be able to fire up a browser and connect to all of:
    http://site1.com
    http://site2.com
    http://www.site1.com
    http://www.site2.com
    Last edited by abarclay; 09-05-2011 at 04:05 PM.

  10. #9
    thnx bro u rocks it is working now

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •