【发布时间】:2020-08-14 04:46:03
【问题描述】:
我已经启动了一个 EC2 实例。在用户数据中,我有以下脚本,但我的 javascript 无法运行。我只看到文字。我应该怎么办?我在本地运行它并在我的浏览器中按预期工作。
#!/bin/bash
# get admin privileges
sudo su
# install httpd (Linux 2 version)
yum update -y
yum install -y httpd.x86_64
systemctl start httpd.service
systemctl enable httpd.service
echo "<body>
Text here
<br>
<p id="quote"></p>
<script>
var affirmArray = [
"text here",
"text here",
"text here",
"text here"
];
var rand = Math.floor(Math.random() * affirmArray.length);
function showquote(){
document.getElementById("quote").innerHTML = affirmArray[rand];
}
showquote();
</script>
</body>" > /var/www/html/index.html
【问题讨论】:
标签: amazon-web-services apache amazon-ec2