Could I add Python2 to AWS Elastic Beanstalk PHP platform? - php

Now I am trying to upload my PHP app to AWS Elastic Beanstalk with PHP platform.
My PHP executes script.py with Python2,
so I need to install Python2 to Elastic Beanstalk.
What shoud I do at first ?
And where the Python2 would be installed ?

I think you might have to use .ebextensions to install Python2.
Basically, your application source code would need to have a .ebextensions file with a snippet of the following kind:
packages:
yum:
python27-devel.x86_64: []
If you environment's operation system is Amazon Linux, perform yum search python to determine the set of Python2.7 packages you need and then list them under packages/yum in the above file.

Related

How to deploy a dockerized php application

I have a Laravel application and docker setup for local development using docker-compose. My source code for the application is kept in BitBucket and now I would like to deploy the application to a Linode instance and serve it from the docker system. How this can be done ? As of now I have a LAMPP image running in Linode and I push my source code to the corresponding path when deployment is triggered. Now I would like to use the same docker image in the server instead of the LAMPP server I am using. How this can be done ? Or this is the correct method of doing it ?
It will be helpful if someone can point out a tutorial or guide for doing this ?
If you are locked on staying with linode, I would try one of these options:
Linode docker machine driver - note that this is a non official docker machine driver.
Linode containers guide - using Kubernetes, which I usually try to avoid for my small-scale apps.
If you are NOT locked on staying with linode, and you wish to avoid the complexities of Kubernetes, I can tell you I have had success with running a docker machine on Digital Ocean - this solution (as most other docker-machine solutions) makes deployment as easy as running it locally.
List of docker machine drivers
Digital Ocean docker machine guide
As for how to get your code PHP code to the container, here is an example Dockerfile I have been using for one of my PHP dockerized apps:
FROM php:7-apache
# Packages
RUN apt-get -y update && apt-get -y install git zip
RUN a2enmod rewrite && docker-php-ext-install sockets
# App
COPY . .
# Composer
COPY private/composer.phar /usr/local/bin/composer
RUN chmod +x /usr/local/bin/composer
RUN [[ ! -f composer.json ]] || composer install --ansi --no-interaction
You can adjust it to your needs.

How do I setup Bitbucket pipeline for my PHP app on Google Cloud?

I've been trying to get bitbucket pipeline deploy to Google cloud php app. But I keep getting a missing python executable error.Here's the script I have to install Google cloud SDK:
image: php:7.1.3
pipelines:
default:
- step:
caches:
- composer
script:
# Downloading the Google Cloud SDK
- curl -O -J https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-155.0.0-linux-x86_64.tar.gz
- tar -xvf google-cloud-sdk-155.0.0-linux-x86_64.tar.gz -C /tmp/
- /tmp/google-cloud-sdk/install.sh -q
- source /tmp/google-cloud-sdk/path.bash.inc
- gcloud -v
And get's stuck with this error:
To use the Google Cloud SDK, you must have Python installed and on your PATH. As an alternative, you may also set the CLOUDSDK_PYTHON environment variable
to the location of your Python executable.
Any help would be appreciated
You are using a PHP image (Docker image), which obviously does not include Python. Therefore, you either have to find another image which includes PHP and Python, or build one yourself. Building your own can be as simple as what is described in https://stackoverflow.com/a/45963743/4715679

Elastic Beanstalk compile php with ZipArchive enabled

I need to set my PHP project to compile php with ZipArchive enabled. I am running php7 on Elastic Beanstalk and need help on how to write a ".ebextensions" file to accomplish this task. Can someone help me out here?
Thank!
You can create this easily.
1. Create a directory ".ebextensions";
(If MAC, in your terminal run mkdir .ebextensions and cd .ebextensions)
2. Create a file php7zip.config so you have .ebextensions/php7zip.config touch php7zip.config
3. paste this inside the file
packages:
yum:
php70-zip: []
Save the file.
4. Run eb deploy
There you go. You should have the extension install. You can use this same method to install other extensions on Elastic Beanstalk.
Goodluck

