Depending on your server, you should be looking at Apache, not PHP.
(For RHEL/CentOS) look at /etc/httpd/conf.d/php.ini
#
# PHP is an HTML-embedded scripting language which attempts to make it
# easy for developers to write dynamically generated web pages.
#
LoadModule php5_module modules/libphp5.so
#
# Causes the PHP interpreter to handle files with a .php extension.
#
AddHandler php5-script .php
AddType text/html .php
You'll see that your PHP module is modules/libphp5.so
.
AddHandler php5-script .php
tells Apache to run PHP on any file with the extension .php
.
If you are using an RPM based OS it's probably easier to uninstall (assuming you can do that) the current version of PHP, and reinstall the version you are looking for.
rpm -qa | grep php
will show you what version of PHP is currently installed.
Download src.rpm for the package, it contains ORIGINAL source code and all the files required for compiling custom rpm's:
- php.spec - spec file needed for rpmbuild
- php-xxx.tar.gz - original source code
- various patches (.diff, .patch)
- documentation files to be added (if exist)
To build rpm - you will need rpm-build package which contains rpmbuild program.
It also can be done with yumdownloader (from yum-utils package):
yum install yum-utils rpm-build
yumdownloader --source php
Install src.rpm:
rpm -Uvh *.src.rpm
cd to rpmbuild SPEC dir;
RHEL5, old Fedora
cd /usr/src/redhat/SPEC/
Suse:
cd /usr/src/packages/SPEC/
RHEL6, newer Fedora:
cd ~/rpmbuild/SPEC/
php.spec file contains details about how package is built and which components will be included. It also contains data regarding dependencies and required packages to have in order to build new packages correctly. So, rpmbuild will remind you about any missing packages.
You will need to:
- Download updated php source code from php.net and put it into SOURCES dir
- Specify new version in "Version:" string in the php.spec file, also use lower value in "Release:" string and add your custom name in it, like "Release: 0.mike"
- Check .spec file for possible additional changes (maybe there are some security patches not needed in current version, rpmbuild will tell you about that if file is already patched). Maybe you will need to comment some "Patch xx:" string and some "%patch xx" if you will have any problems.
run rpmbuild:
rpmbuild --target x86_64 -ba php.spec
--target x86_64 - specifies platform (can be i386, x86_64, amd64, etc)
-ba - "build all", will build both final .rpm and new src.rpm packages
You can find built packages in ../RPM/ and ../SRPM/ directories.
This method ensures, that vendor patches are included, directory. file structure hierarchy is the same, component is compatible, dependencies are met and old version will be safely replaced. Also, you guarantee your future updates.
p.s. I disagree with "new version in production is bad" string. I am providing support services to dozen of companies, also have shared hosting and I always prefer to have fresh version. Only problem with php is moving from one subversion to another (like 5.1.x to 5.2.x, 5.2.x to 5.3.x) - there are some general changes and deprecated/removed functions. But newer is faster, secure and better maintained, followed.
p.s.s. I'll never compile anything manually and put files in /usr/local/ in my life, I've learned rpm as I needed it in few days, now everything is running smooth.
Best Answer
You also need to upgrade the Apache httpd module for PHP. Usually there are three packages for PHP: one for CLI, one for FastCGI and CGI, and one for mod_php.