Ramratan Gupta
Ramratan Gupta

Reputation: 1086

How to install PHP 7.1 on EC2 running on Amazon Linux AMI 2018.03 having nginx as web server?

How to install PHP 7.1 on Amazon EC2 t2.micro Instance running Amazon Linux AMI 2018.03 having nginx as web server?

Reference to PHP7

Upvotes: 6

Views: 23159

Answers (3)

Ritesh Aryal
Ritesh Aryal

Reputation: 843

A reliable way to achieve the same output is by following commands on Amazon Linux AMI 2.

# Remove current php & apache
sudo service httpd stop
sudo yum remove httpd* php*

sudo yum install httpd

amazon-linux-extras install php7.1

Upvotes: 6

Ramratan Gupta
Ramratan Gupta

Reputation: 1086

I followed below steps to install PHP7.1 which had already Nginx as web server for Amazon Linux AMI 2018.03

#Remove Old PHP
yum remove php*

#Update Reposistory
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm

#Update Amazon AMI
yum upgrade -y

#Install PHP
#List of PHP packages https://webtatic.com/packages/php71/

yum install php71w php71w-cli  php71w-fpm
yum install php71w-mysql php71w-xml php71w-curl
yum install php71w-opcache php71w-pdo php71w-gd
yum install php71w-pecl-apcu php71w-mbstring php71w-imap
yum install php71w-pecl-redis php71w-mcrypt

#change listen mode to CGI
sed -i 's/127.0.0.1:9000/\/tmp\/php5-fpm.sock/g' /etc/php-fpm.d/www.conf

/etc/init.d/php-fpm restart
touch /tmp/php5-fpm.sock
chmod 777 /tmp/php5-fpm.sock
service nginx restart

The reason I am still using /tmp/php5-fpm.sock file so that I do not need to change PHP7 sock file in all website nginx conf and assuming server do not have PHP5 as as on first step it has been removed.

Upvotes: 8

Arun Basil Lal
Arun Basil Lal

Reputation: 481

With reference to this answer, change Step 1 to the following:

1. Install Apache 2.4 and PHP 7.1 on Amazon Linux AMI

# Remove current apache & php 
sudo yum remove httpd* php*

# Install Apache 2.4
sudo yum install httpd24

# Install PHP 7.1
sudo yum install php71

# Install additional commonly used php packages
sudo yum install php71-gd
sudo yum install php71-imap
sudo yum install php71-mbstring
sudo yum install php71-mysqlnd
sudo yum install php71-opcache
sudo yum install php71-pdo
sudo yum install php71-pecl-apcu

Basically replacing php70 with php71.

Continue with step 2 and the rest as per the original tutorial.

Upvotes: 19

Related Questions