16

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.

I just need Apache PHP

I ran

 sudo yum install apache2
 sudo yum install php

I copied info.php to /var/www/html

info.php only contains

<? phpinfo(); ?>

when i browse to http://www.example.com/info.php Apache 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?

Thanks,

3 Answers 3

15

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

Alternatively try using one of the pre-built AMI's. Community AMI's have several LAMP configurations.

Sign up to request clarification or add additional context in comments.

2 Comments

Using '<?php phpinfo(); ?>' instead of '<? phpinfo(); ?> ' fixed it. Thanks!!
On AWS, installed Apache on Amazon Linux 2, then installed PHP. But PHP didn't work -- just displayed code. Executing this made php work for me: sudo service httpd restart
5

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:

sudo yum install -y php54
sudo yum -y install httpd24

From: Install Apache, PHP, and MySQL on Amazon Linux Install Apache 2.4, PHP 5.4, and MySQL on Amazon Linux

1 Comment

Links have expired
-14

Just tar your info.php;

Upload it to another public directory;

Get the file to ec2 with wget;

Untar the file.

That's it ;)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.