Does anyone know how to install and enable PHP IMAP Extension on AWS Elastic Beanstalk using configuration files (.ebextensions)?
I'm using 64bit Amazon Linux 2017.03 v2.4.0 running PHP 7.0.16
I've tried several ways as follow:
1st Way
I've tried using files
in configuration file but it doesn't work, the configuration filename is phpini.config
in .ebextensions
directory with below setup:
files:
"/etc/php.d/phpimap.ini":
mode: "000755"
owner: root
group: root
content: |
extension=imap.so
The additional .ini
files parsed into phpinfo()
by displaying /etc/php-7.0.d/phpimap.ini
but the IMAP won't installed.
2nd Way
Using container_command
to install php-imap but i'm getting error.
container_commands:
install_php_imap:
command: yum install php55-imap
3rd Way
Using combined commands
& files
, it is only success installing IMAP and the dependencies (php common) but it doesn't activate the IMAP
a. Create installdependencies.config in my .ebextensions by adding bellow script:
commands:
install_phpcommon:
test: '[ ! -f /etc/php.d/curl.ini ] && echo "php common not installed"'
command:
yum -y install https://archipelagointernational.s3.amazonaws.com/libs/php70w-common-7.0.16-1.w6.x86_64.rpm
b. Create phpini.config in my .ebextensions by adding bellow script:
commands:
install_phpimap:
test: '[ ! -f /etc/php.d/imap.ini ] && echo "php imap not installed"'
command:
yum -y install https://archipelagointernational.s3.amazonaws.com/libs/php70w-imap-7.0.16-1.w6.x86_64.rpm
files:
"/etc/php.d/imap.ini":
mode: "000755"
owner: root
group: root
content: |
extension=imap.so
4th Way I'm testing by adding upload_max_filesize
, post_max_size
and extension=imap.so
to zzzphp.ini
and only two values are included that are upload_max_filesize
and post_max_size
. The extension=imap.so
not included into zzzphp.ini
file.
Below are the script phpini.config
in .ebextensions
:
commands:
install_phpimap:
test: '[ ! -f /etc/php.d/imap.ini ] && echo "php imap not installed"'
command:
yum -y install https://archipelagointernational.s3.amazonaws.com/libs/php70w-imap-7.0.16-1.w6.x86_64.rpm
files:
"/etc/php.d/zzzphp.ini":
mode: "644"
content: |
upload_max_filesize = 50M
post_max_size = 58M
extension=imap.so
Any suggestions?
Thanks in advance.
I followed all of the suggestions here but my commands kept on failing because my composer required imap support and the container commands are run after... Here's what worked for me:
This works for me, using ebextensions too (I'm running a container with PHP 7.2, it should work for your environment, replace accordly):
You’re including the php-imap extension in php’s configuration file, but that’s not sufficient to install it.
You’re going to have to pass something to your EBS provisioning method of choice telling it to install php-imap (or whatever it’s called in that environment) at the system level.
For me, below code in phpini.config solved the issue. Please notice the folder names as per php version. My php version is 7.2 hence below code works:
Finally it's work
Create two files inside .ebextensions as follow:
installdependencies.config, install php common if it is required
phpini.config, install php imap and enable imap