I need to enable gd extension for php7.3 , but extension list did't include it via php -m
Here is my buildspec.yml.
version: 0.2
phases:
install:
runtime-versions:
php: 7.3
commands:
- add-apt-repository ppa:ondrej/php
- apt-get update
- apt-get install -y php-pear php7.3-curl php7.3-dev php7.3-mbstring php7.3-zip php7.3-mysql php7.3-xml php7.3-pdo php7.3-pdo-sqlite php7.3-fpm php7.3-gd php7.3-xmlrpc php7.3-opcache
- php -m
CodeBuild output
[Container] 2019/05/12 09:24:18 Running command php -m
[PHP Modules]
Core
ctype
curl
date
dom
fileinfo
filter
ftp
hash
iconv
json
libxml
mbstring
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_pgsql
pdo_sqlite
Phar
posix
readline
Reflection
session
SimpleXML
sockets
SPL
sqlite3
standard
tokenizer
xml
xmlreader
xmlwriter
zlib
[Zend Modules]
Should I move/copy extension *.so files to <extension_dir> ?
Here is buildspec.yml commands :
- cp /usr/lib/php/20180731/*.so /usr/local/lib/php/extensions/no-debug-non-zts-20180731
- cp /etc/php/7.3/cli/php.ini /usr/local/etc/php
- cp /etc/php/7.3/cli/conf.d/* /usr/local/etc/php/conf.d
Yes , it works for me.
I've been trying to install some extensions and it seems to work for php7.3-gd, but zip keeps dying with this message:
[Container] 2019/05/31 18:50:27 Running command php -m
PHP Warning: PHP Startup: Unable to load dynamic library 'zip.so' (tried: /usr/lib/php/20180731/zip.so (/usr/lib/php/20180731/zip.so: undefined symbol: pcre2_match_8), /usr/lib/php/20180731/zip.so.so (/usr/lib/php/20180731/zip.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
buildspec looks like this for install:
- apt-get install -y php7.3-zip
- apt-get install -y php7.3-gd
- apt-get install -y php7.3-xdebug
- touch /usr/local/etc/php/conf.d/extra_config.ini
- "echo extension_dir=\"/usr/lib/php/20180731/\" >> /usr/local/etc/php/conf.d/extra_config.ini"
- "echo extension=gd.so >> /usr/local/etc/php/conf.d/extra_config.ini"
- "echo extension=zip.so >> /usr/local/etc/php/conf.d/extra_config.ini"
- "echo zend_extension=xdebug.so >> /usr/local/etc/php/conf.d/extra_config.ini"
- cat /usr/local/etc/php/conf.d/extra_config.ini
- php -m
any ideas?
Where exactly are you installing php7.3-zip from? The same command for me produces E: Unable to locate package php7.3-zip which is not surprising because it looks like they compiled PHP from src for this junk and didn't package anything. I am running into the same issue with the same extension and I am struggling to find any workaround. You cannot spin up a 2.0 image without a runtime, so installing a different version of PHP is apparently not a thing. Unfortunately, the only runtime for php is 7.3 which is not supported by Ubuntu 18.04 so you cannot install anything via apt to "fix" you environment. What a dumpster fire.
Alright, I have a working solution for those that come after. The PHP installation proved by AWS for Ubuntu 18.04 (v2) appears to have been compiled from source along with all of the other supported "runtime-versions" and then dumped into /usr/local. Working with this version of PHP is a really painful because it appears to be missing several PHP modules and runtime dependencies for those modules. I am sure there is someway to hack together a working solution with this copy of PHP, but why would you when the package manager already solves this issue in a simple, well documented fashion.
If you look in the /usr/local/bin folder, you will immediately notice that you got ALL of the runtime versions, regardless of which you specified in your buildspec file. This begs the question, why is the runtime-version required or even included in the buildspec file? You can pick any runtime-versions you want, and you will get them all.
So, in order to get a working PHP installation, you need to remove all of the PHP garbage AWS included in /usr/local/bin because that location comes before /usr/bin in the environment PATH. Now that you do not have PHP in the path anymore, you can install the package managers version of PHP via apt-get install -y php7.2-cli php7.2-zip. Finally, do not forget to run phpenmod for the modules installed to ensure they are enabled.
version: 0.2
run-as: root
phases:
install:
runtime-versions:
nodejs: 8
commands:
- rm -f /usr/local/bin/php*
- rm -f /usr/local/bin/phar*
- rm -f /usr/local/bin/pear*
- rm -f /usr/local/bin/pecl*
- apt-get update
- apt-get upgrade -y
- apt-get install -y php7.2-cli php7.2-zip
- phpenmod zip
Hi there,
I was able to install zip by using pecl, and then copying the zip.so to the extension dir '/usr/lib/php/20180731/". I also needed to install "libzip-dev" as per pecl requirement to install zip extension. I hope this information helps. See the following buildspec example:
version: 0.2
phases:
install:
runtime-versions:
php: 7.3
build:
commands:
- php -v
- php -m
- lsb_release -a
- LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/php
- apt-get update -y
- apt-get install -y php7.3-gd php7.3-xdebug libzip-dev
- pecl install zip
- cp /usr/local/lib/php/extensions/no-debug-non-zts-20180731/zip.so /usr/lib/php/20180731/
- ls /usr/lib/php/20180731
- touch /usr/local/etc/php/conf.d/extra_config.ini
- "echo extension_dir=\"/usr/lib/php/20180731/\" >> /usr/local/etc/php/conf.d/extra_config.ini"
- "echo extension=gd.so >> /usr/local/etc/php/conf.d/extra_config.ini"
- "echo zend_extension=xdebug.so >> /usr/local/etc/php/conf.d/extra_config.ini"
- "echo extension=zip.so >> /usr/local/etc/php/conf.d/extra_config.ini"
- cat /usr/local/etc/php/conf.d/extra_config.ini
- php -m
Hi,
Just wanted to let you guys know that AWS seems to have fixed this for php 7.3, now this workaround is not necessary (and will actually fail).
Sample buildspec would be (for Amazon Linux 2 container):
version: 0.2
run-as: Linux-user-name
phases:
install:
runtime-versions:
php: 7.3
commands:
- PYTHON=python2 amazon-linux-extras enable php7.3
- yum install -y php-gd
i want to install pdo_pgsql extension on aws bitnami server kinldy help me out.
Most helpful comment
Alright, I have a working solution for those that come after. The PHP installation proved by AWS for Ubuntu 18.04 (v2) appears to have been compiled from source along with all of the other supported "runtime-versions" and then dumped into /usr/local. Working with this version of PHP is a really painful because it appears to be missing several PHP modules and runtime dependencies for those modules. I am sure there is someway to hack together a working solution with this copy of PHP, but why would you when the package manager already solves this issue in a simple, well documented fashion.
If you look in the /usr/local/bin folder, you will immediately notice that you got ALL of the runtime versions, regardless of which you specified in your buildspec file. This begs the question, why is the runtime-version required or even included in the buildspec file? You can pick any runtime-versions you want, and you will get them all.
So, in order to get a working PHP installation, you need to remove all of the PHP garbage AWS included in /usr/local/bin because that location comes before /usr/bin in the environment PATH. Now that you do not have PHP in the path anymore, you can install the package managers version of PHP via apt-get install -y php7.2-cli php7.2-zip. Finally, do not forget to run phpenmod for the modules installed to ensure they are enabled.