Php – How to change php version used by apache on debian

apache-2.2debiandebian-wheezyPHPphp5

My server is running debian 7 and I have php 5.4.45 installed via apt-get. I need php 5.6 for some other service to run properly, but unfortunately I couldn't find any way to install it via apt-get. I've downloaded, compiled and installed php 5.6 and php -v shows:

PHP 5.6.29 (cli)

Unfortunately, since the version installed via apt-get is still accessible via php5 command, apache uses the old 5.4.45. I cannot get rid of this, because there are other things depending on it that I don't want to lose.
I've read other answers, but I didn't find httpd config files anywhere on my device.
Another thing, how can I "tell" apt-get or any other package manager, that I've installed newer version of php manually, so that it doesn't require me to download older version, just to satisfy the dependence. Is it that the name is incorrect, do I need to link it somewhere? If there is some article, that explains it, please link it.

Best Answer

If you installed another version of PHP and assuming you parse php with mod_php, you just have to load the module from the new installation.

Also, Apache distribution always comes with a file called "envvars", this loads the environment variables you want/need for apache to run with. This file is ran when Apache HTTPD is started.

In this file you can specify, PATH, LD_LIBRARY_PATH, etc. Do you follow? Just specify the paths for the new PHP installation there, and in the Apache configuration use the LoadModule direcitive to load the appropiate file.