Slime: php5.6 source installation and Apache integration

Source: Internet
Author: User
Tags sapi

this article starting at Slime Line the world .

Apache support for PHP is supported by Apache's MOD_PHP5 module, which is different from Nginx. Nginx is through the third-party fastcgi processor to be able to parse PHP, about nginx and PHP integration, see " Slime: php5.6 source installation and PHP-FPM configuration and Nginx integration ."

If the source code compiled to install PHP, you need to specify at compile time--with-apxs2=/usr/local/apache2/bin/apxs to tell the compiler through the Apache MOD_PHP5 module to provide the parsing of PHP.

While the last step of the PHP installation is make install, We will see that the dynamic link library libphp5.so is copied to the modules directory of the APACHE2 installation directory, and you also need to add loadmodule statements in the httpd.conf configuration file to dynamically load the Libphp5.so module in order to enable Apache support for PHP.

PHP integration with Apache requires the following steps:

1. Install Libiconv Library

2. PHP Source Installation

3. Configure Apache to support PHP

4. Test PHP

First, install the Libiconv library

The Libiconv library provides a ICONV command for applications that need to be converted to convert one character encoding to another, such as it can convert UTF8 encoding to GB18030 encoding, and vice versa.

When PHP integrates with Apache, be sure to install the Libiconv library, or the system will error when make. The error message is as follows:

Make: * * * [sapi/cli/php] Error 1

/usr/bin/ld:cannot Find-liconv

Collect2:ld returned 1 exit status

Make: * * * [sapi/cli/php] Error 1

650) this.width=650; "title=" clip_image001 "style=" border-right-width:0px;background-image:none; border-bottom-width:0px;padding-top:0px;padding-left:0px;margin:0px;padding-right:0px;border-top-width:0px; " Border= "0" alt= "clip_image001" src= "Http://s3.51cto.com/wyfs02/M01/55/44/wKiom1SJTZyieiycAAF0au4Ev60792.jpg" Width= "358" height= "/>"

Now start the formal installation of the Libiconv library, first download the Libiconv library, as follows:

wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz

650) this.width=650; "title=" clip_image002 "style=" border-right-width:0px;background-image:none; border-bottom-width:0px;padding-top:0px;padding-left:0px;margin:0px;padding-right:0px;border-top-width:0px; " Border= "0" alt= "clip_image002" src= "Http://s3.51cto.com/wyfs02/M02/55/44/wKiom1SJTZygOKO9AAF3khg_Drc106.jpg" Width= "589" height= "/>"

Unzip the Libiconv library as follows:

TAR-XF libiconv-1.14.tar.gz

650) this.width=650; "title=" clip_image003 "style=" border-right-width:0px;background-image:none; border-bottom-width:0px;padding-top:0px;padding-left:0px;margin:0px;padding-right:0px;border-top-width:0px; " Border= "0" alt= "clip_image003" src= "Http://s3.51cto.com/wyfs02/M01/55/44/wKiom1SJTZ2SOBrlAARmWVvCfsQ171.jpg" Width= "519" height= "442"/>

To install the Libiconv library, first review the installation Help information. As follows:

./configure--help

650) this.width=650; "title=" clip_image004 "style=" border-right-width:0px;background-image:none; border-bottom-width:0px;padding-top:0px;padding-left:0px;margin:0px;padding-right:0px;border-top-width:0px; " Border= "0" alt= "clip_image004" src= "Http://s3.51cto.com/wyfs02/M01/55/42/wKioL1SJTjXC0pyQAAQKzviOW9A571.jpg" Width= "556" height= "479"/>

With help, we can see that the default installation path for the Libiconv library is/usr/local. Now start installing the Libiconv library as follows:

./configure--prefix=/usr/local

Make && make install

650) this.width=650; "title=" clip_image005 "style=" border-right-width:0px;background-image:none; border-bottom-width:0px;padding-top:0px;padding-left:0px;margin:0px;padding-right:0px;border-top-width:0px; " Border= "0" alt= "clip_image005" src= "Http://s3.51cto.com/wyfs02/M02/55/42/wKioL1SJTjbgGddiAAJxNsmyd5Q152.jpg" Width= "443" height= "314"/>

