Php switch don't work
Posted by: nobbie (---.124.98.135.rybnet.pl)
Date: March 06, 2014 04:47AM

Hello,

I have problem with php/apache switch feature(php and apache addons). Don't want work, always orange icon.
I added all modifications from topic [forum.wampserver.com] but still don't working. Switch buttons are clickable but WAMP works only when is set on default apache/php:
Apache 2.4.4 | PHP 5.4.12 = WORKS GREAT
Apache 2.4.4 | PHP 5.2.2 = DON'T WORK
Apache 2.2.9 PHP 5.2.2 = DON'T WORK
Apache 2.2.3 PHP 5.2.2 = DON'T WORK
I have no idea how I can fix it... please help:

Below some informations:

Version of Operating system?
Windows 8.1(migration from 8.0)

Version of Wamp Server installed?
WAMPSERVER 2.4

Version of Apache you are running?
Apache 2.4.4 + installed addons: Apache 2.2.9 , Apache 2.2.3

Version of MySQL you are running?
5.6.12

Version of PHP you are running?
PHP 5.4.12 + installe addon: PHP 5.2.2

Host file:
127.0.0.1 localhost

File: \wamp\bin\php\php5.4.12\wampserver.conf
<?php

$phpConf['phpIniDir'] = '.';
$phpConf['phpExeDir'] = '.';
$phpConf['phpConfFile'] = 'php.ini';

$phpConf['apache']['2.2']['LoadModuleName'] = 'php5_module';
$phpConf['apache']['2.2']['LoadModuleFile'] = 'php5apache2_2.dll';
$phpConf['apache']['2.2']['AddModule'] = '';

$phpConf['apache']['2.4']['LoadModuleName'] = 'php5_module';
$phpConf['apache']['2.4']['LoadModuleFile'] = 'php5apache2_4.dll';
$phpConf['apache']['2.4']['AddModule'] = '';

?>

File: wamp\bin\php\php5.2.2\wampserver.conf
<?php

$phpConf['phpIniDir'] = '.';
$phpConf['phpExeDir'] = '.';
$phpConf['phpConfFile'] = 'php.ini';

$phpConf['apache']['2.2']['LoadModuleName'] = 'php5_module';
$phpConf['apache']['2.2']['LoadModuleFile'] = 'php5apache2_2.dll';
$phpConf['apache']['2.2']['AddModule'] = '';

$phpConf['apache']['2.4']['LoadModuleName'] = 'php5_module';
$phpConf['apache']['2.4']['LoadModuleFile'] = 'php5apache2_4.dll';
$phpConf['apache']['2.4']['AddModule'] = '';

?>

Options: ReplyQuote
Re: Php switch don't work
Posted by: RiggsFolly (---.as13285.net)
Date: March 06, 2014 09:59AM

I think this is because if you installed WAMPServer 2.4 and got 'Apache 2.4.4 | PHP 5.4.12' then you installed the 64bit wamp.

Unfortunately all the ADDONS are still 32bit versions so you are trying to run a 64bit apache with a 32 bit PHP and that wont work.


If you want to be able to use older versions of Apache, you will have to install the 32bit WAMPServer, as I am fairly sure even if you try and install Apache manually, there are not 64bit versions of Apache that old..

---------------------------------------------------------------------------------------------
(Windows 10 Pro 64bit) (Wampserver 3.3.4 64bit) Aestan Tray Menu 3.2.5.4
<Apache versions MULTIPE> <PHP versions MULTIPLE> <MySQL Versions MULTIPLE>
<MariaDB versions MULTIPLE> <phpMyAdmin versions MULTIPLE> <MySQL Workbench 8.0.23>

Read The Manuals Apache -- MySQL -- PHP -- phpMyAdmin
Get your Apache/MySQL/mariaDB/PHP ADDONs here from the WAMPServer alternate Repo
-X-X-X- Backup your databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-

Options: ReplyQuote
Re: Php switch don't work
Posted by: nobbie (---.124.98.135.rybnet.pl)
Date: March 06, 2014 05:25PM

