CentOS 5.6 has never been released, and PHP5.1.6 of CentOS 5.5 does not support json/hash. Because we are studying the Postfix + Dovecot email system, the new version of RoundCube used by webmail (v0.5) requires that the PHP version be no less than 5.2.1, so I decided to compile and install the latest PHP version. PHP was intruded a few days ago. It is said that the v5.3.6 code was contaminated, but it should be okay to use it for research and testing.
First, uninstall the PHP packages installed on the local machine. These packages will be installed in the next compilation method. Install the required software.
# Yum remove php-common php-devel php-cli php-mbstring php-mhash
Php-mysql php-pgsql php-ldap php-imap php-pear php-pdo php-gd
If you do not need a postgresql database, you can remove the postgresql package.
# Yum install httpd-devel libtool-ltdl-devel openssl-devel
Libjpeg-devel libpng-devel freetype-devel
Libc-client-devel gd-devel libmcrypt-devel
Sqlite-devel mysql-devel libicu-devel pcre-devel
Postgresql84 postgresql84-libs postgresql84-server postgresql84-devel
If libtool-ltdl-devel is not installed, an error occurs during compilation. Therefore, either install this package or run the following command:
# Cd/usr/lib
# Ln-s libltdl. so.3.1.4 libltdl. so
Libicu is the package required by -- enable-intl Enable internationalization support. Download the source code to the src directory and unzip it:
# Cd/usr/local/src
# Wget http://cn.php.net/get/php-5.3.6.tar.bz2/from/this/mirror
# Tar-xjf php-5.3.6.tar.bz2
Configure installation parameters
./Configure -- build = i686-RedHat-linux-gnu -- host = i686-redhat-linux-gnu
-- Target = i686-RedHat-linux-gnu -- with-apxs2 =/usr/sbin/apxs
-- Prefix =/usr/local -- exec-prefix =/usr/local -- with-exec-dir =/usr/local/bin
-- Sysconfdir =/etc -- libdir =/usr/local/lib/php -- with-libdir = lib
-- Sbindir =/usr/local/sbin -- sharedstatedir =/usr/com -- datadir =/usr/local/share
-- Includedir =/usr/local/include -- libexecdir =/usr/local/libexec
-- Localstatedir =/var -- cache-file = ../config. cache
-- Mandir =/usr/local/share/man -- infodir =/usr/local/share/info
-- With-config-file-path =/etc -- with-config-file-scan-dir =/etc/php. d
-- With-pic -- with-curl = shared -- with-freetype-dir -- with-png-dir
-- With-gettext -- with-gmp -- with-iconv -- with-jpeg-dir -- with-png-dir
-- With-openssl -- with-layout = GNU -- with-libxml-dir
-- With-pcre-regex =/usr
-- With-mcrypt = shared -- with-mhash -- with-zlib -- with-bz2 = shared
-- With-pdo-mysql -- with-mysql-sock =/var/lib/mysql. sock
-- With-pgsql -- with-pdo-pgsql -- with-sqlite = shared -- with-pdo-sqlite = shared
-- Enable-sqlite-utf8 -- with-kerberos -- with-imap-ssl
-- With-pear -- with-gd -- enable-gd-native-ttf -- enable-calendar = shared
-- Enable-exif -- enable-ftp -- enable-sockets -- enable-bcmath
-- Enable-sysvsem -- enable-sysvshm -- enable-sysvmsg -- enable-intl
-- Enable-mbstring -- enable-zend-multibyte -- enable-zip
-- Without-unixODBC -- disable-tokenizer
Non-RHEL/CentOS systems can omit the -- build, -- host, -- target parameter, the program will automatically judge (LINUX is generally a i686-pc-linux-gnu ). If pgsql is not installed or pgsql is not required, you can delete related parameters (2 in total ). Bz2, calendar, curl, mcrypt, pdo_sqlite, and sqlite modules adopt dynamic compilation and can be loaded using the methods mentioned below. Compile and install
# Make & make install
Installation result summary, which contains several major installation path variables
Libtool: install: warning: remember to run 'libtool -- finish/usr/local/src/php-5.3.6/libs
[Activating module 'php5 in/etc/httpd/conf/httpd. conf]
Installing php cli binary:/usr/local/bin/
Installing php cli man page:/usr/local/share/man/man1/
Installing shared extensions:/usr/local/lib/php/20090626/
Installing build environment:/usr/local/lib/php/build/
Installing header files:/usr/local/include/php/
Installing helper programs:/usr/local/bin/
Program: phpize
Program: php-config
Installing man pages:/usr/local/share/man/man1/
Installing PEAR environment:/usr/local/share/pear/
It seems that you want to run libtool -- finish... once, but it does not have any special effect after I run it ~
Update the httpd configuration file so that apache can parse the PHP File
# Vim/etc/httpd/conf/httpd. conf
Add the following content
AddType application/x-httpd-php. php
AddType application/x-httpd-php-source. phps
If you have not backed up the PHP. ini file before uninstalling the original php file, you can copy the PHP. ini-production file from the php compilation directory to the/etc directory and change it to php. ini.
# Mv/usr/local/src/php-5.3.6/php. ini-production/etc/php. ini
Add or update related settings, such:
Extension_dir = "/usr/local/lib/php/20090626"
# Add the following six modules as needed
Extension = bz2.so
Extension = calendar. so
Extension = curl. so
Extension = mcrypt. so
Extension = pdo_sqlite.so
Extension = sqlite. so
Max_execution_time = 30
Max_input_time = 60
Memory_limit = 128 M
Variables_order = "EGPCS"
Register_globals = Off
Register_long_arrays = Off
Post_max_size = 30 M
Upload_max_filesize = 30 M
Mbstring. internal_encoding = UTF-8
Date. timezone = Asia/Chongqing
Test results. Create a phpinfo. php file under/var/www/html, which contains the content
Php code
<? Php
Phpinfo ();
?>
Restart the apache service
# Service httpd restart
Open the http: // 192.168.0.1/phpinfo. php file in the browser to check the php configuration. The IP address here is the server address.