Compiling and installing PHP

Source: Internet
Author: User
Tags bz2 dbase dbx dio fpm gettext php website zts

Compiling and installing PHP

1. Go to the PHP website to download the source http://www.php.net/downloads.php, I download the version used is (php-5.4.8.tar.gz)

2. Extract to/usr/src directory, execute command: sudo tar-zxvf php-5.4.8.tar.gz-c/usr/src

3. Implementation./configure--prefix=/usr/local/php--enable-fpm--with-mcrypt=/usr/local/libmcrypt--with-zlib-- Enable-mbstring--with-openssl--with-mysql--with-mysqli--with-mysql-sock--with-gd--with-jpeg-dir=/usr/lib-- Enable-gd-native-ttf--enable-pdo--with-pdo-mysql--with-gettext--with-curl--with-pdo-mysql--enable-sockets-- Enable-bcmath--enable-xml--with-bz2--enable-zip--enable-freetype

4. Compilation encountered a problem: Error:xml2-config not found. Workaround:

(1) to the official website http://xmlsoft.org/sources/download source code. The version I used was libxml2-2.9.0.tar.gz, extracted to/usr/src, execute command: sudo tar-zxvf libxml2-2.9.0.tar.gz-c/usr/src

(2) Enter the directory/usr/src/libxml2-2.9.0, execute under root or with the sudo command: sudo./configure --prefix=/usr/local/libxml2/; Install

(3) Add--with-libxml-dir=/usr/local/libxml2 when compiling into PHP directory

5. Compile again and encounter the problem: checking if the location of ZLIB install directory is defined ... no; Configure:error:Cannot find LIBZ. Workaround:

(1) Go to the URL http://www.zlib.net/download zlib source code. I'm under version zlib-1.2.7.tar.gz, unzip to/USR/SRC, execute command: sudo tar-zxvf zlib-1.2.7.tar.gz-c/usr/src

(2) Enter directory/usr/src/zlib-1.2.7/, execute command: sudo./configure--prefix=/usr/local/zlib;make;make Install

(3) Recompile in PHP directory, add new parameter--with-zlib-dir=/usr/local/zlib

6. Compile again and encounter the problem: Error:please Reinstall the BZIP2 distribution. Workaround:

(1) Go to the website http://www.bzip.org/downloads.html download the source code. The version I'm using is bzip2-1.0.6.tar.gz, execute command: sudo tar-zxvf bzip2-1.0.6.tar.gz-c/usr/src

(2) Enter the directory/usr/src/bzip2-1.0.6/,sudo mode of execution: Make;make Install (under the source code is not configure)

(3) Recompile without adding new parameters

7. Compile again and encounter the problem:

Checking if we should use Curl for URL streams ... no checking for CURL in default path ... not found

Configure:error:Please Reinstall the Libcurl distribution-easy.h should be in <curl-dir>/include/curl/

The solution is to reload the Libcurl

(1) Go to the website http://curl.haxx.se/download/download Libcurl source code. The version I'm using is curl-7.28.0.tar.gz, execute command: sudo tar-zxvf curl-7.28.0.tar.gz-c/usr/src

(2) Enter the/usr/src/curl-7.28.0 directory and execute the command with sudo:./configure--prefix=/usr/local/curl;make;make Install

(3) Recompile PHP, add parameter--with-curl=/usr/local/curl

8. Compile again, encounter the problem: Configure:error:jpeglib.h not found. Workaround:

(1) Go to the website http://www.ijg.org/download the source code. The version I'm using is jpegsrc.v8d.tar.gz, execute command: sudo tar-zxvf jpegsrc.v8d.tar.gz-c/usr/src

(2) Enter the/usr/src/jpegsrc.v8d directory, sudo mode execution command: sudo./configure--prefix=/usr/local/jpeg;make;make Install;

(3) Recompile PHP, add parameter--with-jpeg-dir=/usr/local/jpeg

9. Compile again, encounter the problem: Configure:error:png.h not found.

(1) to the website http://www.libpng.org/pub/png/libpng.html download the source code, I use the version is libpng-1.5.13.tar.gz, executes the command: sudo tar-zxvf Libpng-1.5.13.tar.gz-c/USR/SRC

(2) Enter the/usr/src/libpng-1.5.13 directory, sudo mode execution command: sudo./configure--prefix=/usr/local/png;make;make Install;

