Compile and install PHP in Linux

Source: Internet
Author: User
Compile and install PHP in Linux (ubuntu) environment.

Note: The installation path varies with operating systems!

1. Download php source code

$ Cd/usr/local/src

$ Wget http://cn.php.net/get/php-5.3.6.tar.bz2/from/this/mirror

2. decompress and install

$ Tar jxvf php-5.3.6.tar.bz2

$ Cd php-5.3.6/

$. /Configure -- prefix =/usr/local/php5 -- with-apxs2 =/usr/local/apache2/bin/apxs -- with-mysql =/home/service/mysql -- with-zlib

$ Make

$ Make install

3. modify the apache configuration so that apache can identify the ". php" file.

$ Cd/etc/apach2

$ Vi apache2.conf

Add the following content at the end of the file:

 1 LoadModule php5_module  modules/libphp5.so 2 
 
   3 LoadModule php5_module lib/modules/libphp5.so 4 
  5  6 
 
    7     AddType application/x-httpd-php .php  8     AddType application/x-httpd-php .php5  9     AddType application/x-httpd-php-source .phps 10     AddType application/x-httpd-php-source .php5s 11     DirectoryIndex index.php 12     DirectoryIndex index.php5 13 
 

Save and exit.

$/Usr/local/apache2/bin/apachectl restart

Restart apche and use the phpinfo () function to view the installed php module.

Appendix:

Meanings of configure parameters in php compilation in linux

Http://apps.hi.baidu.com/share/detail/34997687

Reference:

Http://blog.csdn.net/lanyd/article/details/6037927

Http://hi.baidu.com/comeon010/blog/item/983b29cbab80f912bf09e6a1.html

Http://hi.baidu.com/travel981cn/blog/item/2514bf34069031b0d0a2d30e.html

Http://www.phpbegin.com/html/96/n-4296.html

Http://www.cnblogs.com/qingfeng2010/archive/2011/01/07/1930333.html

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.