This article will introduce to you how to upgrade ThinkPHP3.2.3 from php5 to php7. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.
First of all, does ThinkPHP3.2.3 support php7? Absolutely.
Under windows, the previous project was deployed in the Apache2.4.17 php5.x version. Because the customer's network security scan found many vulnerabilities, including high-risk vulnerabilities in apache and php, as many as hundreds of times. , in urgent need of repair, if not repaired, there will be a risk of site closure.
So I contacted the software supplier, who promised to cooperate with the upgrade, but ultimately failed to upgrade. The reply given was that ThinkPHP3.2.3 cannot be deployed in php7.
So I had to rely on myself and fumbled for three or four days. Finally, the upgrade was successful. Now I would like to share with you the general process.
1. Upgrade apache, download address http://httpd.apache.org/download.cgi, the downloaded version is 2.4.33
The most important one is the configuration file as shown below :
apache loading php support
PHPIniDir d:/GPS-LOCK/php/php.ini
LoadModule php7_module D:/ GPS-LOCK/php/php7apache2_4.dll
I have encountered many problems in this step. If the PHPIniDir path is enabled, apache cannot start. Finally, it is found that the php.ini file references php_ptheads.dll multi-threading. . After repeated attempts, the problem was solved.
2. Upgrade php, download address: https://windows.php.net/download/ What is downloaded here is 7.2.26,
Now we will summarize the problems expected when upgrading php7
1. Here you need to install the compiled vc class library version corresponding to php7, vc_redist.x64.exe, the installation is vc15
2, sql server database support
This is because php7 does not load the sql server related dll by default
3. You need to download Microsoft Drivers for PHP for SQL Server https://www.microsoft.com/en-us /download/details.aspx?id=20098, I downloaded version 7.2
Modify the location file as follows
4. php.ini file in php7 , just omit php_.dll for ext and configure it as shown above. Currently, you need to copy the decompressed file to the php\ext directory
3. I thought the system could run normally under php7, but the project used multi-threading , php needs to support pthreads, and it is almost crashing now. After adding extension=pthreads to the php.ini file, apache cannot start again. It turns out that ptheads needs to be run in cli mode. The ptheads download address is https://windows.php.net/downloads/pecl/releases/pthreads/
Unzip the download package
1. Put pthreadVC2. The dll file is placed in the php root directory
2. Copy php_pthreads.dll to the php\ext directory.
Start apache again and find that it cannot be started. After searching a lot of information, it turns out that ptheads needs Running in cli mode, my solution is to create two php.ini configuration files, one for the site to use php.ini and the other php-cli.ini file for ptheads to use. The contents of the files are the same. At this point, the upgrade is finally completed. .
Recommended learning: php video tutorial
The above is the detailed content of How to upgrade ThinkPHP3.2.3 from php5 to php7. For more information, please follow other related articles on the PHP Chinese website!