logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


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

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: problem setting up virtual hosts Page 1, 2  Next
Author
rob62



Joined: 22 May 2007
Posts: 54
Location: mi

PostPosted: Mon 05 May '08 3:49    Post subject: problem setting up virtual hosts Reply with quote

green as grass Confused

index.php and index.html r not working in DocumentRoot , site1 or g:/websites

DocumentRoot "g:/wamp/www/"
<Directory "g:/wamp/www/">


I enabled "Include conf/extra/httpd-vhosts.conf" in the "httpd.conf" file.



I added this to the "httpd-vhosts.conf"

<VirtualHost *:80>
ServerName localhost
DocumentRoot "g:/websites"

ErrorLog g:/websites/logs/error.log
CustomLog g:/websites/logs/access.log common
</VirtualHost>

<VirtualHost *:80>
ServerName site1
DocumentRoot "g:/websites/site1

ErrorLog "g:/websites/logs/error.log"
CustomLog "g:/websites/logs/access.log common" common
</VirtualHost>



I added this ti the "hosts" file

127.0.0.1 site1
127.0.0.1 site2
127.0.0.1 site3

G:/websites/site1/logs
G:/websites/site2/logs
G:/websites/site3/logs

If I change DocumentRoot "g:/wamp/www/" and
<Directory "g:/wamp/www/"> to g:\websites, Apache turns yellow

What did I do wrong.

Confused Confused Confused Confused

Thanks for anticipated help
Back to top
James Blond
Moderator


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

PostPosted: Mon 05 May '08 9:46    Post subject: Reply with quote

in every vhost Block you need to set the permissions for the doc root
and you need to have different log file names.

e.g.
Code:

 <VirtualHost *:80>
ServerName localhost
DocumentRoot "g:/websites/site1"

<Directory "g:/websites/site1">
    Options Indexes FollowSymLinks MultiViews Includes
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>

ErrorLog g:/websites/logs/site1.error.log
CustomLog g:/websites/logs/site1.access.log common
</VirtualHost>
Back to top
rob62



Joined: 22 May 2007
Posts: 54
Location: mi

PostPosted: Mon 05 May '08 19:20    Post subject: Reply with quote

I don't understand this:

ServerName localhost
DocumentRoot "g:/websites/site1"


I would think the ServerName would be the same as the sitename, in this example,


ServerName site1
DocumentRoot "g:/websites/site1"



**************************************
Quote:

in every vhost Block you need to set the permissions for the doc root
and you need to have different log file names.


Why do the error logs need different names when they are in different directorys.

IE:

g:/websites/site1/logs/apache_error.log

g:/websites/site2/logs/apache_error.log
Back to top
James Blond
Moderator


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

PostPosted: Mon 05 May '08 21:05    Post subject: Reply with quote

Sorry, I didn't see that you have your logs in different folder.
And you are right. the server name should be site1 in that example. Embarassed
I only copied that ffrom another httpd.conf and didn't change that. I've over seen it.

Does it work now?
Back to top
rob62



Joined: 22 May 2007
Posts: 54
Location: mi

PostPosted: Mon 05 May '08 22:24    Post subject: Reply with quote

Thanks for replying

No, only if I disable virt hosts in httpd.conf
Back to top
rob62



Joined: 22 May 2007
Posts: 54
Location: mi

PostPosted: Wed 14 May '08 22:42    Post subject: php files quit running Reply with quote

After a little reworking here's what I have.

After enabling virtual hosts, php files no longer run.

Log files have zero bytes.

all information is going to original error.log without errors.

PHP file shows Something is wrong with the wamp installation Sad


NameVirtualHost *:80

<VirtualHost *:80>
ServerName localhost
DocumentRoot "g:/websites"
<Directory "g:/websites">
Options Indexes FollowSymLinks MultiViews Includes
AllowOverride All
Order allow,deny
Allow from all
</Directory>
ErrorLog "g:/websites/logs/apache_error.log"
CustomLog "g:/websites/logs/access.log common" common
</VirtualHost>

<VirtualHost *:80>
ServerName skip
DocumentRoot "g:/websites/skip"
<Directory "g:/websites/skip">
Options Indexes FollowSymLinks MultiViews Includes
AllowOverride All
Order allow,deny
Allow from all
</Directory>
ErrorLog "g:/websites/skip/logs/error.log"
CustomLog "g:/websites/skip/logs/access.log common" common
</VirtualHost>


