fadilxcoder
Posted on December 14, 2019
Hello guys,
On thing that I've noticed when working with AWS cloud9 is that by default, it has PHP 5 installed. My question was what if I want to use PHP 7 for development ?
So in this post, I will explain to you how to setup your PHP 7 environement on AWS.
I am assuming that your AWS settings are as follows :
- Environment type : EC2
- Platform : Amazon Linux
Let's get started.
In your bash terminal on AWS, check your current PHP version,
ec2-user:~/environment $ php -v
Normally you should see,
In order to do these changes, you will need to connect as root, so just type sudo su followed by yum update :
ec2-user:~/environment $ sudo su
[root@ip-172-31-30-164 environment]# yum update
The process might take couple of minutes. Then remove any existing PHP packages.
[root@ip-172-31-30-164 environment]# yum remove php*
Note : If you already have Apache 2.4, you don't need to remove your web server but if you have an older version, then remove it and install Apache 2.4,
[root@ip-172-31-30-164 environment]# yum remove httpd*
[root@ip-172-31-30-164 environment]# yum install httpd24
If everything is working fine till now, you did a great job.
Now it's time to install PHP 7. As you know, there are multiple versions, i.e : php7.0
, php7.1
, php7.2
...
Below are the command for different php version you want to install.
PHP 7.0
[root@ip-172-31-30-164 environment]# yum install php70 php70-mysqlnd php70-imap php70-pecl-memcache php70-pecl-apcu php70-gd
PHP 7.1
[root@ip-172-31-30-164 environment]# yum install php71 php71-mysqlnd php71-imap php71-pecl-memcache php71-pecl-apcu php71-gd
PHP 7.2
[root@ip-172-31-30-164 environment]# yum install php72 php72-mysqlnd php72-imap php72-pecl-memcache php72-pecl-apcu php72-gd
Let's say we want to have PHP 7.2
And here you have it..
You can easily work with PHP 7 on AWS now.
Posted on December 14, 2019
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.