-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathec2-commands.txt
61 lines (55 loc) · 2.66 KB
/
ec2-commands.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#--------------------------------------------------------------------
# Update packages and install needed compilation dependencies
#--------------------------------------------------------------------
sudo yum update -y
sudo yum install autoconf bison gcc gcc-c++ libcurl-devel libxml2-devel -y
#--------------------------------------------------------------------
# Compile OpenSSL v1.0.1 from source, as Amazon Linux uses a newer version than the Lambda Execution Environment.
# Which would otherwise produce an incompatible binary.
#--------------------------------------------------------------------
curl -sL http://www.openssl.org/source/openssl-1.0.1k.tar.gz | tar -xvz
cd openssl-1.0.1k
./config && make && sudo make install
cd ~
#--------------------------------------------------------------------
# Download the PHP 7.3.0 source and compile the binary
#--------------------------------------------------------------------
mkdir ~/php-7-bin
curl -sL https://github.com/php/php-src/archive/php-7.3.0.tar.gz | tar -xvz
cd php-src-php-7.3.0
# Compile PHP 7.3.0 with OpenSSL 1.0.1 support, and install to /home/ec2-user/php-7-bin
./buildconf --force
./configure --prefix=/home/ec2-user/php-7-bin/ --with-openssl=/usr/local/ssl --with-curl --with-zlib
make install
#--------------------------------------------------------------------
# Preparing to write some code
#--------------------------------------------------------------------
mkdir -p ~/php-example/{bin,src}/
cd ~/php-example
touch ./src/{hello,goodbye}.php
touch ./bootstrap && chmod +x ./bootstrap
cp ~/php-7-bin/bin/php ./bin
#--------------------------------------------------------------------
# This will leave you with the following structure
#--------------------------------------------------------------------
#/home/ec2-user/php-example/
#+-- bin/
#| +-- php*
#|-- bootstrap*
#+-- src/
# +-- goodbye.php
# +-- hello.php
#
#2 directories, 4 files
#--------------------------------------------------------------------
# Lambda environment's responsibility will be limited to simply starting and shutting down our custom runtime API.
# It's up to us to define what is actually going to happen in the Lambda environment once that runtime API starts up.
# The bootstrap script will be what handles these Init and Invoke phases.
# Implementing the custom runtime API will involve making a number of HTTP requests and parsing response headers
#--------------------------------------------------------------------
# Installing some PHP Vendors
# - Composer
# - Guzzle
#--------------------------------------------------------------------
curl -sS https://getcomposer.org/installer | ./bin/php
./bin/php composer.phar require guzzlehttp/guzzle