650) this.width=650; "title=" clip_image006 "style=" border-right-width:0px;background-image:none; border-bottom-width:0px;padding-top:0px;padding-left:0px;margin:0px;padding-right:0px;border-top-width:0px; " Border= "0" alt= "clip_image006" src= "Http://s3.51cto.com/wyfs02/M02/55/42/wKioL1SJTjbB_0FnAAJ4_OzU20M059.jpg" Width= "459" height= "280"/>

After the Libiconv library is installed, it is recommended that you add the/usr/local/lib library to the/etc/ld.so.conf file and use/sbin/ldconfig to make it effective. As follows:

echo "/usr/local/lib" >>/etc/ld.so.conf

/sbin/ldconfig

650) this.width=650; "title=" clip_image007 "style=" border-right-width:0px;background-image:none; border-bottom-width:0px;padding-top:0px;padding-left:0px;margin:0px;padding-right:0px;border-top-width:0px; " Border= "0" alt= "clip_image007" src= "Http://s3.51cto.com/wyfs02/M00/55/44/wKiom1SJTZ7jlE1CAAD3noTg7p0241.jpg" Width= "508" height= "144"/>

If you do not do this, the system will error if you install PHP to execute make install. The error message is as follows:

/root/php-5.6.2/sapi/cli/php:error while loading shared libraries:libiconv.so.2:cannot open shared object File:no such File or directory

Second, PHP source installation

for PHP source installation can refer to the Slime: php5.6 source installation and PHP-FPM configuration and Nginx integration "article, download and compile the PHP command as follows:

wget http://mirrors.sohu.com/php/php-5.6.2.tar.gz

./configure--enable-fpm--enable-mbstring--with-mysql=/usr/local/mysql--with-iconv-dir=/usr/local--with-apxs2=/ Usr/local/apache2/bin/apxs

650) this.width=650; "title=" clip_image008 "style=" border-right-width:0px;background-image:none; border-bottom-width:0px;padding-top:0px;padding-left:0px;margin:0px;padding-right:0px;border-top-width:0px; " Border= "0" alt= "clip_image008" src= "Http://s3.51cto.com/wyfs02/M00/55/42/wKioL1SJTjfAIaoIAAGYyuidzTw186.jpg" Width= "528" height= "171"/>

650) this.width=650; "title=" clip_image009 "style=" border-right-width:0px;background-image:none; border-bottom-width:0px;padding-top:0px;padding-left:0px;margin:0px;padding-right:0px;border-top-width:0px; " Border= "0" alt= "clip_image009" src= "Http://s3.51cto.com/wyfs02/M01/55/44/wKiom1SJTZ_AQOdVAAJ1v1wRFEQ552.jpg" Width= "780" height= "247"/>

Note that the function of--ENABLE-FPM in the above command is to turn on the fastcgi function of PHP, that is to turn on php-fpm function.

--with-mysql=/usr/local/mysql is the ability to enable PHP to support MySQL,/usr/local/mysql is the path to the MySQL database installation.

--enable-mbstring means that the primary function of enabling the Mbstring Module Mbstring module is to detect and convert the encoding, providing a string function for the corresponding multibyte operation. At present PHP internal code only supports iso-8859-*, EUC-JP, UTF-8, the other encoding language is not able to display correctly in the PHP program, so we want to enable the Mbstring module.

--with-iconv-dir=/usr/local Specifies where PHP stores the Libiconv library.

--WITH-APXS2=/USR/LOCAL/APACHE2/BIN/APXS Specifies the location of PHP to find Apache.

Once the compilation is complete, let's make again. In make, we note that the-liconv parameter is added. If you do not add the-liconv parameter, the system will error in make compilation. The error message is as follows:

Generating phar.php

Php-5.3.16/sapi/cli/php:error while loading shared libraries:libiconv.so.2:cannot open Shared object file:no such file or directory

Use the following command:

Make zend_extra_libs= '-liconv '

We can also add-liconv to the Zend_extra_libs line by modifying the makefile file. As follows:

650) this.width=650; "title=" clip_image010 "style=" border-right-width:0px;background-image:none; border-bottom-width:0px;padding-top:0px;padding-left:0px;margin:0px;padding-right:0px;border-top-width:0px; " Border= "0" alt= "clip_image010" src= "Http://s3.51cto.com/wyfs02/M02/55/44/wKiom1SJTaCCT1jqAAVD5e4tTeY490.jpg" Width= "444" height= "588"/>

VI Makefile

