fengd fengd - 1 year ago 101
PHP Question

phpinfo and php -v show different version on lion

I try to upgrade my php from 5.3.13 to 5.4.5
I've manually download source codes of php 5.4.5 and ./configure then sudo make install it.

after that, I run

php -v

it shows 5.4.5, while I run

<?php phpinfo(); ?>

it shows 5.3.13. what is the problem here and how to fix it. thanks

Answer Source

This is a bit of a guess answer since I don't have a mac, but based on my Winodws experience this could only happen if you have 2 php executables and your CLI is using one and Apache is using the other.

In your phpinfo() output look for the table row Loaded Configuration File.

I'm on Windows so mine says C:\server\php\5.4.3\php.ini but of course yours will be different.

If this is not the path that you expect it to be using then you will need to make sure you change the path in your Apache's httpd.conf file.

Once you have found the httpd.conf file find the line: PHPIniDir

When you have found this line make sure it is pointing at the correct directory for the php.ini file and restart Apache.

I would also say to check the LoadModule php5_module line is also pointing at the correct file but the chances are that this will be ok if you were using php 5.3 before.

This answer does assume that you have installed the new php version in a different directory but this is all I can think of with the information you have provided.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download