CentOS under PHP 5.6 compilation installation

Source: Internet
Author: User

Recently in the attempt to Yii 2.0, I used the system is CentOS, by Yum installed PHP is 5.2, and yii2.0 need at least 5.4

On the Internet to find a number of installation methods have failed, including modifying the source of Yum to update the way is not successful, so only through the most primitive way to download the source code to compile the installation.

Steps are as follows

1. If you want Apache to support PHP, you first need to install Apache Yum Install httpd need to install later Yum Install Httpd-devel This system can be installed APXS, after PHP to use the Find /-name "APXS" Look for the location of APXS.
2. Install PHP
# C and C + + compilers Yum install-y gcc gcc-c++ # PHP Extension dependent Yum install-y libxml2-devel openssl-devel libcurl-devel libjpeg-devel libpng-devel libicu-devel openldap-devel

go to the PHP website http://php.net/downloads.php See the tar.gz link you want to download

then use wget to download the latest source code, unzip, run Configure-make-make install


Configure Directive ./configure--prefix=/data/soft/php\ --with-libdir=lib64\ --enable-fpm\ --with-fpm-user=php-fpm\ --with-fpm-group=www\ --enable-mysqlnd\ --with-mysql=mysqlnd\ --with-mysqli=mysqlnd\ --with-pdo-mysql=mysqlnd\ --enable-opcache\ --enable-pcntl\ --enable-mbstring\ --enable-soap\ --enable-zip\ --enable-calendar\ --enable-bcmath\ --enable-exif\ --enable-ftp\ --enable-intl\ --with-openssl\ --with-zlib\ --with-curl\ --with-gd\ --with-zlib-dir=/usr/lib\ --with-png-dir=/usr/lib\ --with-jpeg-dir=/usr/lib\ --with-gettext\ --with-mhash\ --with-ldap\ --with-apxs2=/usr/local/apache/bin/apxs

Note that the last line points to the APXS location, and if you do not know the Find/-name "Apxs", then PHP will generate libphp5.so for Apache to call after compiling .

The first line is the installation location, I installed in the /data/soft/php directory, you can change


then Make&make instgall .


after compiling the installation, you will need to copy the php-fpm.conf.default Configuration sample file and rename it as a configuration file after installing the ETC directory.

cp/data/soft/php/etc/php-fpm.conf.default/data/soft/php/etc/php-fpm.conf

Modify this file to find User=xxx and group=xxx modified to User=root group=root so that you can run with root (use WhoAmI and groups to see User and group for current users)

then copy the source directory under Php.ini-production to the PHP installation directory under the Lib, renamed to php.ini PHP configuration file (php.ini default path can be written by a index.php file, with Phpinfo () To view)



Locate php-fpm Run Php-fpm-r so that you can start with the root user
PHP-FPM when closed, first use PS Aux|grep php-fpm to find PID then kill-int the PHP-FPM pid to close

then modify the Apache http.conf configuration file Join LoadModule php5_module modules/libphp5.so be careful to check if the configuration file already has the line, if repeated will be an error. Join addtype application/x-httpd-php. PHP such php extension files can be executed by Apache
Restart httpd Service write a index.php with phpinfo () to see the effect, if all is normal can see PHP information

CentOS under PHP 5.6 compilation installation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.