Compile php5.4 and add extension after installation

Source: Internet
Author: User
Compile php5.4 and add extension after installation. today, because php5.4 does not have an appropriate RPM package for R & D, you can only download the source code package and compile and download the php5.4 package: wgetcn2.php.netgetphp-5.4.8.tar.gzfromthismirrortarzxvfphp-5.4.8.tar.gz php module is best not to install in the compilation, compile php5.4 and add extension after installation

Today, because the development requires no RPM Package for php5.4, you can only download the source code package and compile it.

Download php5.4 pack: wget http://cn2.php.net/get/php-5.4.8.tar.gz/from/this/mirror

Tar zxvf php-5.4.8.tar.gz

It is best not to install the php module during compilation to avoid future upgrade troubles,

./Configure -- prefix =/usr/local/webserver/php \
??????? -- With-zlib \
??????? -- With-mysql =/data/mysql \
??????? -- With-jpeg-dir =/usr/local/jpeg \
??????? -- With-png-dir =/usr/local/libpng \
??????? -- With-freetype-dir =/usr/local/freetype \
??????? -- With-libexpat-dir \
??????? -- With-iconv \
??????? -- With-ttf \
??????? -- With-curl \
??????? -- With-curlwrappers \
??? -- Disable-sqlite \
??????? -- Enable-gd-native-ttf \
??????? -- Enable-mbstring \
??????? -- Enable-sockets \
??????? -- Enable-fastcgi \
??????? -- Enable-force-cgi-redirect \
??????? -- Enable-discard-path \
??????? -- Enable-safe-mode \
??????? -- Enable-sysvsem \
??????? -- Enable-sysvshm \
??????? -- Enable-sysvmsg \
??????? -- Enable-inline-optimization \
??????? -- Disable-xmlreader \
??????? -- Disable-debug \
??????? -- Disable-rpath \
??? -- Disable-libxml \
??? -- Disable-dom \
??? -- Disable-pdo \
??? -- Disable-simplexml \
??? -- Disable-xml \
??? -- Disable-xmlwriter \
??????? -- Without-pear \
??????? -- Enable-fpm \
??????? -- With-fpm-user = nobody \
??????? -- With-fpm-group = nobody \
??????? -- With-fpm-log =/var/log/php-fpm.log \
??????? -- With-fpm-pid =/var/run/php-fpm/php-fpm.pid

Configure: error: Cannot find libz solution

Yum install zlib. x86_64

Yum install zlib-devel.x86_64

The solution for re-compilation is: configure: error: Please reinstall the libcurl distribution-easy. h shocould.

Yum-y install curl-devel

This compilation is successful.

Make & make install

If you do not know much about the parameters after./configurg, you can use./configurg -- help to check the details.

Copy php. ini-production to the php Directory: cp php. ini-production? /Usr/local/webserve/php/lib/php. ini

Modify php/etc/php-fpm profile: mv php-fpm.conf.default php-fpm.conf

Install the extension pdo_mysql

This extension is generally included in the PHP source code package: it is generally in the./ext/pdo_mysql/directory.

Cd/php5.4/ext/pdo_mysql/

/Usr/local/webserver/php/bin/phpize

The error "Cannot find autoconf. Please check your autoconf installation and
$ PHP_AUTOCONF environment variable. Then, rerun this script.

Autoconf missing

This package is a GNU tool used to automatically configure source code. Otherwise, the configure file is not generated in the pdo_mysql directory.

Everything works normally again:/usr/local/webserver/php/bin/phpize

./Configure -- with-php-config =/usr/local/webserver/php/bin/php-config -- with-pdo-config =/data/mysql/bin/mysql_config

Also encountered an error: configure: error: Cannot find php_pdo_driver.h.

I found the information and did not find anyone having encountered this problem. I used locate php_pdo_driver.h to find it in the directory of the pdo module. I checked the information and found that to install pdo_mysql, the pdo module must be installed first, okay. install the pdo module first.

Cd? Php5.4/ext/pdo/

/Usr/local/webserver/php/bin/phpize

./Configure -- with-php-config =/usr/local/webserver/php/bin/php-config? -- Enable-pdo = shared

Make & make install

Cd php5.4/ext/pdo_mysql/

/Usr/local/webserver/php/bin/phpize

./Configure -- with-php-config =/usr/local/webserver/php/bin/php-config -- with-pdo-mysql =/data/mysql/bin/mysql_config

Make & make install

After compilation is successful, the Directory of the extension module appears under the php installation directory.

Add the following lines to the php/lib/php. ini file:

Extension_dir = "/usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20100525 /"
Extension = pdo. so
Extension = pdo_mysql.so
Extension = memcache. so

[Root @ localhost yum. repos. d] # php-m
[PHP Modules]
Core
Ctype
Curl
Date
Ereg
Fileinfo
Filter
Hash
Iconv
Json
Mbstring
Memcache
Mysql
Pcre
PDO
Pdo_mysql
Phar
Posix
Reflection
Session
Sockets
SPL
Sqlite3
Standard
Sysvmsg
Sysvsem
Sysvshm
Tokenizer
Zlib

[Zend Modules]

Or:/usr/local/webserver/php/bin/php-r "phpinfo ();" | grep-I pdo_mysql

Finally succeeded.

?

Transfer? Http://198555.blog.51cto.com/188555/1063199

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.