首页 > 解决方案 > EC2 用户数据挂在“检查初始化脚本...”ubuntu php

问题描述

我有一个带有用户数据的 EC2 设置,可以在机器上设置 php,因为添加命令来安装 imagick 我的用户数据脚本在我安装 php-dev 包时开始挂起。

我尝试过: - 一个一个地执行软件包安装 - 在新的 Ubuntu 18.04 实例上的终端窗口中逐步运行脚本(我总是成功安装)

我的用户数据:

sudo apt update
sudo apt install -y nginx
sudo apt install -y pkg-config
sudo apt install -y imagemagick
sudo apt install -y php7.2-fpm php-common php-mysql php-pear php-xml php-mbstring php-intl php-curl php-gd php-zip php-json php-simplexml php-dom
sudo apt install -y php-dev
sudo apt install -y php-imagick
sudo apt install -y composer
sudo apt install -y nodejs npm jq

每次我尝试这个时 EC2 的输出

...
[  102.919299] cloud-init[1250]: Unpacking php-dev (1:7.2+60ubuntu1) ...
[  102.949693] cloud-init[1250]: Selecting previously unselected package pkg-php-tools.
[  102.961152] cloud-init[1250]: Preparing to unpack .../29-pkg-php-tools_1.35ubuntu1_all.deb ...
[  102.972353] cloud-init[1250]: Unpacking pkg-php-tools (1.35ubuntu1) ...
[  103.033142] cloud-init[1250]: Setting up libarchive-zip-perl (1.60-1ubuntu0.1) ...
[  103.049041] cloud-init[1250]: Setting up libltdl-dev:amd64 (2.4.6-2) ...
[  103.061142] cloud-init[1250]: Setting up libtimedate-perl (2.3000-2) ...
[  103.074622] cloud-init[1250]: Processing triggers for install-info (6.5.0.dfsg.1-2) ...
[  103.219307] cloud-init[1250]: Setting up shtool (2.0.8-9) ...
[  103.233891] cloud-init[1250]: Setting up libarchive-cpio-perl (0.10-1) ...
[  103.246200] cloud-init[1250]: Setting up m4 (1.4.18-1) ...
[  103.257928] cloud-init[1250]: Setting up libcroco3:amd64 (0.6.12-2) ...
[  103.269881] cloud-init[1250]: Setting up libsys-hostname-long-perl (1.5-1) ...
[  103.283145] cloud-init[1250]: Setting up libmail-sendmail-perl (0.80-1) ...
[  103.295856] cloud-init[1250]: Processing triggers for libc-bin (2.27-3ubuntu1) ...
[  103.312484] cloud-init[1250]: Setting up autotools-dev (20180224.1) ...
[  103.328905] cloud-init[1250]: Setting up libssl1.1:amd64 (1.1.1-1ubuntu2.1~18.04.4) ...
[  103.470751] cloud-init[1250]: Checking for services that may need to be restarted...done.
[  103.495452] cloud-init[1250]: Checking for services that may need to be restarted...done.
[  103.502489] cloud-init[1250]: Checking init scripts...

我发现EC2 `UserData` 执行挂起在 `Checking init scripts...`但该问题的 OP 没有使用任何与我类似的包,也没有回答问题。

标签: phpubuntuamazon-ec2

解决方案


我是您之前提到的那个问题的作者。经过一番折腾,我很确定这取决于您可能正在使用的 AMI。例如,我使用ami-0727f3c2d4b0226d5的是我认为是 的版本Ubuntu 18.04 LTS eu-west-1,尽管我在任何 AMI 搜索中都找不到它。所以按照这个链接 -

https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/finding-an-ami.html

我运行以下命令以获得 Ubuntu 16:04 的“最新”版本-

aws ec2 describe-images --owners 099720109477 --filters 'Name=name,Values=ubuntu/images/hvm-ssd/ubuntu-xenial-16.04-amd64-server-????????' 'Name=state,Values=available' --query 'reverse(sort_by(Images, &CreationDate))[:1].ImageId' --output text

这导致ami-0c224e30f7a997d9f; 当我使用这个新的 AMI 时,我神奇地消失了:-)

您没有确切说明您使用的是什么 AMI,但就我而言,我怀疑我使用的 AMI 版本存在问题;所以我建议你可以尝试不同的 AMI 版本。祝你好运 :-)


推荐阅读