hosts file

127.0.0.1 localhost
::1 localhost


127.0.0.1 skip

Question Question Question Question
Back to top
James Blond
Moderator


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

PostPosted: Thu 15 May '08 10:07    Post subject: Reply with quote

Where in your httpd.conf did you define PHP? Can you reach the different hosts? What is on the "main" error.log ?
Back to top
rob62



Joined: 22 May 2007
Posts: 54
Location: mi

PostPosted: Thu 15 May '08 23:55    Post subject: Reply with quote

This is the only line pertaining to PHP

LoadModule php5_module "g:/wamp/bin/php/php5.2.5/php5apache2_2.dll"

index.html works in each vir host

None of the index.php files work



http://localhost shows

Not Found

The requested URL was not found on this server.



apache-error.log

[Thu May 15 17:33:47 2008] [notice] Parent: Received shutdown signal -- Shutting down the server.
[Thu May 15 17:33:47 2008] [notice] Child 5680: Exit event signaled. Child process is ending.
[Thu May 15 17:33:48 2008] [notice] Child 5680: Released the start mutex
[Thu May 15 17:33:49 2008] [notice] Child 5680: All worker threads have exited.
[Thu May 15 17:33:49 2008] [notice] Child 5680: Child process is exiting
[Thu May 15 17:33:49 2008] [notice] Parent: Child process exited successfully.
[Thu May 15 17:33:51 2008] [notice] Apache/2.2.8 (Win32) PHP/5.2.5 configured -- resuming normal operations
[Thu May 15 17:33:51 2008] [notice] Server built: Jan 18 2008 00:37:19
[Thu May 15 17:33:51 2008] [notice] Parent: Created child process 3292
[Thu May 15 17:33:51 2008] [notice] Child 3292: Child process is running
[Thu May 15 17:33:51 2008] [notice] Child 3292: Acquired the start mutex.
[Thu May 15 17:33:51 2008] [notice] Child 3292: Starting 64 worker threads.
[Thu May 15 17:33:52 2008] [notice] Child 3292: Starting thread to listen on port 80.
Back to top
James Blond
Moderator


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

PostPosted: Fri 16 May '08 9:31    Post subject: Reply with quote

You also need to assosiate the files with PHP

e.g.
AddType application/x-httpd-php .php

Code:

PHPIniDir "g:/wamp/bin/php/php5.2.5"
LoadModule php5_module "g:/wamp/bin/php/php5.2.5/php5apache2_2.dll"
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
Back to top
rob62



Joined: 22 May 2007
Posts: 54
Location: mi

PostPosted: Fri 16 May '08 14:55    Post subject: virtul hosts not working Reply with quote

Thanks, but that didn't work. Sad I added code to end of httpd.conf file.

Every command line

httpd://localhost
httpd://skip

gives:

"Forbidden

You don't have permission to access / on this server."



apache_error.log indicates php already running.



[Fri May 16 08:38:52 2008] [warn] module php5_module is already loaded, skipping
[Fri May 16 08:38:52 2008] [notice] Apache/2.2.8 (Win32) PHP/5.2.5 configured -- resuming normal operations
[Fri May 16 08:38:52 2008] [notice] Server built: Jan 18 2008 00:37:19
[Fri May 16 08:38:52 2008] [notice] Parent: Created child process 5384
[Fri May 16 08:38:53 2008] [warn] module php5_module is already loaded, skipping
[Fri May 16 08:38:53 2008] [warn] module php5_module is already loaded, skipping
[Fri May 16 08:38:53 2008] [notice] Child 5384: Child process is running
[Fri May 16 08:38:53 2008] [notice] Child 5384: Acquired the start mutex.
[Fri May 16 08:38:53 2008] [notice] Child 5384: Starting 64 worker threads.
[Fri May 16 08:38:53 2008] [notice] Child 5384: Starting thread to listen on port 80. Sad
Back to top
James Blond
Moderator


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

PostPosted: Fri 16 May '08 15:24    Post subject: Reply with quote

403 is a persmission error!! Not an PHP error!
look into your vhost error logs.

make sure that the path of DocumentRoot "g:/websites" and <Directory is the same.
Secondly I don't think that it is an good idea to have a website as a subfolder into a other doc root

e.g.
DocumentRoot "g:/websites"
DocumentRoot "g:/websites/skip"
Back to top
rob62



Joined: 22 May 2007
Posts: 54
Location: mi

