如何在EC2上安装PHP 7.1 t2.micro运行具有nginx作为Web服务器的Amazon Linux的实例?

时间:2017-07-13 05:03:22

标签: nginx amazon-ec2 php-7.1

如何在Amazon EC2上安装PHP 7.1 t2.micro运行具有nginx作为Web服务器的Amazon Linux的实例?

Reference to PHP7

3 个答案:

答案 0 :(得分:18)

参考this回答,将步骤1更改为以下内容:

<强> 1。在Amazon Linux AMI上安装Apache 2.4和PHP 7.1

# 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

基本上用php71替换php70。

继续执行第2步,其余按照original tutorial

答案 1 :(得分:5)

我按照以下步骤安装 PHP7.1 已经 Nginx作为网络服务器

#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 install 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
  

我仍然使用/tmp/php5-fpm.sock文件的原因,所以我不需要在所有网站nginx conf中更改PHP7 sock文件,并假设服务器没有像第一步那样删除PHP5它已被删除

答案 2 :(得分:1)

通过以下命令来获得相同输出的可靠方法。

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

sudo yum install httpd

amazon-linux-extras install php7.1