配置nginx+php+mysql遇到的问题

因为使用某个框架,框架要求必须是php5.4版本,而博主的系统centos6.6在源上没有相应版本,因为一些特殊需求考虑需要编译。以下来写一些个人所遇到的问题。其次提示大家在baidu或者网上看攻略的时候请多看几个对比下,因为每个人遇到的情况和需求可能不同,还有就是网上复制粘贴的人太多了。

先更新下最近的openssl扩展开启,因为框架需要用到composer安装,而composer安装的时候又需要php支持openssl,博主的情况是提前已经编译安装好了PHP,后来需要用到其他扩展希望动态编译进去。所以用到了phpize。
首先我是直接去下载composer了

curl -sS https://getcomposer.org/installer | php
//这个地址是国外的访问比较慢,有时候会提示php语法错误这个可以不用理会,取消之后再次执行多试几次就会好
//返回结果
Some settings on your machine make Composer unable to work properly.
Make sure that you fix the issues listed below and run this script again:

The openssl extension is missing, which means that secure HTTPS transfers are impossible.
If possible you should enable it or recompile php with --with-openssl

首先进入我的php解压包根目录,并且进入对应的扩展目录

cd /root/php5.6.5/ext/openssl

执行phpize(目录为博主指定安装的php目录,参考者根据自己目录使用)

/usr/local/php/bin/phpize //这里为你自己的phpize路径,如果找不到,使用whereis phpize查找

执行后发现找不到.m4文件,ERROR:

Cannot find config.m4. 
Make sure that you run '/usr/local/php/bin/phpize' in the top level source directory of the module

config0.m4就是config.m4,在当前目录下(每个扩展目录下都有)。直接copy

copy config0.m4 config.m4

把PHP加入系统环境变量,再次执行会出现以下报错

Configuring for:
PHP Api Version:         20131106
Zend Module Api No:      20131226
Zend Extension Api No:   220131226
Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.

网友给的解决办法是:

cd /usr/src
wget http://ftp.gnu.org/gnu/m4/m4-1.4.9.tar.gz
tar -zvxf m4-1.4.9.tar.gz
cd m4-1.4.9/
./configure && make && make install
cd ../
wget http://ftp.gnu.org/gnu/autoconf/autoconf-2.62.tar.gz
tar -zvxf autoconf-2.62.tar.gz
cd autoconf-2.62/
./configure && make && make install
//更简单的办法
# yum install m4
# yum install autoconf

再次执行

PHP Api Version:         20131106
Zend Module Api No:      20131226
Zend Extension Api No:   220131226

接下来编译

./configure --with-openssl --with-php-config=/usr/local/php/bin/php-config

接下来 make make install

//make结果:
/bin/sh /root/php-5.6.5/ext/openssl/libtool --mode=compile cc  -I. -I/root/php-5.6.5/ext/openssl -DPHP_ATOM_INC -I/root/php-5.6.5/ext/openssl/include -I/root/php-5.6.5/ext/openssl/main -I/root/php-5.6.5/ext/openssl -I/usr/local/php/include/php -I/usr/local/php/include/php/main -I/usr/local/php/include/php/TSRM -I/usr/local/php/include/php/Zend -I/usr/local/php/include/php/ext -I/usr/local/php/include/php/ext/date/lib  -DHAVE_CONFIG_H  -g -O2   -c /root/php-5.6.5/ext/openssl/openssl.c -o openssl.lo 
mkdir .libs
 cc -I. -I/root/php-5.6.5/ext/openssl -DPHP_ATOM_INC -I/root/php-5.6.5/ext/openssl/include -I/root/php-5.6.5/ext/openssl/main -I/root/php-5.6.5/ext/openssl -I/usr/local/php/include/php -I/usr/local/php/include/php/main -I/usr/local/php/include/php/TSRM -I/usr/local/php/include/php/Zend -I/usr/local/php/include/php/ext -I/usr/local/php/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /root/php-5.6.5/ext/openssl/openssl.c  -fPIC -DPIC -o .libs/openssl.o
