Directory
- 1 Installing PHP-dependent extensions
- 2 Download Unzip PHP
- 3 Compiling PHP
- 4 Let Apache support PHP
- 5 test Installation
To install PHP-dependent extensions:
1 Yum Install -y libxml2-devel openssl-devel libcurl-devel libjpeg-devel libpng-devel libicu-devel openldap-devel
Download Unzip PHP:
Http://php.net/downloads.php can be downloaded to the latest version of PHP, here is the download of php-5.6.8.tar.gz.
1 wget http://cn2.php.net/distributions/php-5.6.8.tar.gz2tar -xzvf php-5.6. 8. Tar . GZ 3 CD php-5.6. 8
Compiling PHP:
file -path=/usr/local/php/etc--enable-fpm--with-fpm-user=php-fpm--with-fpm-group=php-fpm--with-mysql= Mysqlnd--with-mysql-sock=/tmp/mysql.sock--with-libxml-dir --WITH-GD-- With-jpeg-dir --with-png-dir -- With-freetype-dir --with-iconv-dir -- With-zlib-dir --with-mcrypt--enable-soap--enable-gd-native-ttf--enable-< Span style= "color: #0000ff;" >ftp --enable-mbstring--enable-exif--disable-ipv6--with-pear--with-curl--with-openssl--with-apxs2=/usr/ Local/apache/bin/apxs
Note:--with-apxs2=/usr/local/apache/bin/apxs need to add, otherwise apache/modules inside there is no libphp5.so, Httpd.conf also does not add LoadModule php5_module modules/libphp5.so this line.
Let Apache support PHP:
Open the/usr/local/apache/conf/httpd.conf file and enter the following code on the last side:
1 addtype application/x-httpd-php . php2 addtype application/x-httpd-php-source . Phps
Navigate to DirectoryIndex index.html, modified to:
1 directoryindex index.php index.html
It is important to note whether the PHP extension is already open in/usr/local/apache/conf/httpd.conf:
1 LoadModule php5_module modules/libphp5.so
Test installation:
1 /usr/local/apache/htdocs/index.php
Enter the following code:
<? PHP Echo Phpinfo ();
If you can display Phpinfo, you are successful.
Build and install PHP5.6 under CentOS