logo
Apache Lounge
Webmasters

 


About

Forum Index Downloads Search Register Log in  RSS Apache Lounge
 


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Apache Lounge is not sponsored.

Your donations will help to keep this site alive and well, and continuing building binaries.



problem with vhosts
Goto page 1, 2, 3, 4  Next
 
Post new topic   Reply to topic    Apache Forum Index -> Apache



View previous topic :: View next topic  
Author Message
rob62



Joined: 22 May 2007
Posts: 54
Location: mi

PostPosted: Fri 23 Mar '12 16:46    Post subject: problem with vhosts Reply with quote

I don't know the language and spent hours getting this far. I do know about paths

Page will not load.
vhosts enabled.

All my local sites are g:/xxx ,not G:/wamp/www

vhost file:

NameVirtualHost *:80

<VirtualHost *:80 >
DocumentRoot "g:/wamp/www"
ServerName 127.0.0.1
ServerAlias Localhost
</VirtualHost>

<VirtualHost *:80 >
DocumentRoot "g:/skip"
ServerName skip
ServerAlias skip
<Directory "g:/skip/">
Options Includes Indexes FollowSymLinks MultiViews
AllowOverride all
Order Deny,Allow
Deny from all
Allow from skip
</Directory>
</VirtualHost>

Erroe from Apach log
[Fri Mar 23 09:44:47 2012] [error] [client 127.0.0.1] File does not exist:
G:/wamp/www/index.html


I can't figure out why " wamp/www/" is in the path.

Thanks to all who help.
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 6521
Location: Germany, Next to Hamburg

PostPosted: Sat 24 Mar '12 13:14    Post subject: Reply with quote

Which url do you open in your browser?

you have to open http://skip/ to see the disired file cause you named the vhost that.
Back to top
rob62



Joined: 22 May 2007
Posts: 54
Location: mi

PostPosted: Sat 24 Mar '12 15:00    Post subject: Reply with quote

Thanks for responding.

http://skip takes me to skip.com an external website. - no relation to me.

http://skip.localhost which gives me the PHP configuration screen. http://skip.localhost/mypage/php gives me a page indicating it's reading PHP


You missed the main point about "wamp/www" in the path in Apache error log
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 6521
Location: Germany, Next to Hamburg

PostPosted: Mon 26 Mar '12 23:02    Post subject: Reply with quote

http://skip.localhost <---> ServerName skip

That does not match Wink Since the localhost is the first host, apache takes that one if no ServerName matches with the requested host.
Back to top
rob62



Joined: 22 May 2007
Posts: 54
Location: mi

PostPosted: Tue 27 Mar '12 1:40    Post subject: Reply with quote

I moved 127.0.0.1 localhost to bottom of host file.
Samo
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 6521
Location: Germany, Next to Hamburg

PostPosted: Tue 27 Mar '12 11:20    Post subject: Reply with quote

That is not what I meant.

use
Code:

ServerName skip.localhost
Back to top
rob62



Joined: 22 May 2007
Posts: 54
Location: mi

PostPosted: Tue 27 Mar '12 14:32    Post subject: Reply with quote

Thanks for your persistant help.

changed it as you said. No change!
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 6521
Location: Germany, Next to Hamburg

PostPosted: Thu 29 Mar '12 10:04    Post subject: Reply with quote

Ok ....
did you define the vhosts in an extra file, if yes do you realy include that file into httpd.conf? If yes the vhosts with its names must be shown with httpd -S on the console.
Back to top
rob62



Joined: 22 May 2007
Posts: 54
Location: mi

PostPosted: Sun 01 Apr '12 0:31    Post subject: Reply with quote

When I go to console mode it asks for password. I type what I think it is and the window closes.
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 6521
Location: Germany, Next to Hamburg

PostPosted: Wed 04 Apr '12 11:49    Post subject: Reply with quote

rob62 wrote:
When I go to console mode it asks for password. I type what I think it is and the window closes.


How did you install apache? Running apache as a different user? Installed as a service?
Back to top
Triple_Nothing



Joined: 01 Apr 2012
Posts: 39
Location: WI, USA

PostPosted: Wed 04 Apr '12 22:48    Post subject: Reply with quote

Are you aiming to run this local? As far as a basic example of a vhost entry, I use this for my users' default directory:

Code:
<VirtualHost *:80>
    ServerName users.hellzoneinc.com
    ServerAlias www.users.hellzoneinc.com
    DocumentRoot "C:/Program Files (x86)/Apache2/htdocs"