Hi,

I found the bug.
There were set wrong extension_dir in:
wamp\bin\apache\Apache2.2.9\bin\php.ini
wamp\bin\apache\Apache2.2.3\bin\php.ini

And you are right, i have installed Wampserver2.4-x64.exe but now(with correct extension_dir) apache, php and mysql works fine(but sometime i can see error like this [imgur.com]). Phpinfo shows correct informations about php and apache.

However, I have a problem with PhpMyAdmin. Works only for Apache 2.4.4 | PHP 5.4.12. When i try open PhpMyAdmin on another apache/php I get:
"Forbidden
You don't have permission to access /phpmyadmin/ on this server."
Any idea how to fix it?

Options: ReplyQuote
Re: Php switch don't work
Posted by: RiggsFolly (---.as13285.net)
Date: March 06, 2014 05:44PM

RE: Error message. Make sure you have
Microsoft Visual C++ 2008 SP1 Redistributable Package (x86) [www.microsoft.com]

Thats the 32bit library, as wampmanager uses that!!

RE: phpmyadmin

phpmyadmin is independantly secured i.e. look at wamp\alias\phpmyadmin.conf

You may have an issue with the syntax for Apache 2.2 and 2.4 as it changed in 2.4 but wamp uses that same file regardless of the version of Apache in use. Also older versions of Apache were not IPV6 aware so I changed mine to cope with both situations as follows.

You also have to make sure Apache has the version_module enabled to use the <IfVersion...> syntax


I am using phpmyadmin 4.1.7 but yours will probably be different so just leave yours as it is set.

<Directory "d:/wamp/apps/phpmyadmin4.1.7/">
   Options Indexes FollowSymLinks MultiViews
   AllowOverride all

	<IfVersion < 2.4>
            Order Deny,Allow
            Deny from all

             <IfVersion <= 2.2.21>
    	            Allow from 127.0.0.1 localhost
              </IfVersion>

             <IfVersion >= 2.2.22>
    	           Allow from 127.0.0.1 ::1 localhost
             </IfVersion>

       </IfVersion>

       <IfVersion >= 2.4>
		Require local
	</IfVersion>
</Directory>

---------------------------------------------------------------------------------------------
(Windows 10 Pro 64bit) (Wampserver 3.3.4 64bit) Aestan Tray Menu 3.2.5.4
<Apache versions MULTIPE> <PHP versions MULTIPLE> <MySQL Versions MULTIPLE>
<MariaDB versions MULTIPLE> <phpMyAdmin versions MULTIPLE> <MySQL Workbench 8.0.23>

Read The Manuals Apache -- MySQL -- PHP -- phpMyAdmin
Get your Apache/MySQL/mariaDB/PHP ADDONs here from the WAMPServer alternate Repo
-X-X-X- Backup your databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-

Options: ReplyQuote
Re: Php switch don't work
Posted by: nobbie (---.124.98.135.rybnet.pl)
Date: March 06, 2014 09:03PM

Thanks. Your phpmyadmin solution works perfect.

Last problem:
Wamp overwrites extension_dir in random php.ini files(wamp\bin\apache\ApacheX.X.X\bin\php.ini) (sometimes probably when i switching php/apache)
Maybe this inconvience is caused by errors like this [imgur.com] or my 64bits WAMP version what you said before? Maybe I should remove 64bit WAMPSERVER and install WAMPSERVER (32 BITS & PHP 5.4) 2.4 ??

However, my OS is Windows 8.1 x64.

Options: ReplyQuote
Re: Php switch don't work
Posted by: RiggsFolly (---.as13285.net)
Date: March 06, 2014 10:42PM

Personally I would install 32bit WAMP, it works on 32 or 64 bit windows. not all PHP extensions that you may decide you want to use are converted to 64 bit yet.


However the switch bug is correctable on either version:



This bug only occurs when switching versions of Apache and generates an incorrect phpForApache.ini file in the PHP version that was running with the Apache that is being switched away from.