PostPosted: Fri 16 May '08 15:44    Post subject: Reply with quote

Do you mean to make each site like this?

g:\skip
g:\site2
g:\site3

Update!!!

I almost got it working.Smile Smile Smile Smile Smile Smile Smile Smile


Wait till I make another post.
Back to top
rob62



Joined: 22 May 2007
Posts: 54
Location: mi

PostPosted: Tue 20 May '08 23:08    Post subject: Reply with quote

Quote:
Do you mean to make each site like this?

g:\skip
g:\site2
g:\site3



Yes

Heres what I have:


<VirtualHost *:80>
ServerName skip
DocumentRoot G:/websites/skip
ErrorLog G:/websites/skip/logs/error.log
CustomLog G:/websites/skip/logs/access.log common
</VirtualHost>

<VirtualHost *:80>
ServerName site2
DocumentRoot G:/websites
ErrorLog G:/websites/logs/error.log
CustomLog G:/websites/logs/access.log common
</VirtualHost>


Index.php's are showing apache screen.

index.htmls don't work

log files in each site have zero bytes

The log file being used is: apache/logs/apache_error.log




[/quote]
Back to top
sawo



Joined: 15 May 2008
Posts: 36

PostPosted: Thu 22 May '08 3:12    Post subject: Reply with quote

Here is how i use the vhosts:

httpd-vhosts.conf:
Code:

NameVirtualHost *:80
<VirtualHost *:80>
    ServerAdmin admin@localhost
    DocumentRoot X:\dir
    ServerName vhost.com
    ServerAlias vhost.com
</VirtualHost>


httpd.conf:
Code:

<Directory "X:/dir">
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    Allow from All
</Directory>
Back to top
James Blond
Moderator


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

PostPosted: Thu 22 May '08 12:23    Post subject: Reply with quote

it is not recommend to have the dicretory outside the vhost.

e.g.
Code:

<VirtualHost *:80>
    ServerAdmin me@sandbox
    DocumentRoot C:/server2/www_sandbox
    ServerName sandbox
    ServerAlias www.sandbox
    ErrorLog C:/server2/logs/sandbox.error.log
    CustomLog C:/server2/logs/sandbox.access.log common
<Directory "C:/server2/www_sandbox">
    Options Indexes FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>
</VirtualHost>


>index.htmls don't work
e.g.
DirectoryIndex index.php index.htm index.html
Back to top
rob62



Joined: 22 May 2007
Posts: 54
Location: mi

PostPosted: Thu 22 May '08 15:25    Post subject: Reply with quote

Thanks sawyo, I think I better got with james blond with a little more
experience.

Going back 2-3 posts, this is for a server on my computer.

It is installed at g:\wamp


I believe your example was written for a remote server.

Heres what I have:

G:\local host
g:\skip
Aliases created for both


<VirtualHost *:80>
DocumentRoot G:/localhost/
ServerName localhost
ErrorLog G:/localhost/logs/error.log
CustomLog G:/localhost/logs/access.log common
<Directory "g:/localhost">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

<VirtualHost *:80>
ServerAdmin me@sandbox
DocumentRoot g:/skip
ServerName skip
ServerAlias g:/skip/
ErrorLog G:/skip/logs/error.log
CustomLog G:/skip/logs/access.log common
<Directory "g:/skip">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>



g:\localhost

Quote:
Not Found

The requested URL /wamp/ was not found on this server.



g:/localhost/index.html

Shows file correctly


g:/localhost/index.php

shows


Quote:

Not Found

The requested URL /wamp/ was not found on this server.


g:/localhost/index.php changes to g:/localhost/wamp/

all results for skip r same.

error.log and access.log r being used for each vir host.

g:\wamp\logs\apache_error.log looks ok



Confused Confused Confused Confused
Back to top
sawo



Joined: 15 May 2008
Posts: 36

PostPosted: Thu 22 May '08 20:56    Post subject: Reply with quote

Your syntax for the vhosts is totally incorrect. Check what values we have used for server alias and the other settings in our examples above.

What do you mean remote server?
My example was for normal virtual host using directory on the local server for example:
main server domain.com, virtual host - something.domain.com
If you need simple alias then you don't even need virtual host in first place (the syntax you used is incorrect for virtual host).
If you want localhost/somedir to point somewhere, then you need the directory settings applied and simple alias:
Code:
alias /subdir "X:/dir"
Back to top
rob62