</VirtualHost>


and this for my main root site:

Code:
<VirtualHost *:80>
    ServerName www.hellzoneinc.com
    ServerAlias hellzoneinc.com
    DocumentRoot "C:/Program Files (x86)/Apache2/htdocs/triple_nothing/hellzoneinc.com/www"
    ErrorLog "logs/hellzoneinc.com-error.log"
    CustomLog "logs/hellzoneinc.com-access.log" common
</VirtualHost>


So in the end:

Code:
<VirtualHost *:80>
    ServerName {Address to this directory}
    ServerAlias {Alias} (Also known as, n such)
    DocumentRoot "{Directory you wish this address to point to}"
</VirtualHost>


Hope this maybe helps.
Back to top
glsmith
Moderator


Joined: 16 Oct 2007
Posts: 2183
Location: Sun Diego, USA

PostPosted: Thu 05 Apr '12 1:31    Post subject: Reply with quote

The biggest problem for people just starting out using virtual hosts is that they do not see (or understand) something in the docs, mainly the first vhost MUST be a duplicate of the main host. There is also the _default_ host.

So if in httpd.conf you have

ServerName localhost
DocumentRoot C:/Apache2x/htdocs

The the first thing in httpd-vhosts.conf

<VirtualHost _default_:port>
# ServerName is not needed here
DocumentRoot C:/Apache2x/htdocs
</VirtualHost>

<VirtualHost *:port>
ServerName www.whatever.com
DocumentRoot C:/path/to/whatever/site
...
</VirtualHost>

<VirtualHost *:port>
ServerName www.someother.com
DocumentRoot C:/path/to/someother/site
...
</VirtualHost>

and on and on. And if one uses httpd-vhosts.conf, make sure it is included from httpd.conf

Include conf/extra/httpd-vhosts.conf

Now, the default host, even if you do not use _default_ it still does same. It will be the one to answer anything pointing to your IP that does not match any configured ServerName on the server, even a http://xxx.xxx.xxx.xxx IP based URL. This is why it doesn't matter if there is a Servername or not in the first one.
Back to top
rob62



Joined: 22 May 2007
Posts: 54
Location: mi

PostPosted: Thu 05 Apr '12 23:45    Post subject: Reply with quote

Ok ....
did you define the vhosts in an extra file, if yes do you realy
include that file into httpd.conf? If yes the vhosts with its
names must be shown with httpd -S on the console.

mysql> -s gives me ->

****************************

Enabled in httpd.conf:
Include conf/extra/httpd-vhosts.conf

last line in httpd.conf is:
Include "g:/wamp/alias/*"


httpd-vhosts.conf is:

NameVirtualHost *:80

<virtualHost *:80 >
DocumentRoot g:/wamp/www
</virtualHost>

Gives apache erroe:
[Thu Apr 05 16:33:59 2012] [error] (OS 11001)No such host is known. : Could not resolve host name *:80> -- ignoring!
[Thu Apr 05 16:33:59 2012] [warn] NameVirtualHost *:80 has no VirtualHosts
[Thu Apr 05 16:33:59 2012] [notice] Child 7640: Child process is running
[Thu Apr 05 16:33:59 2012] [notice] Child 7640: Acquired the start mutex.
[Thu Apr 05 16:33:59 2012] [notice] Child 7640: Starting 64 worker threads.
[Thu Apr 05 16:33:59 2012] [notice] Child 7640: Starting thread to listen on port 80.
[Thu Apr 05 16:33:59 2012] [notice] Child 7640: Starting thread to listen on port 80.


http://skip gives me the server configuration screen.



http://www/php_test.php

The requested URL /php_test.php was not found on this server.
Back to top
glsmith
Moderator


Joined: 16 Oct 2007
Posts: 2183
Location: Sun Diego, USA

PostPosted: Fri 06 Apr '12 3:26    Post subject: Reply with quote

Q: did you define the vhosts in an extra file
A: I do not know, did you?

Q: if yes do you really include that file into httpd.conf?
A: you betcha, otherwise Apache will not read it at start up.

Statement: If yes the vhosts with its names must be shown with httpd -S on the console.

Reply: Cool, looks like it should, isn't doing it in 2.4.2.

but you are in the mysql prompt on your example,
so what mysql> -s gives you has nothing to do with this.

-------------------------------------------------

