When we open apache, we can see that php has many version numbers. When we don’t want to use php5, how should we switch the version to php7? The editor will introduce to you the switching method below.
Open the official website and find the FAQhttps://www.appserv.org/en/faq/
Question
to switch Version of PHP do?
Answer
to the Shortcut -> PHP Version Switch switch PHP Version needed immediately.
Find the php version switch in the start menu of win10, click it, and the dialog box will flash and then disappear quickly.
Enter localhost/phpinfo.php in the browser address bar
In the PHP version under Core, php The version number remains unchanged (5.5.*)
Open the AppServ/php5/extras/swver.php file, we found that
<?php error_reporting(0); $conf="D:/AppServ/Apache24/conf/httpd.conf"; $php5ini="D:/AppServ/php5/"; $php7ini="D:/AppServ/php7/";...
The following code is Judgment statements, etc., but we can see $conf and modify it according to the path
Open D:/AppServ/Apache24/conf/httpd.conf
Find the following code (about line 180)
LoadModule php5_module D:/AppServ/php5/php5apache2_4.dll<IfModule mod_php5.c> AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps</IfModule><IfModule mod_php7.c> AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps</IfModule>PHPIniDir "D:/AppServ/php5/"
Copy the two pieces of code
LoadModule php5_module D:/AppServ/php5/php5apache2_4.dll
and
PHPIniDir "D:/AppServ/php5/"
and add # in front of the original code
Change the 5 in the pasted code to 7
Restart Appche and run localhost/phpinfo.php
Success!
The openssl extension is required for SSL/TLS protection but is not available. If you can not enable the openssl extension, you can disable this error, at your own risk, by setting the 'disable-tls' option to true.
Open php.ini and modify the configuration ssl, remove the comma ";" in front of extension=php_openssl.dll
Restart Appche!
Recommended learning: php video tutorial
The above is the detailed content of How to switch the php version in apache. For more information, please follow other related articles on the PHP Chinese website!