CentOS compilation and installation Apache2.4 + PHP5.6 classification: Linux Time: December 26, 2015
In CentOS, installing PHP and Apache in YUM is relatively simple. However, by default, the PHP version is 5.3 and Apache version is 2.2. Considering that the higher the performance of PHP and Apache versions, the better, we plan to compile and install Apache2.4 + PHP5.6 in CentOS. Now PHP programmer Lei Xuesong summarizes a complete CentOS compilation and installation steps Apache2.4 + PHP5.6.
1. download the source code package Apache2.4 + PHP5.6
Download httpd-2.4.17.tar.gzand other filefrom http://httpd.apache.org/download.cgi?apache24to download httpd-2.4.17-deps.tar.gz
Download the php-5.6.16.tar.gzsource code package from http://php.net/downloads.php
Download pcre-8.32.tar.gz from http://sourceforge.net/projects/pcre/files/pcre/8.32/
2. install the gcc and make compilation tools first.
[Raykaeso @ LAMP php-5.6.16] # yum-y install gcc make gcc-c ++ without this gcc-c ++ will not compile prce for a while
Switch to the downloaded source code package directory. take the system root directory/LAMP as an example.
3. decompress the Apache2.4 dependency package, install apr, apr-util, and pcre, compile and install Apache2.4
[Raykaeso @ LAMP download] # tar-zxvf httpd-2.4.17-deps.tar.gz install apr [Raykaeso @ LAMP download] # cd apr [Raykaeso @ LAMP apr] #. /configure -- prefix =/usr/local/apr [Raykaeso @ LAMP apr] # make & make install apr-util [Raykaeso @ LAMP apr-util] # cd .. /apr-util [Raykaeso @ LAMP apr-util] #. /configure -- prefix =/usr/local/apr-util -- with-apr =/usr/local/apr [Raykaeso @ LAMP apr-util] # make & make install pcre [Raykaeso @ LAMP apr-util] # cd/LAMP [Raykaeso @ LAMP] # tar-zvxf pcre-8.32.tar.gz [Raykaeso @ LAMP] # cd pcre-8.32 [Raykaeso @ LAMP pcre-8.32] #. /configure [Raykaeso @ LAMP pcre-8.32] # make & make install to install Apache2.4 must first install apr, apr-util and pcre [Raykaeso @ LAMP pcre-8.32] # cd/LAMP [Raykaeso @ LAMP] # tar-zvxf httpd-2.4.17.tar.gz [Raykaeso @ LAMP] # cd httpd-2.4.17 [Raykaeso @ LAMP httpd-2.4.17] #. /configure -- prefix =/usr/local/apache -- with-apr-util =/usr/local/apr-util [Raykaeso @ LAMP httpd-2.4.17] # make & make install
4. Compile and install PHP5.6
[Raykaeso @ LAMP httpd-2.4.17] # cd/LAMP [Raykaeso @ LAMP] # yum-y install libxml2-devel # Don't install this compilation can't PHP5.5 [Raykaeso @ LAMP] # yum-y install libjpeg libjpeg-devel libpng-devel freetype-devel png jpeg gd # enable the dependencies required by the GD Library [Raykaeso @ LAMP] # yum-y install curl-devel # enable the CURL Library dependencies required [Raykaeso @ LAMP] # tar-zvxf php-5.6.16.tar.gz [Raykaeso @ LAMP] # cd php-5.6.16 [Raykaeso @ LAMP php-5.6.16] #. /configure -- prefix =/usr/local/php -- with-config-file-path =/usr/local/php/etc -- enable-fpm -- enable-sysvsem -- enable-sockets -- enable-pcntl -- enable-mbstring -- enable-mysqlnd -- enable-pdo -- with-pdo-mysql -- enable-opcache -- enable-shmop -- enable-zip -- enable-ftp -- enable -gd-native-ttf -- enable-wddx -- enable-soap -- with-png-dir -- with-freetype-dir -- with-jpeg-dir -- with-gd -- with-mysqli [Raykaeso @ LAMP php-5.6.16] # make & make install copy a formal php-fpm.conf and php. ini configuration file [Raykaeso @ LAMP php-5.6.16] # cp/usr/local/php/etc/php-fpm.conf.default/usr/local/php/etc/php-fpm.conf [Raykaeso @ LAMP php-5.6.16] # cp. /php. ini-production/usr/local/php/etc/php. ini
Start and close PHP
[Raykaeso@LAMP php-5.6.16]# /usr/local/php/sbin/php-fpm [Raykaeso@LAMP php-5.6.16]# killall php-fpm
5. edit the httpd. conf file for apache configuration:
[Raykaeso @ LAMP: php-5.6.16] # vi/usr/local/apache/conf/httpd. conf removes the # sign before the three lines. LoadModule proxy_module modules/mod_proxy.so LoadModule proxy_fcgi_module modules/modules LoadModule rewrite_module modules/mod_rewrite.so # enable rewrite and add two lines at the bottom: # proxy php ServerName 127.0.0.1 ProxyPassMatch ^ /(. *\. php (/. *)?) $ Fcgi: // 127.0.0.1: 9000/usr/local/apache/htdocs/$1 save and exit: wq
Restart Apache
[Raykaeso@LAMP php-5.6.16]# /usr/local/apache/bin/apachectl restart
Here, CentOS compilation and installation of Apache2.4 + PHP5.6 are complete, and the actual installation process may still get stuck. the general error is that the PHP dependency package is not installed. After the installation and configuration of Apache2.4 + PHP5.6 are successful, you can write a phpinfo file to check whether common extensions are installed. It is worth noting that the launch should be consistent with the developed PHP version, otherwise it will be a headache to use some obsolete PHP functions.