gpt4 book ai didi

linux - 命令未在 Linux EC2 实例启动时运行

转载 作者:太空宇宙 更新时间:2023-11-04 12:02:21 34 4
gpt4 key购买 nike

我有一个 AWS EC2 Linux 实例,其中用户数据设置如下:

#!/bin/bash
yum update -y
yum group mark install -y "Web Server" "MySQL Database" "PHP Support"
service httpd start
chkconfig httpd on
groupadd www
usermod -a -G www ec2-user
usermod -a -G apache ec2-user
chown -R root:www /var/www
chown -R ec2-user:apache /var/www
chmod 2775 /var/www
find /var/www -type d -exec chmod 2775 {} \;
find /var/www -type f -exec chmod 0664 {} \;

期望的目标是在通过负载均衡器调用实例时获取 apache 页面,但是当实例启动时,我得到一个 502 错误的网关状态代码,然后我通过 ssh 进入实例并手动运行命令,然后我按预期获取 apache 页面。

我正在关注 linkedlearning aws essential training, 跟随 aws docs ,我还在/var/www/html 添加了一个 index.php。我在手动运行命令时得到了预期的结果,但在使用实例设置用户数据时却没有,我做错了什么或遗漏了什么?

非常感谢您的协助!

最佳答案

我在一个实例上运行了您的用户数据,/var/log/cloud-init-output.log 文件包含:

Marked install: Web Server,MySQL Database,PHP Support
httpd: unrecognized service
error reading information on service httpd: No such file or directory
usermod: group 'apache' does not exist
chown: cannot access ‘/var/www’: No such file or directory
chown: invalid group: ‘ec2-user:apache’
chmod: cannot access ‘/var/www’: No such file or directory
find: `/var/www': No such file or directory
find: `/var/www': No such file or directory
Aug 18 06:38:38 cloud-init[2638]: util.py[WARNING]: Failed running /var/lib/cloud/instance/scripts/part-001 [1]
Aug 18 06:38:38 cloud-init[2638]: cc_scripts_user.py[WARNING]: Failed to run module scripts-user (scripts in /var/lib/cloud/instance/scripts)
Aug 18 06:38:38 cloud-init[2638]: util.py[WARNING]: Running module scripts-user (<module 'cloudinit.config.cc_scripts_user' from '/usr/lib/python2.7/dist-packages/cloudinit/config/cc_scripts_user.pyc'>) failed
Cloud-init v. 0.7.6 finished at Sat, 18 Aug 2018 06:38:38 +0000. Datasource DataSourceEc2. Up 16.54 seconds

关于linux - 命令未在 Linux EC2 实例启动时运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51905753/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com