(3) At this time Configure:error:zlib not installed error, obviously before has been installed, but here is still an error. On-line search for solutions are as follows:

3.1) Enter the source file directory of zlib (here my is/usr/src/zlib-1.2.7/), execute command make clean, clear zlib;

3.2) reconfigure./configure, do not answer the--prefix parameters;

3.3) make && make install;

3.4) Enter the Libpng directory (mine is/usr/src/libpng-1.5.13/), execute the command./configure--prefix=/usr/local/png;

3.5) make && make install;

(4) Recompile PHP, then add parameter--with-png-dir=/usr/local/png.

10. Compile again, encounter the problem: Configure:error:mcrypt.h not found. Please reinstall Libmcrypt.

(1) to the website http://mcrypt.hellug.gr/lib/index.html download source code, my next version is libmcrypt-2.5.7.tar.gz; Execute command: sudo tar-zxvf Libmcrypt-2.5.7.tar.gz-c/USR/SRC

(2) Enter the/usr/src/libmcrypt-2.5.7 directory, sudo way to execute the command:./configure prefix=/usr/local/libmcrypt/;make; make install

(3) Recompile PHP, add parameter--with-mcrypt=/usr/local/libmcrypt

11. Compile again, there is no problem, although the configure:WARNING:unrecognized options:--enable-freetype, but the result is still thank you to using PHP. The parameters for compiling PHP at this time are as follows:

(1) sudo./configure--prefix=/usr/local/php--enable-fpm--with-zlib--enable-mbstring--with-openssl--with-mysql-- With-mysqli--with-mysql-sock--with-gd--enable-gd-native-ttf--enable-pdo--with-pdo-mysql--with-gettext-- With-curl--with-pdo-mysql--enable-sockets--enable-bcmath--enable-xml--with-bz2--enable-zip--enable-freetype-- WITH-LIBXML-DIR=/USR/LOCAL/LIBXML2--with-zlib-dir=/usr/local/zlib--with-curl=/usr/local/curl--with-jpeg-dir=/ Usr/local/jpeg--with-png-dir=/usr/local/png--with-mcrypt=/usr/local/libmcrypt--with-apxs2=/usr/local/apache2/ Bin/apxs

(Note: Be sure to add this Apxs-apache eXtenSion tool used to make Apache expansion module DSO, to use this tool, when installing Apache must add enable-so to support DSO. If this is not the case, Apache will only parse the static page, the first time the compilation did not add, how to configure it, the second time added the option to recompile after the OK. )

(2) sudo make

(3) sudo make install

12. In order to be able to use PHP command directly at the command line, edit sudo vim/etc/environment, add php Bin directory path, mine is/usr/local/php/bin, then reboot machine

13. To enable Apache to support PHP, the workaround:

(1) Enter the Apache configuration directory and execute the command: cd/usr/local/apache2/conf. Edit file: sudo vim httpd.conf

(2) Find the string AddType and add

AddType application/x-httpd-php. php. php3. htm. phtml. php4

AddType Application/x-httpd-php-source. Phps

Then restart Apache for the configuration to take effect

(3) Find the string directoryindex and modify it to DirectoryIndex index.html index.php3 index.php default.php

14. Modify the PHP configuration.

(1) Enter the PHP source directory, select Php.ini-development Copy to/usr/local/lib, and renamed PHP.ini use Vim to open, find Extension_dir, modified to Extension_dir = "d:/ Php/php5/ext ", the reader is configured according to its own directory structure to locate and php.ini the extension library in the Ext folder under the same directory.

(2) Find Extension=php_, remove Extension=php_curl.dll,extension=php_gd2.dll,extension=php_mbstring.dll,extension=php_ The semicolon in front of the Mysql.dll,extension=php_mysqli.dll,extension=php_pdo_mysql.dll,extension=php_xmlrpc.dll. Look for short_open_tag = off to change it to Short_open_tag = on, so that it supports the short label (I see the note that the default is open).

15. Find the string documentroot, you can set the Apache virtual root directory

16. Find the string serveradmin and modify it to your own mailbox

17. Add a test.php file to the Apache root file, <?php phpinfo ();., and then visit 127.0.0.1/test.php to view the results.

Appendix: The compilation parameters of the PHP versions for the Web are as follows.

