Wampserver not changing the PHP version for WEB (not CLI)

只谈情不闲聊 提交于 2020-02-16 08:42:10

问题


I have WampServer Version 3.1.4 64bit installed on Windows 7 and it comes with PHP versions php5.6.38, php7.0.32, php7.1.22, and php7.2.10. I would like to use php5.6.x rather than php7.x.

So, when I switch from php7.2.10 to php5.6.38 from the server tray icon; it does not update the actual php version which is shown by phpinfo(). On localhost, it still says:

PHP Version: 7.2.10

However, it is updated on CLI side. This is tested with running this in the cmd:

php -v

The result is :

c:\wamp64\bin\apache\apache2.4.35\bin>php -v
PHP 5.6.38 (cli) (built: Sep 13 2018 12:45:08)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies

After restarting WAMP services, and re opening the terminal, and restarting computer, it still not updated through phpinfo. It probably related the php version used by Apache service. How can I change this to 5.6.x Any suggestions ? Many thanks

Note : The issue is not related with changing php cli version as it was pointed here. I do not understand why some of them insist that this is potential duplication without reading the post carefully.


回答1:


The wampmanager->Tools->Change PHP CLI Version menu only changes the version of PHP that will be used by wampmanager.exe to run all the PHP scripts that provide all the functionality of WAMPServer.

It has no effect on the version of PHP that will will be run from the command line in Windows.

If when you open a command windows and run the PHP interpreter >php.exe you actually get to the PHP interpreter, then you must have added one of the possible paths to one of WAMPServers PHP folders to the Window's PATH. You should never do this with WAMPServer, so if this is what you did, UNDO IT! This is for obvious reasons as you could have multiple versions of PHP available and want to run any one of them at any time as the CLI Version to test some code against multiple versions of PHP.

Instead create yourself a little batch/cmd file that accepts a php version as a parameter like in this answer I posted a while ago

With that you can set the PATH temporarily for the life of a command window ONLY. You can also make it include a PATH to the PEAR and/or COMPOSER folders at the same time, if you use either of these.

To check All VC Runtimes

There is a tool for checking if you have all the possible required VC Runtimes installed. Go to this page, the backup repo for WAMPServer, and download the little utility called Checks VC++ packages installed you will find it down near the bottom of the page. Download and run it, then throw it away, as it changes over time as new VC Runtimes become required.




回答2:


(TL:DR) Use left click -(instead of right click)- menu to change PHP versions.

(Long explanation) Hi, this happened to me today. I was trying to change the php version from 7.2 to 5.6 to test something. However, Wampserver was not changing the web version of php. After much searching in the web and noticing in certain videos that some people were getting a different menu than me in the wamp server icon, I realised that there is a whole left click menu in wampserver in which you can change the php version and it does change the web version of php.

I understand that this can be a bit confusing for people who are used to using wampserver, but for someone who is using it for the first time, we are not used to having a left click menu in the bottom right icons. I hope this saves some time for others who have a similar issue than mine.



来源:https://stackoverflow.com/questions/53992272/wampserver-not-changing-the-php-version-for-web-not-cli

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!