Installing FFMpeg in Lumen

I am using Lumen (of Laravel) as my backend and using vagrant. I am want to install and use FFmpeg but I got confused how to install it.
Do I need to install it on my localhost or add it to Lumen? or both?
I found this page but I got lost which commands to run.
Update: I installed this repo on Github and run it in vagrant. I think this installed the latest version on my local server, but what should I do next? How can I install and use FFMpeg with Lumen in php?
Go to your Homestead folder, run vagrant ssh. This will get you into your vagrant machine's terminal. Run command sudo apt-get install ffmpeg there and acknowledge the questions you get asked. (Additional libraries for PHP integration might be required.) FFMpeg will be ready to use.

Installing ElastiCache Cluster Client on PHP AWS Elastic Beanstalk (without creating resource)

Elastic Beanstalk does not, by default, install the ElastiCache Cluster Client PHP module. This is needed to connect to an ElastiCache node cluster. Reading around, most of the instructions relate to creating an ElastiCache resource (which I assume will also install the PHP module on the Elastic Beanstalk). I want to install the PHP module without creating the resource as I want to use an existing cluster.
(64bit Linux PHP5.5)
The module is not installed by default in Beanstalk nor any EC2 instances. You have to do this yourself. This also is something completely different than creating a resource. You can do one without the other.
The ElastiCache Cluster Client for PHP is an extension that you can install via pecl on your instances. You can do this manually but if the instance is ever destroyed you have to do this again. Therefore it is much better to include the extension's install procedure as part of your deployment process. In a beanstalk app you can do this by adding configurations files in your .ebextensions dir.
For example, create these two files. I took these from an actual config file:
#.ebextensions/01fileselasticachephp.config
files:
"/tmp/AmazonElastiCacheClusterClient-latest-PHP54-64bit.tgz" :
mode: "000777"
owner: ec2-user
group: ec2-user
source: http://elasticache-downloads.s3.amazonaws.com/ClusterClient/PHP-5.4/latest-64bit
#.ebextensions/02setupelasticachephp.config
commands:
01install:
command: "pecl install /tmp/AmazonElastiCacheClusterClient-latest-PHP54-64bit.tgz"
The actual name of the files don't matter. They are for your own organization purposes. Anything in that directory with a .config extension will be executed in alphabetical order, that's why you want to prefix your files with a number so that they get executed in the right order: first download the extension and then install it. Mind you that you can also do it all at once in one file. I split it in two because because my actual config files were a lot bigger.
Once you have these files in place do a deployment and the Elastic Cache Cluster Client will be installed.
Note that at the time I deployed this, only the 5.4 client was available that's why my example shows that. I don't know if there is a 5.5 client so it's up to you to find out. You should only need to change the file name and URL to point to the 5.5 extension and should be all set to go.
UPDATE (as of 10/2020)
The solution above didn't work for me with the current software versions, but it definitely pointed me in the right direction. What didn't work was specifically the pecl install command (even using pecl7): it always threw the error "could not extract the package.xml file from [...]" and I couldn't find a solution for it.
So here's the config file that worked for me:
commands:
02-get-file:
command: "wget https://elasticache-downloads.s3.amazonaws.com/ClusterClient/PHP-7.3/latest-64bit"
02-untar:
command: "sudo tar -zxf latest-64bit amazon-elasticache-cluster-client.so"
03-move-file:
command: "sudo mv amazon-elasticache-cluster-client.so /usr/lib64/php/7.3/modules/"
04-create-ini:
command: "grep -qF 'extension=amazon-elasticache-cluster-client.so' /etc/php-7.3.d/50-memcached.ini || echo 'extension=amazon-elasticache-cluster-client.so' | sudo tee --append /etc/php-7.3.d/50-memcached.ini"
05-cleanup:
command: "sudo rm latest-64bit*"
06-restart-apache:
command: "sudo /etc/init.d/httpd restart"
Hope this helps other people!

Categories