FAST-CGI:
./configure--prefix=/usr/local/php--enable-fastcgi--enable-force-cgi-redirect--with-config-file-path=/etc-- With-zlib--with-mysql--with-xml--with-gd--enable-gd-native-ttf--enable-gd-jis-conv--with-freetype-dir-- With-jpeg-dir--with-png-dir--enable-mbstring

Php4-server:
./configure--prefix=/usr/local/php--with-apxs2=/usr/local/apache2/bin/apxs--with-mysql--with-config-file-path= /etc--with-gd--enable-gd-native-ttf--enable-gd-jis-conv--with-freetype-dir--with-jpeg-dir--with-png-dir-- With-zlib--enable-xml--enable-mbstring

Php4-max:
./configure--prefix=/usr/local/php--with-apxs2=/usr/local/apache/bin/apxs--mandir=/usr/share/ Man--with-mysql=/usr/local/mysql--with-config-file-path=/usr/local/php/etc--with-openssl=/usr/local/ openssl-0.9.7e--with-gd--enable-gd-native-ttf--enable-gd-jis-conv--with-freetype-dir--with-jpeg-dir-- With-png-dir--with-zlib--with-bz2--with-inifile--with-hyperwave--enable-xml--enable-track-vars--enable-dba-- Enable-dbase--enable-filepro--enable-ftp--enable-versioning--enable-memory-limit--enable-calendar-- Enable-session--enable-sockets--enable-sysmsg--enable-sysvsem--enable-sysvshm--enable-tokenizer-- Enable-overload--enable-ctype--enable-sigchild--enable-magic-quotes--enable-roxen-zts--enable-fastcgi-- Enable-dbx--enable-dio--enable-shmop--enable-mbstring

Php5-server:
./configure--prefix=/usr/local/php--with-apxs2=/usr/local/apache2/bin/apxs--with-zlib-dir--with-bz2-- With-tiff-dir--with-libxml-dir--with-gd--with-freetype-dir--with-jpeg-dir--with-png-dir--with-ttf-- Enable-mbstring--with-mysql=/usr/lib/mysql--with-config-file-path=/etc--disable-ipv6--enable-gd-native-ttf

Php5-standard:
./configure--prefix=/usr/local/php--with-apxs2=/usr/local/apache/bin/apxs--mandir=/usr/share/man--with-openssl =/usr/local/openssl-0.9.7e--with-zlib--with-bz2--with-tiff-dir--with-libxml-dir--enable-dio--enable-ftp-- WITH-GD--with-freetype-dir--with-jpeg-dir--with-png-dir--with-zlib-dir--with-bz2-dir--with-ttf-- Enable-mbstring--with-mysql=/usr/local/mysql--with-config-file-path=/usr/local/php/etc--disable-ipv6-- Enable-gd-native-ttf

Php5-max:
./configure--prefix=/usr/local/php--with-apxs2=/usr/local/apache/bin/apxs--mandir=/usr/share/man--with-openssl =/usr/local/openssl-0.9.7e--with-zlib--with-bz2--with-tiff-dir--with-libxml-dir--enable-dio--enable-ftp-- WITH-GD--with-freetype-dir--with-jpeg-dir--with-png-dir--with-zlib-dir--with-bz2-dir--with-ttf--with-inifile-- ENABLE-DBA--enable-dbase--enable-filepro--enable-versioning--enable-memory-limit--enable-calendar-- Enable-sockets--enable-sysvsem--enable-sigchild--enable-magic-quotes--enable-roxen-zts--enable-fastcgi-- Enable-dbx--enable-shmop--enable-mbstring--with-mysql=/usr/local/mysql--with-config-file-path=/usr/local/php/ etc--disable-ipv6--enable-gd-native-ttf

Reference URL:

http://blog.163.com/[email protected]/blog/static/1170868762011593131831/

Http://www.cnblogs.com/amboyna/archive/2008/07/13/1241961.html

Http://www.cnblogs.com/neve/articles/1989352.html

Http://blog.chinaunix.net/uid-23095063-id-163167.html

http://www.habadog.com/2012/02/07/install-curl-ext-with-php-source-code-in-linux/

http://www.oschina.net/question/17_10674

Http://www.cnblogs.com/1110111abc/archive/2012/09/22/2698259.html

http://blog.163.com/[email protected]/blog/static/117086876201159355861/

Http://blog.sina.com.cn/s/blog_61aed0450100sr5k.html

Http://www.jb51.net/article/24691.htm

Compiling and installing PHP

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.