Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where do I put my Hello world PHP file on Ubuntu?

Tags:

php

apache

So I want to learn PHP, and I've installed it with "sudo apt-get install php5" on my Ubuntu 14.04 machine. I see it also installed Apache.

Now I've created my program, and I've saved it to a php file.

 <?php echo '<p>Hello World</p>'; ?> 

I know that I need to use something like http://localhost/myfile.php, but where do I put the file, so Apache will see it?

like image 216
sashoalm Avatar asked May 23 '14 09:05

sashoalm


People also ask

Where should I place my php file?

If your server supports PHP, then you do not need to do anything. Just create your . php files, put them in your web directory and the server will automatically parse them for you. There is no need to compile anything nor do you need to install any extra tools.


1 Answers

Pick a name for it lets use hello.php for this example.

On Ubuntu the folder is /var/www/html, NOT /var/www. You will need root access for that. So you save the file as /var/www/html/hello.php.

Open up a web browser and enter the following address:

localhost/hello.php

And BAM. There's you page.

like image 118
Fluffeh Avatar answered Oct 25 '22 22:10

Fluffeh