This explanations will assumes we are running Apache 2.4.7 and PHP 5.5.6 for demonstration purposes and to show what WAMP does in the following situations.
These versions may or may not actually exist.

All the code that does any of this switching is actually run as PHPCLI scritps that live in the \wamp\scripts folder.
This is why there is a file in the \wamp\bin\php folder called DO_NOT_DELETE_5.4.16.txt, becasue all these CLI scripts depend upon the PHP version mentioned there existing.

- 1 - Change the PHP version
- So this is the senario, we are running Apache 2.4.7 with PHP 5.5.6 and we want to switch just the version of PHP to PHP 5.5.4

These are the relevant enties in wampserver.ini
Type: item; Caption: "5.5.4"; Action: multi; Actions:switchPhp5.5.4

The switching process is performed by calling (Among others):

Action: run; FileName: "C:/wamp/bin/php/php5.5.4/php-win.exe";Parameters: "switchPhpVersion.php 5.5.4";WorkingDir: "C:/wamp/scripts"; Flags: waituntilterminated
Action: run; FileName: "C:/wamp/bin/php/php5.5.4/php-win.exe";Parameters: "-c . refresh.php";WorkingDir: "C:/wamp/scripts"; Flags: waituntilterminated


First the script C:/wamp/scripts/switchPhpVersion.php is run from the command line, where the paramter is the version of PHP we want to switch to i.e 5.5.4
That script finally calls C:/wamp/scripts/refresh.php which regenerates the file wampmanager.ini, this is so the Wampmanager menu are based on the new modified settings.

This result of this is:
- Click on the WampManager menu to switch to PHP5.5.4
- Call switchPhpVersion function with parameter ( 5.5.4 )
- The function switchPhpVersion, moves the current php.ini from the Apache folder to the PHP folder ( php folder for the version running )
copy ( C:/wamp/bin/apache/apache2.4.7/bin/php.ini,C:/wamp/bin/php/php5.5.6/phpForApache.ini ) ;

- Now it gets the php.ini from the new php version file
copy ( C:/wamp/bin/php/php5.5.4/phpForApache.ini,C:/wamp/bin/apache/apache2.4.7/bin/php.ini ) ;

- WampIniset Function - recreates the file ../wampmanager.conf with the new current version information
- Script refresh.php - regenerates the ../wampmanager.ini

So the PHP ini file for PHP5.5.6 is copied from the Apache folder back to its correctly versioned PHP folder before the New PHP version php5.5.4 has its phpForApache.ini file copied to the Apache folder.


- 2 - Change of Apache
So this is the senario, we are running Apache 2.4.7 with PHP 5.5.6 and we want to switch to Apache version 2.4.4. The PHP version should remain the same.

- Click on the WampManager menu to switch to Apache 2.4.4

Type: item; Caption: "2.4.4"; Action: multi; Actions:switchApache2.4.4

calling (Among others):

[switchApache2.4.4]
Action: service; Service: wampapache; ServiceAction: stop; Flags: ignoreerrors waituntilterminated
Action: run; FileName: "C:/wamp/bin/apache/apache2.4.7/bin/httpd.exe"; Parameters: "-n wampapache -k uninstall"; ShowCmd: hidden; Flags: ignoreerrors waituntilterminated
Action: closeservices; Flags: ignoreerrors
Action: run; FileName: "C:/wamp/bin/php/php5.5.4/php-win.exe";Parameters: "switchApacheVersion.php 2.4.4";WorkingDir: "C:/wamp/scripts"; Flags: waituntilterminated
Action: run; FileName: "C:/wamp/bin/php/php5.5.4/php-win.exe";Parameters: "switchPhpVersion.php 5.5.6";WorkingDir: "C:/wamp/scripts"; Flags: waituntilterminated
Action: run; FileName: "C:/wamp/bin/apache/apache2.4.4/bin/httpd.exe"; Parameters: "-n wampapache -k install"; ShowCmd: hidden; Flags: waituntilterminated
Action: run; FileName: "net"; Parameters: "start wampapache"; ShowCmd: hidden; Flags: waituntilterminated
Action: run; FileName: "C:/wamp/bin/php/php5.5.4/php-win.exe";Parameters: "-c . refresh.php";WorkingDir: "C:/wamp/scripts"; Flags: waituntilterminated