/bin/sh /root/php-5.6.5/ext/openssl/libtool --mode=compile cc  -I. -I/root/php-5.6.5/ext/openssl -DPHP_ATOM_INC -I/root/php-5.6.5/ext/openssl/include -I/root/php-5.6.5/ext/openssl/main -I/root/php-5.6.5/ext/openssl -I/usr/local/php/include/php -I/usr/local/php/include/php/main -I/usr/local/php/include/php/TSRM -I/usr/local/php/include/php/Zend -I/usr/local/php/include/php/ext -I/usr/local/php/include/php/ext/date/lib  -DHAVE_CONFIG_H  -g -O2   -c /root/php-5.6.5/ext/openssl/xp_ssl.c -o xp_ssl.lo 
 cc -I. -I/root/php-5.6.5/ext/openssl -DPHP_ATOM_INC -I/root/php-5.6.5/ext/openssl/include -I/root/php-5.6.5/ext/openssl/main -I/root/php-5.6.5/ext/openssl -I/usr/local/php/include/php -I/usr/local/php/include/php/main -I/usr/local/php/include/php/TSRM -I/usr/local/php/include/php/Zend -I/usr/local/php/include/php/ext -I/usr/local/php/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /root/php-5.6.5/ext/openssl/xp_ssl.c  -fPIC -DPIC -o .libs/xp_ssl.o
/bin/sh /root/php-5.6.5/ext/openssl/libtool --mode=link cc -DPHP_ATOM_INC -I/root/php-5.6.5/ext/openssl/include -I/root/php-5.6.5/ext/openssl/main -I/root/php-5.6.5/ext/openssl -I/usr/local/php/include/php -I/usr/local/php/include/php/main -I/usr/local/php/include/php/TSRM -I/usr/local/php/include/php/Zend -I/usr/local/php/include/php/ext -I/usr/local/php/include/php/ext/date/lib  -DHAVE_CONFIG_H  -g -O2   -o openssl.la -export-dynamic -avoid-version -prefer-pic -module -rpath /root/php-5.6.5/ext/openssl/modules  openssl.lo xp_ssl.lo -lssl -lcrypto
cc -shared  .libs/openssl.o .libs/xp_ssl.o  -lssl -lcrypto  -Wl,-soname -Wl,openssl.so -o .libs/openssl.so
creating openssl.la
(cd .libs && rm -f openssl.la && ln -s ../openssl.la openssl.la)
/bin/sh /root/php-5.6.5/ext/openssl/libtool --mode=install cp ./openssl.la /root/php-5.6.5/ext/openssl/modules
cp ./.libs/openssl.so /root/php-5.6.5/ext/openssl/modules/openssl.so
cp ./.libs/openssl.lai /root/php-5.6.5/ext/openssl/modules/openssl.la
PATH="$PATH:/sbin" ldconfig -n /root/php-5.6.5/ext/openssl/modules
----------------------------------------------------------------------
Libraries have been installed in:
   /root/php-5.6.5/ext/openssl/modules

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,--rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------

Build complete.
Don't forget to run 'make test'.

make install会返回一些so文件的拷贝目录 后面需要用到

Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/
[root@VM_20_231_centos openssl]# make install
/bin/sh /root/php-5.6.5/ext/openssl/libtool --mode=install cp ./openssl.la /root/php-5.6.5/ext/openssl/modules
cp ./.libs/openssl.so /root/php-5.6.5/ext/openssl/modules/openssl.so
cp ./.libs/openssl.lai /root/php-5.6.5/ext/openssl/modules/openssl.la
PATH="$PATH:/sbin" ldconfig -n /root/php-5.6.5/ext/openssl/modules
----------------------------------------------------------------------
Libraries have been installed in:
   /root/php-5.6.5/ext/openssl/modules

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,--rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/

接下来去php.ini里面加载so文件

cd vim /usr/local/php/lib/php.ini
//在最后一行加上
extension=openssl.so

再次执行composer下载

curl -sS https://getcomposer.org/installer | php
Downloading...

Composer (version 1.3.1) successfully installed to: /root/composer.phar
Use it: php composer.phar

Some settings on your machine may cause stability issues with Composer.
If you encounter issues, try to change the following:

The zlib extension is not loaded, this can slow down Composer a lot.
If possible, install it or recompile php with --with-zlib

The php.ini used by your command-line PHP is: /usr/local/php/lib/php.ini
If you can not modify the ini file, you can also run `php -d option=value` to modify ini values on the fly. You can use -d multiple times.
//提示安装已经成功,但是被警告我没有安装zlib扩展,于是我再次按照安装openssl的方式再次安装

安装完毕一定要重启nginx或者apache,以后就可以很熟练的使用phpize了

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值