12

After Reading a couple of question on how to upgrade xampp to newer versions of php. I started upgrading mine to version 7 as I wanted to learn

strict type hinting

I downloaded php 7 from officialsite.I copied the content of this downloaded folder to php folder of xampp.but it is not working.I renamed php.ini-development to php.ini.Is there any better way to do this because it is not working.

Please help.

Bugfixer
  • 2,547
  • 2
  • 26
  • 42

2 Answers2

22

I consider @camelCase good, but you can also consider trying this method. It may suite your need.

Upgrade to PHP7 in XAMPP Before proceeding further I will recommend to take backup of your XAMPP configuration. After you have made backup below are some steps to use PHP7 with in your XAMPP

  1. Download PHP7 : Download php7 from php.net website.

If your apache is thread safe then download a thread safe version of PHP7 otherwise download NTS i.e non thread safe version.

  1. Place PHP on appropriate place in your XAMPP : Put your PHP7 in your XAMPP. I usually prefer to to put on location /XAMPP/php7 but you can put as per your need. There is no any restriction for putting your new php version in xampp.

  2. Include PHP7 with your apache : In XAMPP, PHP is configured using apache file path [yourxampp/apache/conf/extra/httpd-xampp.conf]. Please open the file add first change all variable path from php7 directory.

Also do not forget to add php7 module using below code

LoadFile yourxampppath/php7/php7ts.dll
LoadFile yourxampppath/php7/libpq.dll
LoadModule php7_module yourxampppath/php7/php7apache2_4.dll

Make sure to change PHP ini directory for your PHP7

<IfModule php7_module>
    PHPINIDir "yourxampppath/php7"
</IfModule>

Chechout www.techflirt.com

scireon
  • 365
  • 2
  • 4
  • 17
Abayomi Israel
  • 589
  • 6
  • 14
  • 3
    Look through your httpd-xampp.conf, make the above changes, also change every other instance of "php5" to "php7". But, one more thing: When I left `LoadFile yourxampppath/php7/libpq.dll`, just as above, my Apache wouldn't start. I commented out that line, and voila, Apache starts. – TARKUS Sep 05 '17 at 00:21
  • 7
    For all others like me wondering if they need "thread safe" or "non thread safe", see here: https://stackoverflow.com/q/1623914/1066234 - I also looked into http://localhost/phpinfo.php and found `Thread Safety` as `enabled`. – Avatar Feb 13 '18 at 18:14
  • 3
    I followed the exact same steps to upgrade PHP 5.6 to PHP 7.3; I get following error when I try to restart Apache Service... Error: Apache shutdown unexpectedly. This may be due to a blocked port, missing dependencies, improper privileges, a crash, or a shutdown by another method. – Ruturaj Patki Mar 20 '19 at 14:24
  • If the above doesn't work for you: Don't assume that your XAMPP PHP is x64 just because your machine is! You can test this by using the PHP function `phpinfo()` and checking the "Architecture" near the top of the info. Or you can just download and try the x86 version. – Dan Aug 19 '20 at 09:15
6

Not sure if you were able to resolve this, but figured I'd suggest an approach since this question comes up high in Google searches and might benefit others.

Apache Friends released a version of XAMPP for Windows, Linux, and OS that supports PHP 7.0.1.

From the site:

We just released a new version of XAMPP for all platforms with PHP 7.0.1. This version also includes a fixed version of the setup_xampp.bat and test_php.bat scripts for Windows.

It can be downloaded from Apache Friends.

camelCase
  • 5,460
  • 3
  • 34
  • 37
  • 1
    If I install new version, what happens to old projects in htdocs and existing databases? Should I backup them before upgrading? – Amar Ilindra Aug 16 '18 at 12:11
  • 1
    @AmarIlindra you have to take a backup of the htdocs. As for the databases make a copy too. But then it doesnt work that way. So the copy is just for emergency as I had didn't do the following step once and then i imported the sql databases one by one and it worked. A better way is to go to phpmyadmin and export all the databases and then after you copy the htdocs directory you can go to the phpmyadmin of the new installation and then import the databases back. Note: Importing the copy of databases in the mysql folder worked for me but online it didnt work for some people – rawraj Jan 26 '19 at 16:54
  • If you do not want to play around having to re-configure things and do not mind having a brand new setup, this answer is a great alternative. It can save you time! – dankilev Oct 17 '19 at 10:34