ok, I am assuming here that the main hosts document root in httpd.conf is g:/wamp/www (just the default test page and let's not worry about that right now.)

Assuming the above to be true, in httpd.conf
Include conf/extra/httpd-vhosts.conf
You have already done this I believe


In conf/extra/httpd-vhosts.conf

Code:
<VirtualHost *:80>
    DocumentRoot "g:/wamp/www"
</VirtualHost>

<VirtualHost *:80 >
    DocumentRoot "g:/skip"
    ServerName skip
    <Directory "g:/skip">
        Options Includes Indexes FollowSymLinks MultiViews
        AllowOverride all
        Order Allow,Deny
        Allow from all
    </Directory>
</VirtualHost>



Now, provided that, and skip is defined in WIndows host file, http://skip out to go to whatever is in g:/skip
Back to top
rob62



Joined: 22 May 2007
Posts: 54
Location: mi

PostPosted: Fri 06 Apr '12 4:55    Post subject: Reply with quote

Yes, this is configure as a local server. for testing.

httpd-Vhosts.conf is a separate file.

"DocumentRoot C:/Apache2x/htdocs"
I do not have that. I'm assuming that
DocumentRoot g:/wamp/www is the same. Different flavor of Apache
Because of this I think it's best to include the file, httpd.conf

http:/skip gives me "skip" with the configuration screen.

Http://skip/php_test.php gives me"The requested URL /php_test.php was not found on this server."

I don't see an option to attach a file and hate to do this. httpd.conf is here:
Back to top
glsmith
Moderator


Joined: 16 Oct 2007
Posts: 2183
Location: Sun Diego, USA

PostPosted: Fri 06 Apr '12 8:03    Post subject: Reply with quote

not supposed to anyway. I saw it .. I have a question tho.... what is in g:/wamp/alias ?

also, what do you get from http://localhost?
Back to top
rob62



Joined: 22 May 2007
Posts: 54
Location: mi

PostPosted: Fri 06 Apr '12 15:13    Post subject: Reply with quote

Thanks guys for continuing to help.

Yesterdays error log shows:
Fri Apr 06 08:57:05 2012] [error] [client 127.0.0.1] PHP Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in G:\\Wamp\\www\\php_test.php on line 8

open http://skip in browser

Http://skip shows WAMP server configuration screen - Apache, MSQL and PHP ,also showing extensions loaded.

http://localhost also shows above.

http://localhost/php_test.php gives error:
Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in G:\Wamp\www\php_test.php on line 8


Contents of php_test.php file:
<html>
<head>
<title>PHP Test</title>
</head>
<body>
<P> This is HTML</P>
<?php
Echo "Hello, World!" this is PHP from "wamp/www" site folder;
?>
</body>
</html>

The PHP test file in each vhosts dir indicates the residing vhosts folder. In bold type above.

Http://skip/php_test.php
error:
The requested URL /php_test.php was not found on this server. ( file is there)

Apache error log:
[Fri Apr 06 08:40:17 2012] [error] [client 127.0.0.1] script 'G:/Wamp/www/php_test.php' not found or unable to stat

Apache error log for above:
Fri Apr 06 08:57:05 2012] [error] [client 127.0.0.1] PHP Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in G:\\Wamp\\www\\php_test.php on line 8

contents
G:/wamp/alias
phpadmin.conf
sqlbuddy.conf
webgrond.conf

[/b]
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 6521
Location: Germany, Next to Hamburg

PostPosted: Fri 06 Apr '12 21:10    Post subject: Reply with quote

That php code should be

Code:

<?php
Echo '"Hello, World!" this is PHP from "wamp/www" site folder';
?>


or

Code:

<?php
Echo "\"Hello, World!\" this is PHP from \"wamp/www\" site folder";
?>
Back to top
rob62



Joined: 22 May 2007
Posts: 54
Location: mi

PostPosted: Fri 06 Apr '12 21:49    Post subject: Reply with quote

Copied and past each of your code in php_test.php


http://skip/php_test.php gives error:
( ! ) Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in G:\Wamp\www\php_test.php on line 8
Back to top
Triple_Nothing



Joined: 01 Apr 2012
Posts: 39
Location: WI, USA

PostPosted: Fri 06 Apr '12 23:38    Post subject: Reply with quote

Odd. Both his items seem to look just fine. Can you post your updated php_test.php file?
Back to top


Post new topic   Reply to topic    Apache Forum Index -> Apache Goto page 1, 2, 3, 4  Next
Page 1 of 4