Apavhe - 2 websites on 2 links

Alles, was den Apache betrifft, kann hier besprochen werden.

Apavhe - 2 websites on 2 links

Postby teilor111 » 12. April 2015 01:02

Hi! Can you help me with configure apache with it, then:
I have debian (without GUI) server with service: apache2.
I must make 2 websites.
First (intex.html) should was avalible on link http://name1.local/
secound website (for example website2/secound.html) should was avalible on link http://name2.local/

How I can make it?
I trying make it with virtual hosts, but i searched info and i dont know what exactly i must do.
In /etc/hosts i have line: 192.168.230.123 name1.local, ok its work for first website,
but how i must make to enable same secound website?

Thanks for any help
teilor111
 
Posts: 5
Joined: 12. April 2015 00:54
Operating System: Windows 7

Re: Apavhe - 2 websites on 2 links

Postby JJ_Tagy » 12. April 2015 01:11

Looks like you are on the right track. You will have two entries in your hosts file as well as edit your virtualhosts entries. Here is an example: viewtopic.php?f=16&t=70548#p241671
JJ_Tagy
 
Posts: 678
Joined: 30. January 2012 13:44
Operating System: Windows 10 Pro x64

Re: Apavhe - 2 websites on 2 links

Postby teilor111 » 12. April 2015 01:50

Ye, thanks. I have this in my httpd-vhosts.conf:

Code: Select all
<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot "/var/www"
    ServerName name1.local
    ServerAlias name1.local
    ErrorLog "/var/log/apache2/name1.local-error_log"
    CustomLog "/var/log/apache2/name1.local" common
</VirtualHost>


<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot "/var/www/www2"
    ServerName name2.local
    ErrorLog "/var/log/apache2/name2.local-error_log"
    CustomLog "/var/log/apache2/name2.local-access_log" common
</VirtualHost>



but it's not worked. I dont know still what I must put in my /etc/hosts , i think dont add nothing about it?
teilor111
 
Posts: 5
Joined: 12. April 2015 00:54
Operating System: Windows 7

Re: Apavhe - 2 websites on 2 links

Postby JJ_Tagy » 12. April 2015 02:21

Not sure I would nest vhosts, but that is up to you. Just be aware that you may run into problems of overlapping.

For the hosts file, I would use:
Code: Select all
127.0.0.1    name1.local
127.0.0.1    name2.local
JJ_Tagy
 
Posts: 678
Joined: 30. January 2012 13:44
Operating System: Windows 10 Pro x64

Re: Apavhe - 2 websites on 2 links

Postby teilor111 » 12. April 2015 10:19

I know, but i need to set it. I add this 2 lines to hosts file and still it's not working. I see this same page on name1 and name2.
Why wirtual hosts not working and change it? You seen my vhost file
teilor111
 
Posts: 5
Joined: 12. April 2015 00:54
Operating System: Windows 7

Re: Apavhe - 2 websites on 2 links

Postby Nobbie » 12. April 2015 10:49

Look into the error_log, that should tell you what is wrong. If you are using older Apache than 2.4, youre VirtualHost declaration is incomplete for Namebased Virtualhost, there is missing the NameVirtualhost clause. You also should read the documentation about Virtualhosts:

http://httpd.apache.org/docs/2.2/vhosts/examples.html
Nobbie
 
Posts: 8778
Joined: 09. March 2008 13:04

Re: Apavhe - 2 websites on 2 links

Postby teilor111 » 12. April 2015 11:04

I solve it. Thanks for help.
I set default site on : a2ensite name.local
And in this file i set virtual host settings. thanks!
teilor111
 
Posts: 5
Joined: 12. April 2015 00:54
Operating System: Windows 7


Return to Apache

Who is online

Users browsing this forum: No registered users and 1 guest