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?
Printable View
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?
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:
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).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>
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.
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
=)
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:Why?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>
Restart apache.
What in logs ?
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:
on the /etc/hosts file on the client that is attempting to access the webserver via a browser, you want something like this:Code:127.0.0.1 localhost www.test.com www.foo.com
where <IP_ADDRESS> is the ip address of your web server.Code:<IP_ADDRESS> www.test.com www.foo.com
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.