-1

NOTE: I'm using apache2 on Linux with PHP 5

Suppose I had this simple hello_world.php file:

<html>
    <head>
        <title>PHP Test</title>
    </head>
    <body>
        <?php echo '<p>Hello World </p>'; ?>
    </body>
</html>

...and I wanted to display it on my apache2 server. How do I do this, and where do I move the source code? Thank you in advance

Cyril F
  • 1,842
  • 2
  • 19
  • 35
sharksfan98
  • 547
  • 3
  • 9
  • 19
  • 3
    Move the file to /var/www, make sure www-data owns it. – Nick ODell Dec 31 '12 at 22:33
  • possible duplicate of [htdocs path in linux](http://stackoverflow.com/questions/1582851/htdocs-path-in-linux) – mario Dec 31 '12 at 22:37
  • The answer depends on where your Apache DocumentRoot resides. If you don;t know what that is, ask your web hosting provider. – Chris Ostmo Dec 31 '12 at 22:39
  • 1
    In addition to what has already been suggested: Fix the missing `; ?>` and `'`'s around `

    Hello World

    `, and ensure that Apache is loading PHP, then you will probably be fine. =)
    – Andreas Hagen Dec 31 '12 at 22:46

1 Answers1

2

You have to move your files in /var/www and make sure Apache is launched.

Run the following command in a terminal : sudo /etc/init.d/apache start

After launch your browser (ex: Chrome) and type "localhost/hello_world.php" in your url adress bar.

Cyril F
  • 1,842
  • 2
  • 19
  • 35