- Stop and uninstall the current wampapache Service : launch httpd.exe with parameter -k uninstall wampapache
- Change Apache ( from 2.4.7 to 2.4.4 ) by the command line script C:/wamp/scripts/switchApacheVersion.php with as parameter the new Apache 2.4.4
- Call PHP control script C:/wamp/scripts/switchPhpVersion.php with a parameter of the active PHP version i.e. PHP 5.5.6 to update php.ini in the newly activated Apache.
- Install wampapache as a Service : launch httpd.exe with parameter -n - k install wampapache
- Start the wampapache Service
- Finally the script C:/wamp/scripts/refresh.php is called which regenerates the file wampmanager.ini, so the Wampmanager menu is based on the new modified settings.

This results in the trace :

- In the script switchApacheVersion.php - Call function wampIniSet ; (/wampmanager.conf, 2.4.4 . ).
- WampIniset Function - Writing file ../wampmanager.conf
- Call switchPhpVersion function ( 5.5.6 )
- In function switchPhpVersion - Saves the current php.ini
copy ( C:/wamp/bin/apache/apache2.4.4/bin/php.ini, C:/wamp/bin/php/php5.5.6/phpForApache.ini ) ;

- Place the new php.ini
copy ( C:/wamp/bin/php/php5.5.6/phpForApache.ini, C:/wamp/bin/apache/apache2.4.4/bin/php.ini ) ;
- WampIniset Function - Writing file ../wampmanager.conf
- Script refresh.php - was regenerated ../wampmanager.ini


And this is where the bug is!
It overwrites the phpForApache.ini file in the currently running PHP version (5.5.6) with the php.ini file from the newly activated Apache2.4.4, but of course we have no idea what version of PHP this php.ini file came from, as we dont know what version of PHP we last used in this version of Apache.

It should have taken the php.ini from the old Apache (2.4.7) and not that of the new (2.4.4).

- 3 - Solution

It is quite complicated in the script to know what the old version of Apache was, once it has changed Apache.

At the end of all operations to change the configuration of WampServer, whatever these operations :
Version of Apache, PHP version, MySQL version, Apache modules, PHP extensions, PHP settings, management services, etc...
the script C:/wamp/scripts/refresh.php is executed, so that the file wamp/wampmanager.ini always reflects the current configuration of WampServer.

So we will inform the script wamp/scripts/swithPhpVersion.php what Apache version is currently in force, but only if we are changing Apache versions.

To do this, we will slightly modify the script wamp/scripts/refresh.php to add a second parameter
- the current Apache
- calls the script C:/wamp/scripts/switchPhpVersion.php but only the menu items change Apache ( It is unnecessary to add in the calls for change of PHP version.)

So in the file wamp/scripts/refresh.php

replace :
Action: run; FileName: "'.$c_phpCli.'";Parameters: "switchPhpVersion.php '.$wampConf['phpVersion'].'";WorkingDir: "'.$c_installDir.'/scripts"; Flags: waituntilterminated
with
Action: run; FileName: "'.$c_phpCli.'";Parameters: "switchPhpVersion.php '.$wampConf['phpVersion'].' '.$wampConf['apacheVersion'].'";WorkingDir: "'.$c_installDir.'/scripts"; Flags: waituntilterminated

This change will use the PHP version from the wamp/wampmanager.ini file, but only the items change Apache, for example:

Action: run; FileName: "C:/wamp/bin/php/php5.5.4/php-win.exe";Parameters: "switchPhpVersion.php 5.5.6";WorkingDir: "C:/wamp/scripts"; Flags: waituntilterminated
is replaced by
Action: run; FileName: "C:/wamp/bin/php/php5.5.4/php-win.exe";Parameters: "switchPhpVersion.php 5.5.6 2.4.7";WorkingDir: "C:/wamp/scripts"; Flags: waituntilterminated
which was added in the second parameter, the current version of Apache.
Now, we must detect the second parameter in the script change PHP versions.

