Can and Can't install php7.4 on Amazon Linux 2 with user-data
I'm trying to install wordpress(latest version) with php7.4 on Amazon linux 2 by using following user-data.
#!/bin/bash
yum update -y
amazon-linux-extras enable php7.4
yum clean metadata
yum install -y httpd mysql php php-{pear,cgi,common,curl,mbstring,gd,mysqlnd,gettext,bcmath,json,xml,fpm,intl,zip,imap,devel}
wget http://wordpress.org/latest.tar.gz -P /tmp/
tar zxvf /tmp/latest.tar.gz -C /tmp
cp -r /tmp/wordpress/* /var/www/html/
chown apache:apache -R /var/www/html
systemctl enable httpd.service
systemctl start httpd.service
However, I got issue about php7.4 installation.
Some EC2 instances can't enable amzn2extra-php7.4 repo, then use amzn2-core.
php 5.4 will be installed.
================================================================================
Dec 24 17:42:04 ip-10-0-0-43 cloud-init: Package Arch Version Repository Size
Dec 24 17:42:04 ip-10-0-0-43 cloud-init: ================================================================================
Dec 24 17:42:04 ip-10-0-0-43 cloud-init: Installing:
~~
Dec 24 17:42:04 ip-10-0-0-43 cloud-init: php x86_64 5.4.16-46.amzn2.0.2 amzn2-core 1.4 M
Dec 24 17:42:04 ip-10-0-0-43 cloud-init: php-bcmath x86_64 5.4.16-46.amzn2.0.2 amzn2-core 58 k
Dec 24 17:42:04 ip-10-0-0-43 cloud-init: php-cli x86_64 5.4.16-46.amzn2.0.2 amzn2-core 2.8 M
Dec 24 17:42:04 ip-10-0-0-43 cloud-init: php-common x86_64 5.4.16-46.amzn2.0.2 amzn2-core 563 k
Dec 24 17:42:04 ip-10-0-0-43 cloud-init: php-devel x86_64 5.4.16-46.amzn2.0.2 amzn2-core 602 k
Dec 24 17:42:04 ip-10-0-0-43 cloud-init: php-fpm x86_64 5.4.16-46.amzn2.0.2 amzn2-core 1.4 M
Dec 24 17:42:04 ip-10-0-0-43 cloud-init: php-gd x86_64 5.4.16-46.amzn2.0.2 amzn2-core 127 k
Dec 24 17:42:04 ip-10-0-0-43 cloud-init: php-intl x86_64 5.4.16-46.amzn2.0.2 amzn2-core 98 k
Dec 24 17:42:04 ip-10-0-0-43 cloud-init: php-mbstring x86_64 5.4.16-46.amzn2.0.2 amzn2-core 505 k
Dec 24 17:42:04 ip-10-0-0-43 cloud-init: php-mysqlnd x86_64 5.4.16-46.amzn2.0.2 amzn2-core 172 k
Dec 24 17:42:04 ip-10-0-0-43 cloud-init: php-pear noarch 1:1.10.12-9.amzn2 amzn2-core 359 k
Dec 24 17:42:04 ip-10-0-0-43 cloud-init: php-xml x86_64 5.4.16-46.amzn2.0.2 amzn2-core 125 k
~~
~~~
[root@ip-10-0-0-43 ~]# php -v
PHP 5.4.16 (cli) (built: Oct 31 2019 18:34:05)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
Some EC2 instances can enable amzn2extra-php7.4 repo,
php 7.4 will be installed.
Dec 24 17:42:07 ip-10-0-0-147 cloud-init: ================================================================================
Dec 24 17:42:07 ip-10-0-0-147 cloud-init: Package Arch Version Repository Size
Dec 24 17:42:07 ip-10-0-0-147 cloud-init: ================================================================================
Dec 24 17:42:07 ip-10-0-0-147 cloud-init: Installing:
~
Dec 24 17:42:07 ip-10-0-0-147 cloud-init: php x86_64 7.4.21-1.amzn2 amzn2extra-php7.4 3.2 M
Dec 24 17:42:07 ip-10-0-0-147 cloud-init: php-bcmath x86_64 7.4.21-1.amzn2 amzn2extra-php7.4 68 k
Dec 24 17:42:07 ip-10-0-0-147 cloud-init: php-cli x86_64 7.4.21-1.amzn2 amzn2extra-php7.4 4.9 M
Dec 24 17:42:08 ip-10-0-0-147 cloud-init: php-common x86_64 7.4.21-1.amzn2 amzn2extra-php7.4 1.1 M
Dec 24 17:42:08 ip-10-0-0-147 cloud-init: php-devel x86_64 7.4.21-1.amzn2 amzn2extra-php7.4 1.3 M
Dec 24 17:42:08 ip-10-0-0-147 cloud-init: php-fpm x86_64 7.4.21-1.amzn2 amzn2extra-php7.4 1.7 M
Dec 24 17:42:08 ip-10-0-0-147 cloud-init: php-gd x86_64 7.4.21-1.amzn2 amzn2extra-php7.4 182 k
Dec 24 17:42:08 ip-10-0-0-147 cloud-init: php-intl x86_64 7.4.21-1.amzn2 amzn2extra-php7.4 220 k
Dec 24 17:42:08 ip-10-0-0-147 cloud-init: php-json x86_64 7.4.21-1.amzn2 amzn2extra-php7.4 71 k
Dec 24 17:42:08 ip-10-0-0-147 cloud-init: php-mbstring x86_64 7.4.21-1.amzn2 amzn2extra-php7.4 514 k
Dec 24 17:42:08 ip-10-0-0-147 cloud-init: php-mysqlnd x86_64 7.4.21-1.amzn2 amzn2extra-php7.4 241 k
Dec 24 17:42:08 ip-10-0-0-147 cloud-init: php-pear noarch 1:1.10.12-9.amzn2 amzn2-core 359 k
Dec 24 17:42:08 ip-10-0-0-147 cloud-init: php-xml x86_64 7.4.21-1.amzn2 amzn2extra-php7.4 199 k
~~
[root@ip-10-0-0-147 ~]# php -v
PHP 7.4.21 (cli) (built: Jul 7 2021 17:35:08) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
I launched 10 EC2 instances with the "same" configuration as test.
7x EC2 instances: php5.4 was installed
3x EC2 instances: php7.4 was installed
I'm using default Amazon linux AMI (Amazon Linux 2 AMI (HVM) - Kernel 5.10, SSD Volume Type )
ami-0218d08a1f9dac831 ( region: ap-northeast-1)
I have no idea why this happens..
- 最新
- 最多得票
- 最多評論
Have you checked the logs? If your script did not accomplish the tasks you were expecting it to, or if you just want to verify that your script completed without errors, examine the cloud-init output log file at /var/log/cloud-init-output.log and look for error messages in the output.
相關內容
- 已提問 7 個月前lg...
- 已提問 1 年前lg...
- 已提問 7 個月前lg...
- 已提問 1 年前lg...
- AWS 官方已更新 5 個月前
- AWS 官方已更新 10 個月前