函數計算 php runtime 編譯非內置的擴展

問題

函數計算 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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章