如何在 Amazon EC2 上配置 PHP + Apache?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4011294/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I configure PHP + Apache on Amazon EC2?
提问by Jamey McElveen
I am new to this of course.
我当然是新手。
I am trying to configure PHP and Apache on a new Amazon EC2 AMI. This is a very lightweight server so the Micro instance fits the bill.
我正在尝试在新的 Amazon EC2 AMI 上配置 PHP 和 Apache。这是一个非常轻量级的服务器,因此 Micro 实例符合要求。
I just need Apache PHP
我只需要 Apache PHP
I ran
我跑了
sudo yum install apache2
sudo yum install php
I copied info.php
to /var/www/html
我复制info.php
到/var/www/html
info.php only contains
info.php 只包含
<? phpinfo(); ?>
when i browse to http://www.example.com/info.phpApache serves info.php but it does not render it. I looks like apache is not configured to handle php files. What step or steps am I missing?
当我浏览到http://www.example.com/info.phpApache 提供 info.php 但它不呈现它。我看起来 apache 没有配置为处理 php 文件。我错过了什么步骤?
Thanks,
谢谢,
采纳答案by kieran
First try using full tags, so your script would be.
首先尝试使用完整的标签,这样你的脚本就会是。
<?php phpinfo(); ?>
instead of <? ?>
代替 <? ?>
If no luck, try:
如果没有运气,请尝试:
sudo yum remove php
sudo yum install php
then service httpd restart
然后 service httpd restart
Alternatively try using one of the pre-built AMI's. Community AMI's have several LAMP configurations.
或者尝试使用预先构建的 AMI 之一。社区 AMI 有多种 LAMP 配置。
回答by goodMan
Just for those who get here from Google, try this:
对于那些从谷歌来到这里的人,试试这个:
sudo yum install -y php
sudo yum -y install httpd
If you need development versions:
如果您需要开发版本:
sudo yum install -y php-devel
sudo yum -y install httpd
If you need Apache 2.4 and PHP 5.4:
如果您需要 Apache 2.4 和 PHP 5.4:
sudo yum install -y php54
sudo yum -y install httpd24
From: Install Apache, PHP, and MySQL on Amazon LinuxInstall Apache 2.4, PHP 5.4, and MySQL on Amazon Linux
来自: 在 Amazon Linux 上安装 Apache、PHP 和 MySQL 在 Amazon Linux 上安装 Apache 2.4、PHP 5.4 和 MySQL
回答by nuno-vieira
Just tar your info.php;
只需 tar 你的 info.php;
Upload it to another public directory;
将其上传到另一个公共目录;
Get the file to ec2 with wget;
使用 wget 获取文件到 ec2;
Untar the file.
解压文件。
That's it ;)
就是这样 ;)