Author |
|
Thog
Joined: 12 Feb 2007 Posts: 75 Location: Montreal
|
Posted: Sun 25 Dec '11 4:45 Post subject: Multiple PHP.ini Files In Virtual Host Not Working... :( |
|
|
I can't seem to get the virtual hosts to load a different php.ini file... Using Apache 2.3.16beta
I have my regular httpd.conf file...
Code: |
ServerRoot "C:/Servers/Apache24"
LoadModule alias_module modules/mod_alias.so
LoadModule auth_basic_module modules/mod_auth_basic.so
LoadModule authn_core_module modules/mod_authn_core.so
LoadModule authn_file_module modules/mod_authn_file.so
LoadModule authz_core_module modules/mod_authz_core.so
LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule authz_user_module modules/mod_authz_user.so
LoadModule autoindex_module modules/mod_autoindex.so
LoadModule cgi_module modules/mod_cgi.so
LoadModule dir_module modules/mod_dir.so
LoadModule env_module modules/mod_env.so
LoadModule include_module modules/mod_include.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule mime_module modules/mod_mime.so
LoadModule negotiation_module modules/mod_negotiation.so
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule socache_shmcb_module modules/mod_socache_shmcb.so
LoadModule ssl_module modules/mod_ssl.so
LoadModule fcgid_module modules/mod_fcgid.so
<IfModule !mpm_netware_module>
<IfModule !mpm_winnt_module>
User daemon
Group daemon
</IfModule>
</IfModule>
ServerAdmin admin@rave.ca
ServerName www.hyperbass.com:80
DocumentRoot "C:/Servers/Apache24/htdocs"
<Directory />
Options FollowSymLinks
AllowOverride None
Require all denied
</Directory>
<Directory "C:/Servers/Apache24/htdocs">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
<IfModule dir_module>
DirectoryIndex index.php index.htm index.html
</IfModule>
<FilesMatch "^\ht.">
Require all denied
</FilesMatch>
ErrorLog "logs/error.log"
LogLevel warn
<IfModule log_config_module>
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
CustomLog "logs\access.log" common
</IfModule>
<IfModule mime_module>
TypesConfig conf/mime.types
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
</IfModule>
EnableMMAP off
EnableSendfile off
<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>
<IfModule fcgid_module>
FcgidInitialEnv PHPRC "C:/Servers/PHP_NTS"
FcgidInitialEnv PATH "C:/Servers/PHP_NTS"
FcgidInitialEnv SystemRoot "C:/Windows"
FcgidInitialEnv SystemDrive "C:"
FcgidInitialEnv TEMP "C:/Windows/temp"
FcgidInitialEnv TMP "C:/Windows/temp"
FcgidInitialEnv windir "C:/Windows"
FcgidBusyTimeout 3600
FcgidIOTimeout 64
FcgidConnectTimeout 16
FcgidMaxRequestsPerProcess 250
FcgidMaxRequestLen 1073741824
</IfModule>
<IfModule !mpm_netware_module>
PidFile "logs/httpd.pid"
</IfModule>
<IfModule mpm_winnt_module>
ThreadsPerChild 150
MaxRequestsPerChild 0
</IfModule>
AccessFileName ht.access
HostnameLookups Off
KeepAlive On
KeepAliveTimeout 5
MaxKeepAliveRequests 100
ServerSignature Off
ServerTokens Full
Timeout 300
UseCanonicalName Off
Listen 67.205.67.208:80
Listen 70.38.28.209:80
Listen 70.38.28.210:80
Listen 70.38.28.211:80
Listen 70.38.28.212:80
Listen 70.38.28.213:80
AcceptFilter http none
AcceptFilter https none
Include sites/*.site
|
And the virtual host file:
Code: |
<VirtualHost 67.205.67.208:80>
ServerName afterhour.ca
ServerAlias www.afterhour.ca
ServerAdmin webmaster@afterhour.ca
DocumentRoot "d:/websites/afterhour.ca/website"
ErrorLog "d:/websites/afterhour.ca/logs/error.log"
<Directory "d:/websites/afterhour.ca/website">
SetEnv PHPRC "c:/servers/php_ini/afterhour.ca"
AddHandler fcgid-script .php
Options Indexes FollowSymLinks ExecCGI
AllowOverride all
FcgidWrapper "c:/servers/php_nts/php-cgi.exe" .php
Require all granted
</Directory>
</VirtualHost>
|
PHP is loading but when I view a the site phpinfo() I get...
Loaded Configuration File C:\Servers\PHP_NTS\php.ini
And not the one at:
C:\Servers\PHP_INI\afterhour.ca\php.ini
I also see in the phpinfo();
PHPRC C:/Servers/PHP_NTS
So it does not seem to be picking up the new path...
I've also tried changing all /'s to \\'s and still nothing. Do you happen to know any reason why because I want to add different virtual hosts to use different php.ini files...
Right now the php.ini files on both C:\Servers\PHP_NTS\php.ini and C:\Servers\PHP_INI\afterhour.ca\php.ini are 100% the same...
I also see "Virtual Directory Support disabled" when I view the phpinfo(); which could be the reason?
I also tried commenting out:
Code: |
# FcgidInitialEnv PHPRC "C:/Servers/PHP_NTS"
# FcgidInitialEnv PATH "C:/Servers/PHP_NTS"
|
And it will still load "C:/Servers/PHP_NTS/php.ini"... Grrr! |
|
Back to top |
|
glsmith Moderator
Joined: 16 Oct 2007 Posts: 2268 Location: Sun Diego, USA
|
Posted: Sun 25 Dec '11 6:59 Post subject: |
|
|
Cause Apache is defaulting to your main host and not your www.afterhour.ca. I'm sure if you had two different index.html files, you would see this.
Make your first VirtualHost
<VirtualHost *:80>
DocumentRoot "C:/Servers/Apache24/htdocs"
</VirtualHost>
This sets the default vhost (for all IPs), It has to be the same as the main server. Once that is done, you will get your www.afterhour.ca one and it should then look at the proper ini file as well. |
|
Back to top |
|
Thog
Joined: 12 Feb 2007 Posts: 75 Location: Montreal
|
Posted: Sun 25 Dec '11 15:23 Post subject: |
|
|
I actually already have that... This is my test: 3 sites... They all work great but afterhour.ca is loading the wrong php.ini file... It is also the only of the sites to load PHP. Maybe I'm not understanding something.
0.com.site
Code: |
<VirtualHost *:80>
DocumentRoot "c:/servers/apache24/htdocs"
<Directory "c:/servers/apache24/htdocs">
Options Indexes FollowSymLinks
AllowOverride all
Require all granted
</Directory>
</VirtualHost>
|
afterhour.ca.site
Code: |
<VirtualHost 67.205.67.208:80>
ServerName afterhour.ca
ServerAlias www.afterhour.ca
ServerAdmin webmaster@afterhour.ca
DocumentRoot "d:/websites/afterhour.ca/website"
ErrorLog "d:/websites/afterhour.ca/logs/error.log"
<Directory "d:/websites/afterhour.ca/website">
SetEnv PHPRC "c:/servers/php_ini/afterhour.ca"
AddHandler fcgid-script .php
Options Indexes FollowSymLinks ExecCGI
AllowOverride all
FcgidWrapper "c:/servers/php_nts/php-cgi.exe" .php
Require all granted
</Directory>
</VirtualHost>
|
atomicchildren.com.site
Code: |
<VirtualHost 67.205.67.208:80>
ServerName atomicchildren.com
ServerAlias www.atomicchildren.com
ServerAdmin webmaster@atomicchildren.com
DocumentRoot "d:/websites/atomicchildren.com/website"
ErrorLog "d:/websites/atomicchildren.com/logs/error.log"
<Directory "d:/websites/atomicchildren.com/website">
Options Indexes FollowSymLinks
AllowOverride all
Require all granted
</Directory>
</VirtualHost>
|
See Picture: http://www.afterhour.ca/temp/wrong.jpg
Last edited by Thog on Sun 25 Dec '11 15:39; edited 1 time in total |
|
Back to top |
|
Steffen Moderator
Joined: 15 Oct 2005 Posts: 3092 Location: Hilversum, NL, EU
|
Posted: Sun 25 Dec '11 15:39 Post subject: |
|
|
You have in your Vhost:
SetEnv PHPRC ....
Must be:
FcgidInitialEnv PHPRC ....
Should also set:
FcgidInitialEnv PATH "C:Servers/PHP_NTS;C:/WINDOWS/system32;C:/WINDOWS;C:/WINDOWS/System32/Wbem;"
Steffen |
|
Back to top |
|
Thog
Joined: 12 Feb 2007 Posts: 75 Location: Montreal
|
Posted: Sun 25 Dec '11 15:46 Post subject: |
|
|
If I changed the SetEnv to FcgidInitialEnv in there I get:
C:\Servers\Apache24\bin>httpd -k start -n "Apache24"
AH00526: Syntax error on line 8 of C:/Servers/Apache24/sites/afterhour.ca.site:
FcgidInitialEnv not allowed here |
|
Back to top |
|
Thog
Joined: 12 Feb 2007 Posts: 75 Location: Montreal
|
Posted: Sun 25 Dec '11 15:49 Post subject: |
|
|
I moved it outside of the:
<Directory "d:/websites/afterhour.ca/website">
And it worked
Code: |
<VirtualHost 67.205.67.208:80>
ServerName afterhour.ca
ServerAlias www.afterhour.ca
ServerAdmin webmaster@afterhour.ca
DocumentRoot "d:/websites/afterhour.ca/website"
ErrorLog "d:/websites/afterhour.ca/logs/error.log"
FcgidInitialEnv PHPRC "c:/servers/php_ini/afterhour.ca"
<Directory "d:/websites/afterhour.ca/website">
AddHandler fcgid-script .php
Options Indexes FollowSymLinks ExecCGI
AllowOverride all
FcgidWrapper "c:/servers/php_nts/php-cgi.exe" .php
Require all granted
</Directory>
</VirtualHost>
|
You should get the people from apachehaus to change their example because it's bad...
Code: |
# Per VirtualHost Config Example
#
#<VirtualHost *:80>
# DocumentRoot /Apache22/htdocs/fcgi
# ServerName fcgi.local
# ErrorLog logs/fcgi.error.log
# CustomLog logs/fcgi.access.log common
# <Directory "/Apache22/htdocs/fcgi">
# SetEnv PHPRC "c:/php"
# AddHandler fcgid-script .php
# Options Indexes FollowSymLinks ExecCGI
# AllowOverride all
# FcgidWrapper "C:/php/php-cgi.exe" .php
# Require all granted
# </Directory>
#</VirtualHost>
|
|
|
Back to top |
|
Thog
Joined: 12 Feb 2007 Posts: 75 Location: Montreal
|
Posted: Sun 25 Dec '11 15:52 Post subject: |
|
|
Thanks for the help!!! |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7373 Location: Germany, Next to Hamburg
|
Posted: Mon 26 Dec '11 16:16 Post subject: |
|
|
Thog wrote: |
You should get the people from apachehaus to change their example because it's bad...
|
My example worked some time ago with an older version and apache 2.2.x Thanks for the hint, I will change that. Was that only in the download or did your see that somewhere else? |
|
Back to top |
|
Thog
Joined: 12 Feb 2007 Posts: 75 Location: Montreal
|
Posted: Mon 26 Dec '11 19:30 Post subject: |
|
|
It was in the example file of the download of the 64bit version of 2.3.16 on apachehaus.com which is what I used as an example since before on 2.2 I used to run as a module and now I'm running fastCGI since the module version apache restarted itself once every 20-30 minutes which was really annoying (I blame PHP for being buggy since if I don't run PHP it never crashes but only a couple of my sites are still html).
I changed over one of my sites (the busiest one) to be fastCGI on 2.3.15 3 weeks ago (now 2.3.16) and it has not crashed once! With 2.3.16 I have no problems restarting the server or shutting it down. Before with 2.2 I would have to go into process explorer and force shut the site down.
I also tried fastCGI with 2.2 but it would crash sometimes also so I would have to make a scheduler which ran every minute "httpd -k start -n "Apache22_Rave" which was kind of stupid. Also now with the FcgidInitialEnv PHPRC I have my 2nd instance of apache which runs all my smaller sites running on fastCGI also and since yesterday no crashes! Only thing left is getting SSL to work via fastCGI which is another thread
All in all 2.3.16 is amazing for windows so far. In my opinion way better and way more stable then 2.2... |
|
Back to top |
|