Jump to content

php only showing one virtualhost


cyjetsu

Recommended Posts

I am running php on apache. I have setup multiple virtual-hosts on apache and managed to get php scripts working on a test website, but I am having trouble getting apache files to run on all my virtual hosts.

 

In my php.ini file at the bottom I have added

doc_root = "c:\test"

extension_dir = "C:\php\ext"

extension=php_mysqli.dll.

 

So when I go to http://lc.test.com/, it successfully runs my php test script in the browser.

However... when I go to my other virtualhost site http://lc.informativesolutions.com/, it actually runs the same script from c:\test, when my index.php file in the informativesolutions directory is a completley different file. Is that normal?

 

Anyway I want to set up php for all my sites so do I add doc_root and extension dir per virtual host like this:

doc_root = "c:\test"

extension_dir = "C:\php\ext"

extension=php_mysqli.dll.

 

doc_root = "c:\apple"

extension_dir = "C:\php\ext"

extension=php_mysqli.dll.

 

doc_root = "c:\tango"

extension_dir = "C:\php\ext"

extension=php_mysqli.dll.

 

Or do I need to specifiy the name of the virtualhost along with it? Or put php access to virtual hosts somewhere else?

 

Also in my apache's httpd.conf file I have:

DocumentRoot "C:/test"

<Directory "C:/test">

 

and Include conf\virtual-hosts.conf where I have setup my virtual hosts.

 

I am not sure if the docroot and dir entries in the httpd conf is why it isnt working, same as in the php file I am not sure if I should add more entries for each host or if there should only be one.

 

when viewing normal html files, each virtualhost site displays the correct files for that individual website so I am positive that my virtualhosts directory setup is correct and different for each virtualhost. It is only when viewing php file that it seems to leap from my virtualhost to the test directory.

Link to comment
Share on other sites

Why do you need to setup php for each virtual host? As long as you setup a handler for .php files in httpd.conf it will work for all your virtual hosts.

 

All you need to do is setup a document root for each virtual host:

 

<VirtualHost ServerIP:Port>

    ServerName domainname.com

    ServerAlias www.domainname.com

    DocumentRoot /path/to/docroot

</VirtualHost>

 

Link to comment
Share on other sites

This is what I find weird.

 

it does. this is what is i my vhosts file:

 

NameVirtualHost 127.0.0.1:80

<VirtualHost 127.0.0.1:80>

ServerName lc.test.com

DocumentRoot "C:\test"

CustomLog logs\lc.test.com.access.log combined

ErrorLog logs\lc.test.com.error.log

</VirtualHost>

 

<VirtualHost 127.0.0.1:80>

ServerName lc.informativesolutions.com

DocumentRoot "C:\operator1\on-infosol\primary"

CustomLog logs\lc.informativesolutions.com.access.log combined

ErrorLog logs\lc.informativesolutions.com.error.log

</VirtualHost>

 

NameVirtualHost 127.0.0.1:80

<VirtualHost 127.0.0.1:80>

ServerName lc.aivdesign.com

DocumentRoot "C:\operator1\on-aivdesign\primary"

CustomLog logs\lc.aivdesign.com.access.log combined

ErrorLog logs\lc.aivdesign.com.error.log

</VirtualHost>

 

<VirtualHost 127.0.0.1:80>

ServerName lc.onmedias.com

DocumentRoot "C:\operator1\on-onmedias\primary"

CustomLog logs\lc.onmedias.com.access.log combined

ErrorLog logs\lc.onmedias.com.error.log

</VirtualHost>

 

<Directory C:\operator1>

Order Deny,Allow

Allow from all

</Directory>

 

 

I have html files in all my site directories except test, so when I go to lc.onmedias.com, or lc.aivdesign.com, it shows those website files..... but if I rename index.html to index.php and go to that site(lc.onmedias.com), the browser shows the php test output from the file in C:\test which is also index.php when it should be taking index.php from C:\operator1\on-onmedias\primary, as it does correctly take index.html from that virtual host directory. Am I making more sense now? I have succesfully setup multiple virtualhosts which display correct files in the corresponding vhost directory, until I try and call a .php file it goes back to c:\test.

 

For instance. http://lc.informativesolutions.com/ displays the html website(index.html in C:\operator1\on-infosol\primary) but when I rename it to index.php or type in http://lc.informativesolutions.com/index.php, it displays the php script c:\test\index.php.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.