linux - 未在 Linux EC2 实例启动上运行的命令
问题描述
我有一个 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 bad gateway 状态代码,然后我 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
推荐阅读
- swift - 如何在 Flutter iOS Native 代码(Swift)中使用多个 EventChannel
- python - 有效地将图块保存到 bigtiff 图像
- python - 使用 Python 为 word 文档添加水印
- expo - React Native Web中视口上固定位置的元素?
- tinymce - 在编辑器中显示 TinyMCE 代码插件,而不是在弹出窗口中
- javascript - 如何重用来自第 3 方 @types 模块的 TypeScript 联合类型?
- c++ - 我的 c++ 程序编译正常,但没有运行 . 我的程序正在运行并停止了一段时间。没有错误显示
- javascript - 未捕获的类型错误:无法设置 null [Chrome 扩展程序] 的属性“onclick”
- c# - 无法在 .net 核心中实例化实现类型
- java - 我怎样才能使.txt文件中“,”之后的所有内容都将被单独检查:)?