docker安装yar及msgpack踩坑记录

跨世纪少年 20天前 102

以下操作是基于已经在docker里安装好nginx+php环境的,点 这里 查看。

下面进入正题:

centos容器创建后,进入系统无法使用一些命令

1、我是mac系统,首先用下面的命令创建并启动一个容器

docker run -tid --network=dusnoob --ip 192.168.10.1 --dns=8.8.8.8 --privileged=true --name=server01 -v /Users/xxx/www:/alidata -p 1080:80 -p 1022:22 cf4981lle3cdb

2、在我安装完nginx后,想用systemctl命令启动nginx却发现命令用不了!

我的解决办法:

docker run -tid --network=dusnoob --ip 192.168.10.1 --dns=8.8.8.8 --privileged=true --name=server01 -v /Users/xxx/www:/alidata -p 1080:80 -p 1022:22 cf4981lle3cdb init

网上有说加上 --privileged=true 就可以的,也有说在最后加上 /usr/sbin/init的

但我是mac电脑,上面的试了都还是不行,可能系统的关系,我是在最后面加了init就可以了,因为mac系统里/usr/sbin/init这个不存在。

pecl命令不能用,提示bash: pecl: command not found

解决办法:

因为docker里的centos是精简版的,所以能不装的都没,这个装一下就可以了,终端执行下面命令就可以:

yum install php-devel php-pear

执行pecl install msgpack报如下错误

[root@bf5282d14181 /]# pecl install msgpack
downloading msgpack-2.0.3.tgz ...
Starting to download msgpack-2.0.3.tgz (45,769 bytes)
.............done: 45,769 bytes
20 source files, building
running: phpize
Configuring for:
PHP Api Version:         20160303
Zend Module Api No:      20160303
Zend Extension Api No:   320160303
building in /var/tmp/pear-build-defaultuserNZMyqW/msgpack-2.0.3
running: /var/tmp/msgpack/configure --with-php-config=/usr/bin/php-config
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for a sed that does not truncate output... /usr/bin/sed
checking for cc... no
checking for gcc... no
configure: error: in `/var/tmp/pear-build-defaultuserNZMyqW/msgpack-2.0.3':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
ERROR: `/var/tmp/msgpack/configure --with-php-config=/usr/bin/php-config' failed

解决办法:

安装gcc软件套件

yum install gcc

执行pecl install yar报如下错误

[root@bf5282d14181 /]# pecl install yar
downloading yar-2.0.5.tgz ...
Starting to download yar-2.0.5.tgz (38,004 bytes)
..........done: 38,004 bytes
25 source files, building
running: phpize
Configuring for:
PHP Api Version:         20160303
Zend Module Api No:      20160303
Zend Extension Api No:   320160303
Enable Msgpack Supports [no] : yes
building in /var/tmp/pear-build-defaultuser7Gl4Jj/yar-2.0.5
running: /var/tmp/yar/configure --with-php-config=/usr/bin/php-config --enable-msgpack=yes
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for a sed that does not truncate output... /usr/bin/sed
checking for cc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
checking for cc option to accept ISO C89... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking whether cc understands -c and -o together... yes
checking for system library directory... lib
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for PHP prefix... /usr
checking for PHP includes... -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib
checking for PHP extension directory... /usr/lib64/php/modules
checking for PHP installed headers prefix... /usr/include/php
checking if debug is enabled... no
checking if zts is enabled... no
checking for re2c... no
configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.
checking for gawk... gawk
checking whether to enable yar support... yes, shared
checking for curl protocol support... yes, shared
checking for msgpack packager support... yes
checking for cURL in default path... not found
configure: error: Please reinstall the libcurl distribution - easy.h should be in <curl-dir>/include/curl/
ERROR: `/var/tmp/yar/configure --with-php-config=/usr/bin/php-config --enable-msgpack=yes' failed

解决办法:

安装libcurl,完成之后再安装就可以了

yum install -y libcurl-devel

重启nginx和php-fpm,查看phpinfo就有msgpack和yar的扩展了,如图:

最新回复 (0)
    • 都市菜鸟网
      2
        立即登录 立即注册 
返回
发新帖