CENTOS compilation and installation of APACHE2.4 + PHP5.6 tutorial

Source: Internet
Author: User

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.


Yum-y install gcc make gcc-c ++ does not have this gcc-c ++ compilation will not prce
Switch to the downloaded source code package directory. Take the system root directory/LAMP as an example.


3. DecompressApache2.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


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


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, you 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-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 dependencies required by the CURL Library
[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
Remove the # sign before the three rows
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
LoadModule rewrite_module modules/mod_rewrite.so # enable rewrite
Add two rows 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.

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.