I am trying to use shell_exec to run a node app like that:
shell_exec(node app.js) ;
But I got an error:
sh: node: command not found
I have tried to install node js using confing file like that:
commands:
01_node_install:
# run this command from /tmp directory
cwd: /tmp
# don't run the command if node is already installed (file /usr/bin/node exists)
test: '[ ! -f /usr/bin/node ] && echo "node not installed"'
# install from epel repository
# flag -y for no-interaction installation
command: 'yum install -y nodejs --enablerepo=epel'
This was all of my env.config file but I don't see anything in the Elastic Beanstalk log related to that and the problem still exists.
How could I use Node JS from php environment !!
Your configuration file is fine. Just make sure that env.config is inside .ebextensions folder in the root directory of your project.
Related
I'm using docker
and This my Dockerfile contains:
FROM nginx:latest
RUN apt-get update && apt-get install -y \
php \
php-fpm \
nano
so as you see, we use nginx's latest version image and then run some of these bash command which you can see.
base on these configuration I'm trying to execute a php file to show phpinfo()
so I create a file in /usr/share/nginx/html called index.php
and when I try to use index.php like this http://localhost:8000/index.php, the php file start downloading immediately.
What should I do?
I know that this is a possible duplicate but I've tried something like this link:
Nginx - Downloading PHP instead of executing
but nothing well happened.
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
Error as image below:
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.
Finally it's work
Create two files inside .ebextensions as follow:
installdependencies.config, install php common if it is required
commands:
01_install_phpcommon:
command:
sudo yum -y install php70-common
phpini.config, install php imap and enable imap
commands:
02_install_phpimap:
command:
sudo yum -y install php70-imap
files:
"/etc/php.d/zzzphp.ini":
mode: "644"
content: |
extension=imap.so
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:
commands:
install_phpimap:
test: '[ ! -f /etc/php-7.2.d/imap.ini ] && echo "php imap not installed"'
command:
sudo yum -y install php72-imap
files:
"/etc/php-7.2.d/imap.ini":
mode: "000755"
owner: root
group: root
content: |
extension=imap.so
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.
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:
packages:
yum:
php72-imap.x86_64: []
This works for me, using ebextensions too (I'm running a container with PHP 7.2, it should work for your environment, replace accordly):
packages:
yum:
php72-imap: []
I've been unable to add the MailParse PHP extension (https://pecl.php.net/package/mailparse) to an instance of Elastic Beanstalk running PHP 7. My goal is to get it added into the boot sequence so that it's always installed when an instance is created.
My problem is that Amazon's version of Linux for EB doesn't offer PECL, so I am unsure how to get it loaded.
I've tried to adapt various approaches for installing other php extenions/modules, but haven't had any success.
https://packagist.org/packages/php-mime-mail-parser/php-mime-mail-parser - I tried including this via my composer.json file, but it failed because "ext-mailparse" wasn't installed.
http://wiki.cerbweb.com/Installing_PHP_Mailparse_Ubuntu - I tried running these commands to install the extension, but the first command to install the dependencies failed.
https://serverpilot.io/community/articles/how-to-install-the-php-mailparse-extension.html - "sudo: apt-get: command not found"
I have a feeling there is an easier way to get this done but I'm stuck. Can anyone help?
Create two files:
.ebextensions/01mailparse.config
commands:
01install_mailparse:
command: "pecl7 install --force mailparse"
Note the use of the --force flag. I added this since sometimes AWS EB automatically re-deploys the app in a way that PECL fails if it find the extension being already installed.
.ebextensions/02prioritize.config
commands:
01change_mailparse_load_priority:
command: "sed '/extension=\"mailparse.so\"/d' /etc/php.ini > /etc/php.ini && echo 'extension=\"mailparse.so\"' > /etc/php-7.0.d/zz_mailparse.ini"
This removes the mailparse extension registration from the php.ini file (PECL was adding the line at the top, weird) and registers it to be loaded at the end of the list (zz prefix).
Note that I used two files. For some reason, using two commands on the same file was making the deploy file. I'd appreciate if someone could clarify this.
To add to #Mauro's answer the following allows you to install mailparse and remove the extension from /etc/php.ini in a single file.
.ebextensions/01_mailparse.config (PHP 7.x)
commands:
01_mailparse_install:
command: |
pecl7 install --force mailparse
sed -i '/extension="mailparse.so"/d' /etc/php.ini
files:
"/etc/php.d/mailparse.ini":
mode: "000644"
owner: root
group: root
content: |
extension="mailparse.so"
.ebextensions/01_mailparse.config (PHP 5.6)
commands:
01_mailparse_install:
command: |
pecl install --force mailparse-2.1.6
sed -i '/extension="mailparse.so"/d' /etc/php.ini
files:
"/etc/php.d/mailparse.ini":
mode: "000644"
owner: root
group: root
content: |
extension="mailparse.so"
The | allows multi line values. I modified the sed command and added the files block to allow it to work on multiple PHP versions without much change.
I bumped into this bit of instructions while installing an addon for a PHP framework:
Make sure you don't have the PHP module installed. This is a Debian/Ubuntu example:
sudo apt-get purge php5-geoip
I am working on Windows PC with a Virtual Machine running Laravel Homsetead. I am using Git Bash command window. When I enter the above command I get:
bash: sudo: command not found
If I remember correctly, sudo is an Apple-related command so I tried dropping it like this:
apt-get purge php5-geoip
but I get
bash: apt-get: command not found
What command do I need to use to purge php5-geoip?
EDIT: echo $PATH gives out:
$ echo $PATH
/c/Users/Arthur/bin:/mingw64/bin:/usr/local/bin:/usr/bin:/bin:/mingw64/bin:/usr/
bin:/c/Users/Arthur/bin:/c/ProgramData/Oracle/Java/javapath:/c/Windows/system32:
/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0:/
c/Program Files (x86)/Intel/OpenCL SDK/2.0/bin/x86:/c/Program Files (x86)/Intel/
OpenCL SDK/2.0/bin/x64:/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/c
/Program Files/MATLAB/MATLAB Production Server/R2015a/runtime/win64:/c/Program F
iles/MATLAB/MATLAB Production Server/R2015a/bin:/c/Program Files/MATLAB/MATLAB P
roduction Server/R2015a/polyspace/bin:/c/Program Files (x86)/Skype/Phone:/c/PHP:
/c/ProgramData/ComposerSetup/bin:/c/Users/Arthur/AppData/Roaming/Composer/vendor
/bin:/c/HashiCorp/Vagrant/bin:/c/Program Files/nodejs:/c/Users/Arthur/AppData/Ro
aming/npm:/usr/bin/vendor_perl:/usr/bin/core_perl
I am trying to configure my AWS Elastic Beanstalk to work with mongo, all I need to do is install the mongo driver for PHP and update the php.ini file
To do this, usually I would ssh into the EC2 and run:
sudo pecl install mongo
But this would require using a custom AMI which isnt the best way to go.
It is better to use config files to install the software required onto the standard AMI.
So to do this, I have done the following:
created directory .ebextensions
created file mongo.config
in it I have put the following:
packages:
pecl: install mongo
However upon deployment, I get the following error:
"option_settings" in one of the configuration files failed validation. More details to follow.
and
'null' values are not allowed in templates
So I am wondering how this config file needs to be laid out in order to install the mongo extension?
I have read the info here: http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html
but I am not quite understanding how to do this specific task
Help would be appreciated , thanks! :)
pecl is not a valid package manager on Amazon Linux and therefore cannot be used under the packages key of an .ebextensions config.
To install a PECL package it is enough to add a single command under the commands key. To avoid that Beanstalk tries to install the extension twice on follow-up deployments add a PHP console command to the test key that checks if the extension is already installed:
commands:
install_mongo_driver:
command: pecl install mongo
test: "php -r \"exit(extension_loaded('mongo') ? 1 : 0);\""
If the test result is true, i.e. exit(0), then the command gets executed - otherwise not. Please note that a exit code of 0 means "No errors" in a shell context.
See also the description at http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html#customize-containers-format-commands.
I have figured it out and thought I would share what I found. Thanks to Hudku (http://blog.hudku.com/2013/02/innocuous-looking-evil-devil.html#elastic-beanstalk.config) for the excellent article:
1) Create myapp.config
2) enter the following into it
packages:
yum:
dos2unix: []
container_commands:
01-command:
command: rm -rf /myapp/ebextensions
02-command:
command: mkdir -p /myapp/ebextensions
03-command:
command: cp -R .ebextensions/* /myapp/ebextensions/
04-command:
command: dos2unix -k /myapp/ebextensions/mongo.sh
05-command:
command: chmod 700 /myapp/ebextensions/mongo.sh
06-command:
command: bash /myapp/ebextensions/mongo.sh
Then create mongo.sh file and put in it something like:
#!/bin/bash
if [ ! -f /mongostatus.txt ];
then
pecl install mongo
echo "mongo extension installed" > /mongostatus.txt
apachectl restart
fi
This will install mongo php extension and restart apache so the install takes affect.
I just accomplished the same thing thanks to the answer above, and figured out it can be done with less lines and less files for those interested...
# ~/project/.ebextensions/project.config
# Logger messages can be viewed in /var/log/messages
files:
"/tmp/test.sh":
content: |
# This file will be created and can then
# be executed by a command call below.
logger TEST FILE CALLED
commands:
01-command:
command: logger CALLING TEST FILE; sh /tmp/test.sh;