Find the answer to your Linux question:
Results 1 to 7 of 7
Hello, Im using apache server and i would like to have more then one website with diferents links diferent directory. how can i do it?...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Newbie
    Join Date
    May 2012
    Posts
    117

    Apache server


    Hello,

    Im using apache server and i would like to have more then one website with diferents links diferent directory.
    how can i do it?

  2. #2
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    VirtualHosts

    make a separate config file, say /etc/httpd/conf.d/vhosts.conf and in it put all your vhosts stuff. here's a basic example:

    Code:
    NameVirtualHost *:80
    
    <VirtualHost *:80>
      DocumentRoot /var/www/html/www.test.com
      ServerName www.test.com
      ErrorLog logs/test.com-error_log
      CustomLog logs/test.com-access_log common
    </VirtualHost>
    
    
    <VirtualHost *:80>
      DocumentRoot /var/www/html/www.foo.com
      ServerName www.foo.com
      ErrorLog logs/foo.com-error_log
      CustomLog logs/foo.com-access_log common
    </VirtualHost>
    then make sure www.test.com and www.foo.com (or whatever) resolve to your ip address on the apache server (easiest is to put them in /etc/hosts).

    also make sure the directories (what is after DocumentRoot above) exist and are r/x by all.

    then restart apache server.

    make sure client accessing www.test.com/foo.com resolves those names to the proper ip address.

    check apache logs if problems.

  3. #3
    Just Joined!
    Join Date
    Aug 2012
    Posts
    2
    Other and easy way:
    create directories /var/www/html/site1 and /var/www/html/site2.
    and copy you web projects into this dirs.
    So you have 2 links in 2 different directories. 192.168.0.1/site1 and 192.168.0.1/site2
    =)

  4. $spacer_open
    $spacer_close
  5. #4
    Linux Newbie
    Join Date
    May 2012
    Posts
    117
    Now I dont know if you can help me with this but I hope so.

    Im using WebAdmin to Debian Linux 6.0 but in the Apache secession I can create as much virtuals servers as I want however it doens affect the server i mean it doesnt create that:
    PHP Code:
    NameVirtualHost *:80

    <VirtualHost *:80>
      
    DocumentRoot /var/www/html/www.test.com
      ServerName www
    .test.com
      ErrorLog logs
    /test.com-error_log
      CustomLog logs
    /test.com-access_log common
    </VirtualHost>


    <
    VirtualHost *:80>
      
    DocumentRoot /var/www/html/www.foo.com
      ServerName www
    .foo.com
      ErrorLog logs
    /foo.com-error_log
      CustomLog logs
    /foo.com-access_log common
    </VirtualHost
    Why?

  6. #5
    Just Joined!
    Join Date
    Aug 2012
    Posts
    2
    Restart apache.
    What in logs ?

  7. #6
    Linux Newbie
    Join Date
    May 2012
    Posts
    117
    ok I actually doing it by hand so in hosts what a need to right there?


    On my Advancced DNS Zone Editor (on my Domains) Welcome - Grupo White Virtual if I create some thing like:

    Name.....................TTL ......Class.....Type .........Record
    whitevirtual.net.......3600.......IN..........A... ........xxxxIPxxxxx


    If I do this im going to the website 1 and not for my(2)

  8. #7
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    Quote Originally Posted by Joaogl View Post
    ok I actually doing it by hand so in hosts what a need to right there?


    On my Advancced DNS Zone Editor (on my Domains) Welcome - Grupo White Virtual if I create some thing like:

    Name.....................TTL ......Class.....Type .........Record
    whitevirtual.net.......3600.......IN..........A... ........xxxxIPxxxxx


    If I do this im going to the website 1 and not for my(2)
    i wouldn't fiddle w/DNS yet if I were you. Just use entries in /etc/hosts for now, that would be easier.

    on the /etc/hosts file on the server, you want something like this:
    Code:
    127.0.0.1        localhost www.test.com www.foo.com
    on the /etc/hosts file on the client that is attempting to access the webserver via a browser, you want something like this:
    Code:
    <IP_ADDRESS>    www.test.com www.foo.com
    where <IP_ADDRESS> is the ip address of your web server.

    make sure that you can ping the domain names from both server and client before continuing.

    now try and access a page on the webserver from the client, what do you get?

    what is in the apache logs on the web server?

    Note: I see now you are on Debian -well that might change where you'd put that vhosts.conf file. Check the Debian documentation for where exactly you should put it. According to this guide:

    Apache Tips & Tricks: Default apache2 configuration files location | MDLog:/sysadmin

    such config files would go here: /etc/apache2/sites-enabled/

    Also, it bears repeating: watch your apache log files when restarting the server and when a client browser is attempting to connect.

Posting Permissions

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