I have upgraded to PHP 5.3 on a development machine (Windows 7 box).
php-v shows
PHP 5.3.3 (cli) (built: Jul 21 2010 20:36:55)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
However, phpinfo.php shows that the version on the machine is: 5.2.14 as shown
The loaded configuration file rightly loads the correct php.ini file for 5.3
The configuration file (php.ini) Path wrongly reads: C:\Windows - I don't install PHP on the said path. I have however done a recursive search of PHP folders and files within that file but the search turned up nothing.
Applications seem to use the settings reported by the phpinfo and not by php -v or php -m or php -i (or else).
Apart from deleting the PHP folder and starting from scratch (which I have done), and ensuring that Apache points to the right PHP dir using PHPINIDir, what could I possibly do to solve this? Thanks.
Hello
You should also update apache php
module
#soju - that fixed it, thanks, but I thought I'd make this a little clearer for others.
Apache requires the php module to serve php files. On Windows it comes as a .dll file. This would be called: php5apache2_2.dll - located within your php folder. Strangely though, during upgrading the php folder with a newer version, you may find out that apache still uses the old php module file. So while php -v correctly reports the new version, Apache still looks at the old php module (reported by phpinfo). To find out what module version you have, you could: right-click on the .dll file > select properties -> view the details tab. Or just hover on the file.
If this version is not what you want, you might want to hunt for a newer version and replace it. Good idea to back up first. Also, the php5apache.dll file works with and requires the file: php5ts.dll - so ensure these files are the same versions.
With your httpd.conf file with the directive:
LoadModule php5_module "\path to\php5apache2_2.dll"
You may restart apache and smile!
Your command line (CLI) php is an other version than the one used for Apache. Check also that both use the same php.ini. When you call on your Windows machine
c:\path\to\php\php.exe -v
or
c:\path\to\php\php-win.exe -v
and
c:\path\to\php\php-cli.exe -v
They all can return different versions. Often this happens when upgrading to a new WAMP version and forgetting to delete the old versions. I'm sure you will find the executable PHP binary which matches the same version. It is also save to use the php.exe or php-win.exe instead the php-cli.exe on Windows.
Related
I'm a begginer in Laravel and I installed XAMPP as local server. I noticed that my XAMPP already install php 7.4 as it's dependency. But when I tried php -v in www dir in php it shown.
'php' is not recognized as an internal or external command, operable
program or batch file.
But in php directory is shown
PHP 7.4.15 (cli) (built: Feb 2 2021 20:47:45) ( ZTS Visual C++ 2017
x64 ) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c)
Zend Technologies
So, should I install additional php in my system for development? Should the version of the php matche with XAMPP php 7.4?
php -v will only tell you if you have PHP installed as a command line interface (PHP-CLI) which would enable you to run php code in cmd.exe or powershell. You'd normally not need this, but for reference here's how to enable it: https://stackoverflow.com/a/10753133 (mind the comment on Windows 10).
To check if PHP runs in your webserver environment (which is by default available in xampp), create a file test.php in your www folder with the following content:
<?php
phpinfo();
?>
Call this file in a browser, you will get an overview of all php features available. Delete the file before you go productive, because it will also give hackers a lot of information (which you don't want).
Try to add XAMPP PHP to Environment Variables
here is an instructions for Windows 10
I'm currently using Raspbian Wheezy 7.0 right now. Since PHP 5.6 is not available on the apt repositories for wheezy, I decided to build it from source. The build worked perfectly, I didn't receive any errors from it.
So when I used php -v it gave me the following output.
PHP 5.6.10 (cli) (built: Sep 18 2016 09:23:21)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies
Ok, I thought. Perfect, everything is updated like it should be.
Here's where the problem comes in. For some reason, when I use phpinfo() on my apache2 server. It says that I'm still on version 5.4.45.
My first guess was that the module apache was using libphp5.so located in /usr/lib/apache2/modules/ was out of date. But, I have no idea where the libphp5.so module is for the new php version that I just installed is.
It'd be great if anyone could help me with this or point me in the right direction. I'm using Apache version 2.2.
As you can see from your console, php -v is the CLI binary. When building PHP you can build many different binaries for different SAPIs (Server APIs), one of them being CLI. Apache2 Handler or mod_php would be another one. In order to build your PHP as an Apache httpd module you need to make sure you include the --with-apxs2 configuration option when compiling from source. This means running ./configure --with-apxs2 before you make; make install; the binary. You then need to make sure to load the newly built libphp5.so or mod_php.so (however you built it) to the appropriate directly and load it from your Apaache httpd config. Where your newly compiled binaries are stored, depends on your compile time configuration options and environment, but typically they are located in $PREFIX/$HOME/bin. So for example, if you compiled --with-prefix=/usr you might get /usr/php/bin/libphp5.so, but typically the binary is moved for you by make install. You do need to make sure you restart httpd for the newly built binary to be loaded.
See the PHP manual on installation for more details.
I have been using a software which files are encoded by Zend Guard. Since PHP 5.3 + versions don't support Zend Optimizer hence I have to install Zend Guard Loader to run that application on my windows xampp installation.
I downloaded Zend guard loader and copied to xampp folder.Then I edited the following lines to php.ini file.
zend_extension ="E:\xampp\ZendGuardLoader\php-5.4.x\ZendLoader.dll"
zend_loader.enable=1
Then restarted the xampp but it was giving php5.dll missing error then I downloaded php5.dll file from internet and uploaded to xampp/php folder and edited following file
xampp\apache\conf\extra\httpd-xampp.conf here I edited this line
LoadFile "/xampp/php/php5ts.dll"
to
LoadFile "/xampp/php/php5.dll"
then the php5.dll error gone and the following error occurred:
"the procedure entry point zend_new_interned_string could not be located in the dynamic link library E:\xampp\ZendGuardLoader\php-5.4.x\ZendLoader.dll"
When I tried to search on internet then found that this is the issue with 'Thread Safety' is enabled in xampp php. I don't know how to disable 'Thread Safety' or how to use 'Non Thread Safety' php version with xampp.
Please help me to install Zend Guard Loader on Windows 8 os Xampp 1.8.1 with php 5.4.x
Before you waste any more time checking, see if phpinfo() output shows that Thread Safety is enabled or not.
Zend Extensions are NTS (non thread safe) so if it is enabled, it cannot load and you need NTS PHP to load Guard Loader extension.
And
Thread Safety cannot be disabled, it is a compilation flag and how the compiled binary works.
You need to load a different Apache PHP Module which is non-thread-safe (php.net releases both TS and NTS builds).
Take a look to
http://forums.zend.com/viewtopic.php?f=57&t=43013
So, I had this same issue.
XAMPP (as far as version 3.2.1) comes bundled with Thread Safe PHP compilation. This is php binaries are compiled using a flag to force "Tread Safe", so, it can't be switched back on the same binaries.
You need to change the binaries of XAMP for those Non Tread Safe (NTS) compiled.
I followed this guide for replacing PHP in XAMP to use NTS. The guide explains how to enable FastCGI and Zend OPcache, so if you copy paste the steps, you should have XAMP run PHP on FastCGI mode. The relevant steps are:
Identify the version of Apache server that is running. [..]
Download the latest PHP binaries for windows. Choose the non-thread-safe (you might choose a newer version of php) [...] Create a new folder for the new version of PHP (ex. c:\xampp\php56-nts ).
Edit the Apache configuration file (ex: c:\xampp\apache\apache\conf\extra\ httpd-xampp.conf ) and replace the paths in the php5 module configuration you may need to change the name of the .dll
As php binaries downloaded from php.net can be used for developpment or for production, you need to create a php.ini according to your needs (there are 2 templates in the folder you can use to begin with: php.ini-development and php.ini-production )
With this, basically you have XAMPP to run PHP's NTS version. Afther that, you can install Zend Guard Loader as the guide says. Basically:
Download the Zend Guard Loader binary
Locate the ZendLoader.dll file and paste it inside the library path of php for xampp. Get the path.
Configure php.ini to use ZendLoader; Add
zend_extension=< full_path_to_ZendLoader.dll>
zend_extension=< full_path_to_opcache.dll>
Add any other optional configuration. Restart Apache and it should restart with the NTS version of PHP. You can test this with localhost/xampp/phpinfo.php
I have windows 8, and whenever I run php from the installed directory, then it works without a problem, but whenever I set the environment variable to that directory, and run php --version, then a win-8 bar appears:
This app can't run on your PC To find a version for your PC,
check with the software publisher
Has anyone encountered a similar issue or found a solution for this?
Attached below are the commands that i ran:
K:\Users\username>php
Access is denied.
K:\Users\username>php
Access is denied.
K:\Users\username>php --version
Access is denied.
K:\Users\username>F:/
'F:/' is not recognized as an internal or external command,
operable program or batch file.
K:\Users\username>F:
F:\>php
Access is denied.
F:\>cd Program
F:\Program>cd php-5.5.6-x86
F:\Program\php-5.5.6-x86>ls
dev iculx51.dll libpq.dll php.gif
ext icutest51.dll libsasl.dll php.ini-development
extras icutu51.dll license.txt php.ini-production
glib-2.dll icuuc51.dll news.txt php5.dll
gmodule-2.dll install.txt phar.phar.bat readme-redist-bins.txt
icudt51.dll libeay32.dll pharcommand.phar snapshot.txt
icuin51.dll libenchant.dll php-cgi.exe ssleay32.dll
icuio51.dll libenchant_ispell.dll php-win.exe
icule51.dll libenchant_myspell.dll php.exe
F:\Program\php-5.5.6-x86>php --version
PHP 5.5.6 (cli) (built: Nov 12 2013 11:33:16)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2013 Zend Technologies
F:\Program\php-5.5.6-x86>
By the way the same thing occurs in wampserver php, so it probably dont have anything to do with 86 bit install or 5.5.6 unstable.
I also tried run as admin not working either, same output.
You might have two PHP executables, one of them (F:\Program\php-5.5.6-x86\php.exe) is working, one of them (which is on your path) is not. Check the directories in your PATH for the broken one.
I have same issue before and tried several things, one of the things that works for me that the php.exe file has been changed by some program and it's size was 0 kb, I reverted back by bringing the php.exe file from backup folder I have.
may be it is not solution for all people, but just check the php file hasn't been changed.
I'm trying to load the MongoDb extension for php on a Windows 7 64 bit PC, running XAMPP with Apache 2.0 and PHP 5.3.5, compiler version VC6. I started out with this tutorial, and have also tried the extensions that the php documentation suggested. MongoDb itself is running fine, and shell commands seem to work.
At the moment I have:
Added extension=php_mongo.dll to my php.ini file.
Put the VC6 version of php_mongo.dll (from the following download page, suggested by the PHP documentation) in the php/ext folder.
Restarted my Apache server.
I have also tried php_mongo.dll files form Stealth's github, but they didn't seem to work either.
When restarting Apache, I don't get any errors, but I can't find anything on MongoDb in phpinfo(), and the Mongo class is not recognised either.
Any ideas of what might be wrong? Let me know if you need more info.
The problem might be incorrect version of extension. Try different versions downloaded from here: http://pecl.php.net/package/mongo/1.6.4/windows
Use Bitnami WAMP Stack instead of XAMPP it comes preloaded php_mongo.dll driver installed and no need to configure php.ini file
There is no official MongoDB Driver released for PHP7. So it would be better to download the recommended PHP version 5.5.30(currently) offered by Bitnami Wamp Stack.
There might be two reasons:
First one is as #Sadd suggested. Your mongodb extension should be loaded after what you have done so its very likely that you have enabled extension in wrong file. And yes, there are two such similar files (named php.ini-development and php.ini-production on windows computers), so make sure to enable it in php.ini file and run the following code echo extension_loaded("mongodb") ? "loaded\n" : "not loaded\n"; and you should see loaded on screen.
If you still don't see it, then the second thing you can do is to check whether the version is right or not. You can check your phpinfo() for your php version and then put the right versioned dll file in ext folder. In this, you can have to check whether your php is ts or nts and second one is whether your php is x64 or x86. I hope you are good to go after one or both of the changes.
This was driving my crazy until I looked closely at my PHP version:
$ php -v
PHP 7.4.1 (cli) (built: Dec 17 2019 19:23:59) ( NTS Visual C++ 2017 x64 )
Notice that it says PHP 7.4.1 and NTS and x64? This means that when I download from PECL, I need version 7.4 Non Thread Safe (NTS) x64 or it won't run correctly.
If the correct version of module is not added, an error is thrown.
[PHP Warning: PHP Startup: Unable to load dynamic library 'php_mongodb.dll' (tried: C:\xampp\php\ext\php_mongodb.dll (The specified module could not be found), C:\xampp\php\ext\php_php_mongodb.dll.dll (The specified module could not be found)) in Unknown on line 0]
When downloading the dll extension from https://pecl.php.net/package/mongodb, make sure that NTS (Non Thread Safe) or TS (Thread Safe) is chosen according to what shown from php -v command.
$ php -v
PHP 8.1.7 (cli) (built: Jun 7 2022 21:45:53) (ZTS Visual C++ 2019 x64)
Although here it shows ZTS, TS version can be used in this case.