Author |
|
smilerdude
Joined: 11 Apr 2011 Posts: 7
|
Posted: Mon 11 Apr '11 13:54 Post subject: Need help configuring 2 apaches intances and 2 PHP versions |
|
|
Hello folks.
I've been tasked to upgrade a production environment that currently consists of MySQL ver: 3.23.49-nt, PHP ver 4.3.2 and Apache ver 1.3ish on a Windows 2003 server.
The upgrade plan is to keep the current system running whilst, I install the latest versions of MySQL, PHP and Apache on the same Windows 2003 server and then test new PHP software against the new production environment.
I installed Apache 2.2.17 by using the command line method of installing the .msi file. The new Apache 2.2 window service runs. I installed PHP 5.2.17 using the PHP zip file method. and installed MySQL 5.5 using it's normal install procedure. Apache 2.2 and MySQL 5.5 seem to be working fine.
It's the PHP configuration with Apache that I need help with.
In the Win OS's Path env variable, I've added paths to both PHP4 and PHP5 install dirs. The Win OS's PHPRC env variable, points to the PHP4 directory.
In Apache 2.2 httpd.conf file I set "SetEnv PHPRC "path to PHP5 directory"
When I run the PHPversioninfo() in a test script using Apache 2.2 ports I get the following (edited for just PHP info bits):
******************************
PHP Version 5.2.17
System Windows NT GANDALF 5.2 build 3790
Build Date Jan 6 2011 17:26:08
Configure Command cscript /nologo configure.js "--enable-snapshot-build" "--enable-debug-pack" "--with-snapshot-template=d:\php-sdk\snap_5_2\vc6\x86\template" "--with-php-build=d:\php-sdk\snap_5_2\vc6\x86\php_build" "--with-pdo-oci=D:\php-sdk\oracle\instantclient10\sdk,shared" "--with-oci8=D:\php-sdk\oracle\instantclient10\sdk,shared" "--without-pi3web"
Server API Apache 2.0 Handler
Virtual Directory Support enabled
Configuration File (php.ini) Path C:\WINDOWS
Loaded Configuration File C:\WINDOWS\php.ini
Scan this dir for additional .ini files (none)
additional .ini files parsed (none)
PHP API 20041225
PHP Extension 20060613
Zend Extension 220060519
Debug Build no
Thread Safety enabled
Zend Memory Manager enabled
IPv6 Support enabled
Registered PHP Streams php, file, data, http, ftp, compress.zlib
Registered Stream Socket Transports tcp, udp
Registered Stream Filters convert.iconv.*, string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, zlib.*
This program makes use of the Zend Scripting Language Engine:
Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies
--------------------------------------------------------------------------------
PHP Credits
--------------------------------------------------------------------------------
Configuration
PHP Core
error_log e:\tmp\phperr.log e:\tmp\phperr.log
extension_dir e:\php4win\extensions e:\php4win\extensions
include_path .;e:\php4win\includes .;e:\php4win\includes
apache2handler
Apache Version Apache/2.2.17 (Win32) PHP/5.2.17
Apache API Version 20051115
Server Root C:/Program Files/Apache Group/Apache2.2
Loaded Modules core mod_win32 mpm_winnt http_core mod_so mod_actions mod_alias mod_asis mod_auth_basic mod_authn_default mod_authn_file mod_authz_default mod_authz_groupfile mod_authz_host mod_authz_user mod_autoindex mod_cgi mod_dir mod_env mod_include mod_isapi mod_log_config mod_mime mod_negotiation mod_rewrite mod_setenvif mod_unique_id mod_php5
Apache Environment
Variable Value
UNIQUE_ID TaLf4MCoBWQAACYUDlIAAAA-
PHPRC C:\Program Files\PHP\5.2.17
PATH E:\php4win\;C:\Program Files\PHP\5.2.17\;C:\Program Files\HP\NCU;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Microsoft SQL Server\80\Tools\Binn\;C:\Program Files\Common Files\Sage SBD\;C:\Program Files\Microsoft SQL Server\90\Tools\binn\
SystemRoot C:\WINDOWS
SERVER_SOFTWARE Apache/2.2.17 (Win32) PHP/5.2.17
session.name PHPSESSID PHPSESSID
safe_mode_allowed_env_vars PHP_ PHP_
Path E:\php4win\;C:\Program Files\PHP\5.2.17\;C:\Program Files\HP\NCU;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Microsoft SQL Server\80\Tools\Binn\;C:\Program Files\Common Files\Sage SBD\;C:\Program Files\Microsoft SQL Server\90\Tools\binn\
PHPRC E:\php4win\
PHP Variables
Variable Value
_SERVER["PHPRC"] C:\Program Files\PHP\5.2.17
_SERVER["PATH"] E:\php4win\;C:\Program Files\PHP\5.2.17\;C:\Program Files\HP\NCU;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Microsoft SQL Server\80\Tools\Binn\;C:\Program Files\Common Files\Sage SBD\;C:\Program Files\Microsoft SQL Server\90\Tools\binn\
_SERVER["argc"] 0
_ENV["Path"] E:\php4win\;C:\Program Files\PHP\5.2.17\;C:\Program Files\HP\NCU;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Microsoft SQL Server\80\Tools\Binn\;C:\Program Files\Common Files\Sage SBD\;C:\Program Files\Microsoft SQL Server\90\Tools\binn\
_ENV["PATHEXT"] .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH
_ENV["PHPRC"] E:\php4win\
*****************************
So when I try to run a script that uses mysqli calls, it reports the following" "Fatal error: Call to undefined function mysqli_connect() in".
The php_mysqli.dll is located in the PHP5 extension directory but doesn't seem to be picked up for some reason.
So my questions are:
1) Can anyone see where I've gone wrong ?
2) What more can I do to resolve this issue ? Short of scrapping the current production enviroment and force users onto the new enviroment before it's been tested.
Any help is very much appreciated.
Thank you in advance. |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7373 Location: Germany, Next to Hamburg
|
Posted: Mon 11 Apr '11 20:57 Post subject: |
|
|
in your apache 2.2 installation your can add in httpd.conf where to take the config file from.
Code: |
LoadModule php5_module "c:/php5/php5apache2_2.dll"
AddHandler application/x-httpd-php .php
# configure the path to php.ini
PHPIniDir "c:/php5"
|
I hope your php4 php.ini is not in C:\Windows
Do you see mysqli when you open phpinfo script in your browser? |
|
Back to top |
|
smilerdude
Joined: 11 Apr 2011 Posts: 7
|
Posted: Mon 11 Apr '11 23:00 Post subject: |
|
|
Thank you for your response, it's much appreciated.
The code was already in the new apache's httpd.conf file for the location of the php 5 install directory and ini file.
Code: | #PHP5 - My version
#BEGIN PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL
LoadModule php5_module "C:\Program Files\PHP\5.2.17\php5apache2_2.dll"
AddHandler application/x-httpd-php .php
PHPIniDir "C:\Program Files\PHP\5.2.17\"
#END PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL |
When I do the PHPversioninfo() on the new apache server, there is no mention of MYSQLI any where. All the required php_mysql*.dll's are in the PHP 5 ext directory.
This is why I'm struggling to understand why PHP 5 changes are not being picked up.
Unfortunately the PHP4.ini file is located in the windows directory. This is from an installation before I joined the company.
From my PHP/Apache research into this issue, says that PHP 4 and versions below needed it's PHP.ini file to be in the windows directory. Is this correct ?
I think I should be able to move this PHP 4 ini file from the windows directory, but I'm not sure where to or what edits to configuration files should are required. |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7373 Location: Germany, Next to Hamburg
|
Posted: Tue 12 Apr '11 10:05 Post subject: |
|
|
You also have to enbale the extension in your php.ini
e.g.
Code: |
;extension=php_mysqli.dll
to
extension=php_mysqli.dll
|
|
|
Back to top |
|
smilerdude
Joined: 11 Apr 2011 Posts: 7
|
Posted: Tue 12 Apr '11 12:03 Post subject: |
|
|
The Code: | extension=php_mysqli.dll | line is exactly the same in my php 5 php.ini file. |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7373 Location: Germany, Next to Hamburg
|
Posted: Tue 12 Apr '11 17:02 Post subject: |
|
|
A simple script will help to see if the extension is loaded.
Code: |
<?php
$ext = get_loaded_extensions();
asort($ext);
print_r($ext);
$inipath = php_ini_loaded_file();
if ($inipath) {
echo 'Loaded php.ini: ' . $inipath;
}
else
{
echo 'A php.ini file is not loaded';
}
if ($filelist = php_ini_scanned_files()) {
if (strlen($filelist) > 0) {
$files = explode(',', $filelist);
foreach ($files as $file) {
echo "<li>" . trim($file) . "</li>\n";
}
}
}
?>
|
Please run this over the web server and the command line. |
|
Back to top |
|
smilerdude
Joined: 11 Apr 2011 Posts: 7
|
Posted: Tue 12 Apr '11 19:43 Post subject: |
|
|
I've run the script you provided on both the command line and with the web browser.
The results are: Code: | E:\www\ajnew\php5test>"C:\Program Files\PHP\5.2.17\php.exe" "E:\www\ajnew\php5test\info.php"
Array
(
[12] => Reflection
[20] => SPL
[18] => SimpleXML
[0] => bcmath
[1] => calendar
[2] => com_dotnet
[3] => ctype
[4] => date
[19] => dom
[5] => filter
[6] => ftp
[7] => hash
[8] => iconv
[9] => json
[14] => libxml
[25] => mysqli
[10] => odbc
[11] => pcre
[13] => session
[15] => standard
[16] => tokenizer
[21] => wddx
[22] => xml
[23] => xmlreader
[24] => xmlwriter
[17] => zlib
)
Loaded php.ini: C:\Program Files\PHP\5.2.17\php.ini
E:\www\ajnew\php5test>
From browser:
Array ( [12] => Reflection [20] => SPL [18] => SimpleXML [25] => apache2handler [0] => bcmath [1] => calendar [2] => com_dotnet [3] => ctype [4] => date [19] => dom [5] => filter [6] => ftp [7] => hash [8] => iconv [9] => json [14] => libxml [10] => odbc [11] => pcre [13] => session [15] => standard [16] => tokenizer [21] => wddx [22] => xml [23] => xmlreader [24] => xmlwriter [17] => zlib ) Loaded php.ini: C:\WINDOWS\php.ini |
It seems the Apache 2.2.17 instance is finding the PHP 4 php.ini file in the windows directory, even though it's httpd.conf has the following lines in it to force it to locate the PHP 5 php.ini file.
Code: |
#PHP5 - My version
#BEGIN PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL
#PHPIniDir "C:\Program Files\PHP\5.2.17\"
LoadModule php5_module "C:\Program Files\PHP\5.2.17\php5apache2_2.dll"
AddHandler application/x-httpd-php .php
PHPIniDir "C:\Program Files\PHP\5.2.17\"
#END PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL
|
|
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7373 Location: Germany, Next to Hamburg
|
Posted: Wed 13 Apr '11 10:28 Post subject: |
|
|
You should move the php.ini (PHP 4) from C:\Windows to you PHP 4 folder and add PHPIniDir with the correct that to it. And / or delete the PHPRC env variable. |
|
Back to top |
|
smilerdude
Joined: 11 Apr 2011 Posts: 7
|
Posted: Wed 13 Apr '11 17:34 Post subject: |
|
|
It would be lovely to move the PHP 4 php.ini from the windows directory, using the PHPDirIni directive in Apache's httpd.conf.
There's a small problem. The Apache version is 1.7, which doesn't support the PHPDirIni directive. Only Apache 2 modules or higher, support it. And that has given me an idea, that I'm surprised I didn't think of before because I was too fixated getting Apache 2.2.17 working alongside the existing Apache 1.7 version.
I noticed today that Apache 2.0 module, works with PHP 4.3.2 and does support the PHPDirIni directive.
New idea:
Current Production Environment: Apache 1.7, PHP 4.3.2 and MySQL 3.1
1) Upgrade Apache 1.7 to 2.0.
2) Shut down Apache 1.7 service
3) Copy the Apache 1.7's httpd.conf file, to 2.0.
4) Add the PHPDirIni directive and move the php 4 php.ini file from winodws dir to somewhere else.
5) Start new Apache 2.0 service.
6) Have plenty of cold beers as a reward.
This should be a short term solution, whilst the new environment is tested.
What do you think of this plan ? |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7373 Location: Germany, Next to Hamburg
|
Posted: Wed 13 Apr '11 20:31 Post subject: |
|
|
Well I guess there is not apache 1.7, but 1.3 How ever, I think your plan is good. But it has two issues. First: you should update to apache 2.2 since 2.0 will be die soon. Second: you can't use the config file from 1.3 in 2.0 or 2.2 cause the config and the module changed.
My Idea for you. Install Apache 2.2. Run it on a different port. Installl mod_fcgid. Than you can run PHP 4 and PHP 5 at the same time.
See http://www.apachelounge.com/viewtopic.php?t=3430 for this.
If you still have a question. Please ask again. |
|
Back to top |
|
somnang
Joined: 08 Apr 2011 Posts: 61
|
Posted: Thu 14 Apr '11 12:27 Post subject: |
|
|
Did you know the newer version of Apache fixes many security exploits found on the older version of Apache? just sayin... |
|
Back to top |
|
smilerdude
Joined: 11 Apr 2011 Posts: 7
|
Posted: Wed 04 May '11 18:44 Post subject: Got both working using "sticky tape" and "ban |
|
|
Just letting you guys know I got my original proposition working without going down the fastcgi route.
This is a dirty and temporary solution but it allowed the new Apache/PHP version to be tested, with the current Apache/PHP to run at the same time.
This solution only works as long as the server isn't rebooted often or the services crash. If this happens, then follow the steps below will be required to get both instances up and running again.
It requires 2 steps:
1:
a) Shut both versions of Apache 1.7 and 2.2.17.
b) Temporarily remove direction locations of Apache 1.7 from environmental variables PATH and PHPRC. Add the paths for the 2.2.17 in these variables.
c) Temporarily renamed the PHP4's ini file in the windows directory.
d) Started 2.2.17's service.
2:
a) Undid the temporary changes, so that the ENV variables pointed to 1.7 and renamed PHP4's ini back to it's original name.
b) Started 1.7's service.
So when the new Apache/PHP config is tested. I can change the ENV variables on the fly to the new Apache config, rename the PHP4's ini to something else. Then just shut down the old 1.7 service.
Easy peasy, lemon squeezy. |
|
Back to top |
|