阿里云 Serverless Computing + 关注
手机版

函数计算 php runtime 编译非内置的扩展

  1. 云栖社区>
  2. 阿里云 Serverless Computing>
  3. 博客>
  4. 正文

函数计算 php runtime 编译非内置的扩展

rsong 2019-01-11 20:20:07 浏览599 评论2

摘要: 在本文中,以 `php-gd` 扩展为例, 我们讲解如果利用fcli 工具编译函数计算php runtime 中其他没有内置的扩展

php runtime 使用FAQ

问题

函数计算 php runtime 中的 php 版本为 7.2.7,php runtime 已经内置了较多的扩展,具体如下:

"Core", "date", "libxml", "openssl", "pcre", "zlib", "curl","filter", "hash", "readline", "Reflection", 
"SPL", "session","xml", "standard", "mysqlnd", "bcmath", "bz2", "calendar","ctype", "dom", "mbstring", 
"fileinfo", "ftp", "gettext", "gmp", "iconv","imagick", "json", "exif", "mysqli", "pcntl", "PDO", 
"pdo_mysql","Phar", "posix", "protobuf", "redis", "shmop", "SimpleXML", "soap","sockets", "sysvmsg", "zip", "memcached",
"sysvsem", "sysvshm", "tokenizer", "xmlreader","xmlrpc", "xmlwriter", "Zend OPcache", "xdebug",

但是还有用户具有其他扩展的需求,比如用户有对 php-gd 扩展的需求, 在本文中,以 php-gd 扩展为例, 我们讲解如果利用fcli 工具编译其他没有内置的扩展,php相关的扩展如下: php-ext

文章最后章节提供了编译好的扩展下载.

操作方法

~ tmp # fcli shell
Welcome to the function compute world. Have fun!
>>> sbox -t php7.2 -d code
Entering the container. Your code is in the /code direcotry.
Unable to find image 'aliyunfc/runtime-php7.2:build' locally
build: Pulling from aliyunfc/runtime-php7.2
...

root@c83d77cb373d:/code# docker-php-ext-install gd
Configuring for:
PHP Api Version:         20170718
Zend Module Api No:      20170718
Zend Extension Api No:   320170718
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for a sed that does not truncate output... /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
....

Installing shared extensions:     /usr/local/lib/php/extensions/no-debug-non-zts-20170718/
Installing header files:          /usr/local/include/php/
find . -name \*.gcno -o -name \*.gcda | xargs rm -f
find . -name \*.lo -o -name \*.o | xargs rm -f
find . -name \*.la -o -name \*.a | xargs rm -f
find . -name \*.so | xargs rm -f
find . -name .libs -a -type d|xargs rm -rf
rm -f libphp.la       modules/* libs/*
root@c83d77cb373d:/code# ls /usr/local/lib/php/extensions/no-debug-non-zts-20170718/
bcmath.so    dom.so      gd.so       iconv.so       mysqli.so   pdo_mysql.so  redis.so       soap.so     sysvshm.so    xmlrpc.so
bz2.so         exif.so      gettext.so  imagick.so   opcache.so  phar.so         session.so    sockets.so  tokenizer.so  xmlwriter.so
calendar.so  fileinfo.so  gmp.so      json.so       pcntl.so    posix.so      shmop.so       sysvmsg.so  xdebug.so
ctype.so     ftp.so      hash.so     mbstring.so  pdo.so      protobuf.so   simplexml.so  sysvsem.so  xmlreader.so
root@c83d77cb373d:/code# cp /usr/local/lib/php/extensions/no-debug-non-zts-20170718/gd.so ./

最后从sbox 命令中关联的code目录把 gd.so 提取出来, 然后参考:
php runtime 使用自定义扩展

扩展下载

php-gd download

pgsql-demo

【云栖快讯】一站式开发者服务,海量学习资源免费学  详情请点击

网友评论