源码安装php5.6之旅

官网下载php5.6

依次在目录中执行:

./buildconf --force

./configure --prefix=/data/php-fpm --with-apxs2=/usr/sbin/apxs --enable-fpm --with-fpm-user=myname --with-fpm-group=myname --with-mysqli --with-pdo-mysql --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --with-mcrypt --enable-ftp --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --disable-fileinfo --enable-maintainer-zts

遇到报错:

configure: error: Cannot find OpenSSL's <evp.h>

半年之后,又遇到了openssl的问题,看来要短兵相接了!

N久之前,安装了这个openssl-1.0.1q

修改configure

./configure --prefix=/data/php-fpm --with-apxs2=/usr/sbin/apxs --enable-fpm --with-fpm-user=myname --with-fpm-group=myname --with-mysqli --with-pdo-mysql --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --with-mcrypt --enable-ftp --with-gd --enable-gd-native-ttf --with-openssl=/data/openssl-1.0.1q --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --disable-fileinfo --enable-maintainer-zts

还是同样的报错

只好百度一下了。

参考这个:Link

尝试

brew install openssl

发现已经安装过了openssl

brew info openssl

发现缺少了一个makebuild的依赖

brew install makebuild

安装这个依赖之后,再次查看openssl的info

brew info openssl

哦?!依赖报错没有了

思考了一下,我是否可以直接用brew install安装的openssl来安装php,so。。。

./configure --prefix=/data/php-fpm --with-apxs2=/usr/sbin/apxs --enable-fpm --with-fpm-user=myname --with-fpm-group=myname --with-mysqli --with-pdo-mysql --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --with-mcrypt --enable-ftp --with-gd --enable-gd-native-ttf --with-openssl=usr/local/Cellar/openssl/1.0.2f --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --disable-fileinfo --enable-maintainer-zts

T_T感动的落泪了。终于换了一个报错

configure: error: Cannot locate header file libintl.h

搜到了大牛的一篇文章:

google了一下,这里有解决办法:PHP with Intl and Gettext on OSX Lion。

大致步骤是:

1、安装ICU

tar xzvf icu4c-4_8_1-src.tgz
cd icu/source
./runConfigureICU MacOSX
make
sudo make install

2、安装PHP自带的intl扩展

找了半天终于找到了下载地址

wget http://download.icu-project.org/files/icu4c/4.2.1/icu4c-4_2_1-src.tgz  

执行完最后的sudo make install之后,再次执行./configure

waiting...

依旧报错:

configure: error: Cannot locate header file libintl.h

执行第二步: 安装php自带的intl扩展

./configure --prefix=/data/php-fpm --with-apxs2=/usr/sbin/apxs --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-mysqli --with-pdo-mysql --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --with-mcrypt --enable-ftp --with-gd --enable-gd-native-ttf --enable-intl --with-openssl=/usr/local/Cellar/openssl/1.0.2f --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --disable-fileinfo --enable-maintainer-zts

waiting

还是报错。。。。

F!手动安装

cd ext/intl
/usr/local/php/bin/phpize intl
./configure --enable-intl
make

报错:

In file included from /data/php5.6/ext/intl/php_intl.c:25:
./php_intl.h:23:10: fatal error: 'php.h' file not found
#include <php.h>
         ^
1 error generated.

F

源码安装搞不定intl了,试试看PECL安装。

I can't open PEAR, so..

Try another method:

http://www.codeweblog.com/configure-error-cannot-locate-header-file-libint/

是不是缺少了gettext底层依赖,所以报错?

未完啊未完
Continue

/php5.6目录下,重新配置configure

./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php --with-mysql --with-mysqli --enable-pdo --with-pdo-mysql --with-mysql-sock=/tmp/mysql.sock --enable-opcache --enable-cgi --enable-fpm --enable-sockets --enable-mbstring --enable-mbregex --enable-bcmath --enable-xml --enable-zip --with-zlib --with-gd --with-png-dir=/usr/local/lib/libpng --with-jpeg-dir=/usr/local/lib/libjpeg --with-curl --with-mhash=/usr/local/lib/libmhash --with-mcrypt=/usr/local/lib/libmcrypt --with-iconv=/usr/local/lib/libiconv --with-openssl

提示

Cann't find evp.h 

发现是在安装openssl的时候报错。

查看configure文件

vim configure

在vim命令行下搜索evp.h

找到了openssl的搜索目录。其实在搜索的这三个目录下,没有openssl这个库导致的报错。

将以前下载好的openssl库进行copy,copy到指定的搜索目录。

继续安装。

成功。

参考

  1. http://serverfault.com/questions/415458/php-error-cannot-find-openssls-evp-h

  2. http://note.rpsh.net/posts/2015/10/07/installing-php-intl-extension-os-x-el-capitan/

tar zxvf php-5.6.37.tar.gz cd php-5.6.37 #添加组 groupadd www #添加php-fpm用户 useradd -c php-fpm-user -g www -M www # c和c++编译器 yum -y install -y gcc gcc-c++ # PHP扩展依赖 yum install -y libxml2-devel openssl-devel libcurl-devel libjpeg-devel libpng-devel libicu-devel openldap-devel ./configure --prefix=/usr/local/php \ --with-config-file-path=/usr/local/php/etc \ --enable-fpm\ --with-fpm-user=www\ --with-fpm-group=www\ --enable-mysqlnd\ --with-mysql=mysqlnd\ --with-mysqli=mysqlnd\ --with-pdo-mysql=mysqlnd\ --enable-opcache\ --enable-pcntl\ --enable-mbstring\ --enable-soap\ --enable-zip\ --enable-calendar\ --enable-bcmath\ --enable-exif\ --enable-ftp\ --enable-intl\ --with-openssl\ --with-zlib\ --with-curl\ --with-gd\ --with-zlib-dir=/usr/lib\ --with-png-dir=/usr/lib\ --with-jpeg-dir=/usr/lib\ --with-gettext\ --with-mhash\ --with-ldap make && make install cp php.ini-production /usr/local/php/etc/php.ini cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm # 设置php-fpm开机自动启动 chmod +x /etc/init.d/php-fpm chkconfig php-fpm on cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf service php-fpm start 设置php为全局命令: 修改/etc/profile文件使其永久性生效,并对所有系统用户生效, 在文件末尾加上如下两行代码: PATH=$PATH:/usr/local/php/bin //php命令路径 如果还要同时加入mysql 则第一句: PATH=$PATH:/usr/local/php/bin:/usr/local/mysql/bin //路径一定要正确 执行 命令source /etc/profile 使用php -V确认 【查看php-fpm端口】 vim /usr/local/php/etc/php-fpm.conf listen = 127.0.0.1:9000
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值