if they work in /var/www, then your php installation works.
running a php file from command line is done easily through
Code:
~%> php myscript.php
that of course won't show you html stuff. it's quite useful as a scripting tool however for many tasks.
read through the comments in php.ini. Granted, the php.ini since 5.3. has gotten bigger, but mostly because they added some more comments. Keep in mind, you do not edit this file for the locations where PHP will work by accessing the files through your apache server.
You need to set up apache config files for that.
Have a look at
/etc/apache2/sites-available
In it should be at least one file, named
default
which contains a Virtualhost.
In short:
copy the file, adjust the "DocumentRoot" in it, symlink the file to /etc/apache2/sites-enabled, restart/reload apache2
In long:
copy the file, check if you need the Directory settings in it, remove all unnecessary stuff (e.g. the cgi-bin, /usr/share/doc), set up the Log files (mostly just rename it from access.log and error.log to something else,specific for this virtualhost, to keep it separate from the other log entries of other virtualhosts)
Adjust the DocumentRoot to the path where you want to have php working through apache2.
Put some thought into this, set up a structure where you want all your web sites to be. Usually
/var/www is good enough, but of course you can also set up
/var/development, or /home/myuser/myphpstuff/
Further, you can also include php files in your scripts which aren't in the document root, e.g. following:
your docroot is /home/myuser/myphpstuff
your site is running via /home/myuser/myphpstuff/website2
using php's include/require functions, you can include files from, say,
/home/myuser/someotherscripts/script1/lib/