In the file wamp/scripts/switchPhpVersion.php

replace
switchPhpVersion($newPhpVersion) ;
With
//[modif oto] Test if second parameter exists. Apache common
switchPhpVersion($newPhpVersion,(($_SERVER['argc'] >= 3) ? $_SERVER['argv'][2] : '')) ;

It should also take into account this parameter in the switchPhpVersion function:

So in the file wamp/scripts/wampserver.lib.php

replace

function switchPhpVersion($newPhpVersion)
{
    require 'config.inc.php' ;
with

//[modif oto] Ajout version Apache courante si basculement version Apache.
function switchPhpVersion($newPhpVersion,$oldApacheVersion="" )
{
    require 'config.inc.php';
    //[modif oto] - Chemin php.ini courant si changement version Apache.
    if(empty($oldApacheVersion))
      $c_phpOldConfFile = $c_phpConfFile;
    else
      $c_phpOldConfFile = $c_apacheVersionDir.'/apache'.$oldApacheVersion.'/'.$wampConf['apacheExeDir'].'/'.$wampConf['phpConfFile'] ;

and replace

         // on sauvegarde le php.ini courant
            copy($c_phpConfFile,$c_phpVersionDir.'/php'.$wampConf['phpVersion'].'/'.$phpConfFileForApache) ;
with
        // on sauvegarde le php.ini courant
            copy($c_phpOldConfFile,$c_phpVersionDir.'/php'.$wampConf['phpVersion'].'/'.$phpConfFileForApache) ;
{/code]

Now, assuming we have Apache 2.4.7 and PHP 5.5.6 configured as current, change the Apache version to 2.4.4, we obtain the trace:
 - SwitchPhpVersion call function (5.5.6)
 - In function switchPhpVersion - Saves the current php.ini
   copy (C:/wamp/bin/apache/apache2.4.7/bin/php.ini,C:/wamp/bin/php/php5.5.6/phpForApache.ini);

 - Place the new php.ini
   copy (D:/wamp/bin/php/php5.5.6/phpForApache.ini,C:/wamp/bin/apache/apache2.4.4/bin/php.ini);

 - WampIniset Function - Writing file ../wampmanager.conf
 - Script refresh.php - was regenerated ../wampmanager.ini

It has saved the current php.ini from the old Apache version 2.4.7, and loaded php.ini into the new version of Apache 2.4.4.
This description was a bit long, but it helps to understand the internal operation of WampServer.


Originally posted by otomatic in French so all kudos belong to him, only the English translation was done by me, and before you ask, no I dont speak French but I can use Google Translator and then try and sort out the position of the verb.

---------------------------------------------------------------------------------------------
(Windows 10 Pro 64bit) (Wampserver 3.3.4 64bit) Aestan Tray Menu 3.2.5.4
<Apache versions MULTIPE> <PHP versions MULTIPLE> <MySQL Versions MULTIPLE>
<MariaDB versions MULTIPLE> <phpMyAdmin versions MULTIPLE> <MySQL Workbench 8.0.23>
Read The Manuals Apache -- MySQL -- PHP -- phpMyAdmin 
Get your Apache/MySQL/mariaDB/PHP ADDONs here from the WAMPServer alternate Repo
-X-X-X- Backup your databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-

Options: ReplyQuote
Re: Php switch don't work
Posted by: nobbie (---.124.98.135.rybnet.pl)
Date: March 09, 2014 07:17PM

Looks that now everything works OK but i need some days to full tests winking smiley
Thanks.

Options: ReplyQuote
Re: Php switch don't work
Posted by: nobbie (---.124.98.135.rybnet.pl)
Date: March 09, 2014 10:04PM

I need some days for testing but now everything works great.
Big thanks winking smiley



Edited 1 time(s). Last edit at 03/09/2014 10:04PM by nobbie.

Options: ReplyQuote


Sorry, only registered users may post in this forum.