Rotten mud: php5.6 source code installation and apache integration, php5.6apache _ PHP Tutorial

Source: Internet
Author: User
Tags sapi
Rotten mud: php5.6 source code is installed and integrated with apache, php5.6apache. Rotten mud: php5.6 source code is installed and integrated with apache. php5.6apache this article is sponsored by Xiuyi Linfeng, and first launched in the world. Apache supports php through the mod_php5 module of apache: php5.6 source code installation and apache integration, php5.6apache

This article was sponsored by Xiuyi Linfeng and first launched in the dark world.

Apache supports php through the mod_php5 module of apache, which is different from nginx. Nginx can parse php only through a third-party fastcgi processor. for nginx and php integration, see mud: php5.6 source code installation and php-fpm configuration and nginx integration.

If you install php through source code compilation, you need to specify -- with-apxs2 =/usr/local/apache2/bin/apxs at compilation to tell the compiler to provide php parsing through the mod_php5 module of apache.

At the same time, when you make install the last step of php installation, we will see that the dynamic link library libphp5.so is copied to the modules Directory of the installation directory of apache2, and also needs to be in httpd. add the LoadModule statement to the conf configuration file to dynamically load the libphp5.so module to implement Apache's support for php.

The following steps are required to integrate php with apache:

1. install the libiconv Library

2. install php source code

3. configure apache to support php

4. test php

1. install the libiconv Library

The libiconv Library provides an iconv command for the application that requires conversion to encode one character to another. for example, it can convert UTF8 to GB18030 encoding, the opposite is true.

When integrating php with apache, you must install the libiconv Library. Otherwise, the system reports an error during 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

Now, the libiconv Library is officially installed. first, download the libiconv library as follows:

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

Decompress the libiconv library as follows:

Tar-xf libiconv-1.14.tar.gz

To install the libiconv Library, first view the installation help information. As follows:

./Configure -- help

With help, we can see that the default installation path of the libiconv Library is/usr/local. Install the libiconv library as follows:

./Configure -- prefix =/usr/local

Make & make install

After the libiconv Library is installed, we recommend that you add the/usr/local/lib library to the/etc/ld. so. conf file, and then use/sbin/ldconfig to make it take effect. As follows:

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

/Sbin/ldconfig

If you do not perform this step, run make install on php, and the system reports an error. 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

II. install php source code

For php source code installation, refer to the article "mud: php5.6 source code installation and php-fpm configuration and nginx integration". 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

Note that in the preceding command -- enable-fpm is used to enable the fastcgi function of php, that is, to enable the php-fpm function.

-- With-mysql =/usr/local/mysql is to enable php to support mysql, and/usr/local/mysql is the installation path of mysql database.

-- Enable-mbstring indicates that the main function of enabling the mbstring module of the mbstring module is to detect and convert the encoding and provide the corresponding string functions for multi-byte operations. Currently php internal encoding only supports ISO-8859-*, EUC-JP, UTF-8, other encoding languages can not be correctly displayed on the php program, so we want to enable the mbstring module.

-- With-iconv-dir =/usr/local specifies the location where php stores the libiconv Library.

-- With-apxs2 =/usr/local/apache2/bin/apxs specifies the location where php looks for apache.

After compilation, make again. When using make, you must add the-liconv parameter. If the-liconv parameter is not added, the system reports an error during 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

Run the following command:

Make ZEND_EXTRA_LIBS = '-liconv'

You can also add-liconv to the ZEND_EXTRA_LIBS line by modifying the Makefile file. As follows:

Vi Makefile

Make install

We can see that php support is enabled in the apache configuration file httpd, and the libphp5.so file is copied to the module directory of apache.

III,Configure apache to support php

After installing php, 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 the LoadModule php5_module modules/libphp5.so line exists when you view the httpd. conf file. This is because it was added during php installation. Now we only need to add the AddType application/x-httpd-php. php line.

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

In addition, we also need to modify the default apache homepage file and add index. php. The content is as follows:

Echo" ">/Usr/local/apache2/htdocs/index. php

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

IV,Test php

After the preceding modification, restart apache and run the following command:

/Etc/init. d/httpd graceful

Note that this command can restart apache elegantly.

Open the site as follows:

We can see that apache supports php.

This article is sponsored by Xiuyi Linfeng and first published in The Dark World. Apache supports php through the mod_php5 module of apache...

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.