Joined: 22 May 2007
Posts: 54
Location: mi

PostPosted: Fri 23 May '08 0:26    Post subject: Reply with quote

Thanks sawo, for responding.
I tried your script, moving the permissions block to vir host file. Didn't work.


I better make it clear that the server is on my desktop.

The log files have the same name but are in different directories. Each site has its own log files.

James Blond, You posted some script in previous post concerning PHP in the Httpd.conf file. I tried it and apache_error.log gave a couple error messages saying it was already loaded and exited so I took it out.

Here's everything on the same page.


I installed wamp package.

g:\wamp\


hosts file

127.0.0.1 localhost
127.0.0.1 skip


vir host

I checked very carefully for empty spaces.

NameVirtualHost *:80


<VirtualHost *:80>
ServerName localhost
DocumentRoot g:/localhost
ErrorLog g:/localhost/logs/error.log
CustomLog g:/localhost/logs/access.log common
<Directory "g:/localhost/">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from All
</Directory>
</VirtualHost>

<VirtualHost *:80>
ServerName skip
DocumentRoot g:/skip
ErrorLog g:/skip/logs/error.log
CustomLog g:/skip/logs/access.log common
<Directory "g:/skip/">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from All
</Directory>
</VirtualHost>


Below is what was produced.

apache_error.log

[Thu May 22 18:09:26 2008] [notice] Parent: Received shutdown signal -- Shutting down the server.
[Thu May 22 18:09:26 2008] [notice] Child 4708: Exit event signaled. Child process is ending.
[Thu May 22 18:09:27 2008] [notice] Child 4708: Released the start mutex
[Thu May 22 18:09:28 2008] [notice] Child 4708: All worker threads have exited.
[Thu May 22 18:09:28 2008] [notice] Child 4708: Child process is exiting
[Thu May 22 18:09:28 2008] [notice] Parent: Child process exited successfully.
[Thu May 22 18:09:35 2008] [notice] Apache/2.2.8 (Win32) PHP/5.2.6 configured -- resuming normal operations
[Thu May 22 18:09:35 2008] [notice] Server built: Jan 18 2008 00:37:19
[Thu May 22 18:09:35 2008] [notice] Parent: Created child process 5512
[Thu May 22 18:09:35 2008] [notice] Child 5512: Child process is running
[Thu May 22 18:09:35 2008] [notice] Child 5512: Acquired the start mutex.
[Thu May 22 18:09:35 2008] [notice] Child 5512: Starting 64 worker threads.
[Thu May 22 18:09:35 2008] [notice] Child 5512: Starting thread to listen on port 80.



g://localhost/ brings up g:/localhost/wamp/

g://localhost/index.php brings up

Quote:
Not Found

The requested URL /wamp/ was not found on this server.


g://localhost/index.html brings up correct file in correct dir

Now, lets start fresh on the same page with critique. Smile
Back to top
sawo



Joined: 15 May 2008
Posts: 36

PostPosted: Fri 23 May '08 0:58    Post subject: Reply with quote

I tried your syntax for the skip vhost and it works flawlessly.
Did you created the g:/skip/logs/ directory?
What happens when you type http://skip/ ?
You schuldnt call the url using g://localhost/ - use http://localhost instead.
btw im using AppServ.
Back to top
rob62



Joined: 22 May 2007
Posts: 54
Location: mi

PostPosted: Fri 23 May '08 4:49    Post subject: Reply with quote

typo error!

I used http://

The directories are all there. I modified the index.html in each dir so I know what file is showing on the screen.

I forgot to mention vir hosts is enabled in httpd.conf

skip does exactly the same as localhost.

system variables shows:

g:\wampserver\bin\php\php5.2.5

2 errors in line above!!!

g:\wamp\bin\php\php5.2.6


It acts like these dirs are not in the "path".


Quote:
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host.localhost
1. DocumentRoot "C:/Program Files/Apache Software Foundation/Apache2.2/docs/dummy-host.localhost"
ServerName dummy-host.localhost
ServerAlias www.dummy-host.localhost
2. ErrorLog "logs/dummy-host.localhost-error.log"
3. CustomLog "logs/dummy-host.localhost-access.log" common
</VirtualHost>



Rolling Eyes
Back to top


Reply to topic   Topic: problem setting up virtual hosts View previous topic :: View next topic
Post new topic   Forum Index -> Apache Page 1, 2  Next