tags:

views:

102

answers:

4

Hi, I just installed PHP on my computer (Ubuntu). If I create a test.php file with simple code and then run "php test.php", it works fine (I get what I expect). However, if I open this file (test.php) with my browser (Mozilla) it ask me how to open this file. Not a problem. I click "open with" and then I select "/usr/bin/php" and... nothing happen. Browser does not display anything.

Can anybody help me with that? Why my browser cannot display a local php-file using a local php server?

+8  A: 

You need to install a web server (apache, lighttpd, ngnix etc.) on your machine, then make sure the server is setup to process php files through the php interpreter. After you have done all that, copy the php files to your server web root directory and access them through the browser.

code_burgar
OK. I did everything except the last step. I do not know where is "my server web root directory".
Verrtex
I thing it is /var/www.
Verrtex
+2  A: 

XAMPP is probably the easiest way to get a development environment up and running.

Here is forum article on getting it running on Ubuntu.

Matthew Vines
I would not advice XAMPP. Just apache with the mod_php will do.
milovanderlinden
Ubuntu tasksel will pull all the correct packages and configure them to work together. It's kind of like XAMPP but plays nicely with the package manager. :)
joemoe
A: 

Vertex

PHP through a browser will only work if you have php running as a webserver module (cgi, fcgi)

If you are on a regular linux distro you can probably apt-get emerge or zypper apache2 and the mod_php module from a repository. If you want to build from source, here is an small howto: apache2php

milovanderlinden
+1  A: 

Do you have a web server installed also?

This will install a full LAMP stack on Ubuntu.

sudo tasksel install lamp-server

But keep in mind this will launch Apache and MySQL daemons in the background. To disable when you are not developing: sudo /etc/init.d/apache stop; sudo /etc/init.d/mysql stop

When you are: sudo /etc/init.d/apache start; sudo /etc/init.d/mysql start

You can make a macro in your favorite IDE to do this automatically.

Removing it is as easy as:

sudo tasksel remove lamp-server

joemoe