650) this.width=650; "title=" clip_image011 "style=" border-right-width:0px;background-image:none; border-bottom-width:0px;padding-top:0px;padding-left:0px;margin:0px;padding-right:0px;border-top-width:0px; " Border= "0" alt= "clip_image011" src= "Http://s3.51cto.com/wyfs02/M00/55/42/wKioL1SJTjjAKeQ-AACs0PXioZY185.jpg" Width= "510" height= "/>"

Make install

650) this.width=650; "title=" clip_image012 "style=" border-right-width:0px;background-image:none; border-bottom-width:0px;padding-top:0px;padding-left:0px;margin:0px;padding-right:0px;border-top-width:0px; " Border= "0" alt= "clip_image012" src= "Http://s3.51cto.com/wyfs02/M01/55/42/wKioL1SJTjiTEHpzAASn9fzaI5I563.jpg" Width= "814" height= "404"/>

Through, we can obviously see the Apache configuration file httpd enabled PHP support, but also the libphp5.so files copied to the Apache module directory.

Third, configure Apache to support PHP

Once the PHP installation is complete, we can modify the Apache configuration file httpd.conf to support PHP.

We only need to add the following two lines of code to the httpd.conf file:

LoadModule Php5_module modules/libphp5.so

AddType application/x-httpd-php. php

Note that, where LoadModule php5_module modules/libphp5.so line, we see that the row already exists when we view the httpd.conf file. That's because when you install PHP, you add the. Now we just need to add AddType application/x-httpd-php. PHP line.

Vi/usr/local/apache2/conf/httpd.conf

650) this.width=650; "title=" clip_image013 "style=" border-right-width:0px;background-image:none; border-bottom-width:0px;padding-top:0px;padding-left:0px;margin:0px;padding-right:0px;border-top-width:0px; " Border= "0" alt= "clip_image013" src= "Http://s3.51cto.com/wyfs02/M01/55/44/wKiom1SJTaHTzf26AAGNSTSR4mU230.jpg" Width= "567" height= "/>"

In addition, we also need to modify Apache's default home page file and add index.php. The contents are as follows:

echo "<?php phpinfo ();? > ">/usr/local/apache2/htdocs/index.php

cat/usr/local/apache2/htdocs/index.php

650) this.width=650; "title=" clip_image014 "style=" border-right-width:0px;background-image:none; border-bottom-width:0px;padding-top:0px;padding-left:0px;margin:0px;padding-right:0px;border-top-width:0px; " Border= "0" alt= "clip_image014" src= "Http://s3.51cto.com/wyfs02/M02/55/44/wKiom1SJTaHTLwT6AADY5NUkWxg512.jpg" Width= "496" height= "155"/>

650) this.width=650; "title=" clip_image015 "style=" border-right-width:0px;background-image:none; border-bottom-width:0px;padding-top:0px;padding-left:0px;margin:0px;padding-right:0px;border-top-width:0px; " Border= "0" alt= "clip_image015" src= "Http://s3.51cto.com/wyfs02/M02/55/42/wKioL1SJTjnxMk2RAAESbxT-p8Q490.jpg" Width= "621" height= "/>"

Four, Test PHP

Once the above modifications are complete, we restart Apache using the following command:

/ETC/INIT.D/HTTPD Graceful

Note that this command can gracefully restart Apache.

650) this.width=650; "title=" clip_image016 "style=" border-right-width:0px;background-image:none; border-bottom-width:0px;padding-top:0px;padding-left:0px;margin:0px;padding-right:0px;border-top-width:0px; " Border= "0" alt= "clip_image016" src= "Http://s3.51cto.com/wyfs02/M00/55/44/wKiom1SJTaLTYvSdAAGOaDxFcVg348.jpg" Width= "799" height= "141"/>

Open the site as follows:

650) this.width=650; "title=" clip_image017 "style=" border-right-width:0px;background-image:none; border-bottom-width:0px;padding-top:0px;padding-left:0px;padding-right:0px;border-top-width:0px; "border=" 0 "alt = "clip_image017" src= "http://s3.51cto.com/wyfs02/M02/55/44/wKiom1SJTaOCswXwAAOM4vjmIb0789.jpg" width= "961" height = "431"/>

Through, we can obviously see that Apache has supported PHP.

This article is from the "Slime Row World" blog, please be sure to keep this source http://ilanni.blog.51cto.com/526870/1588796

Slime: php5.6 source installation and Apache integration

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.