PHP on Linux (Ubuntu 11.04 – Natty Narwhal)

These are some of the codes that helped me getting started in using Apache server on Ubuntu 11.04 (Natty Narwhal)

Finding out the user group

 <?php
// outputs the username that owns the running php/httpd process
// (on a system with the "whoami" executable in the path)
echo exec('whoami');
?> 

(often it is www-data )

source : http://php.net/manual/en/function.exec.php


Check you have the permission. If not change the pormissions for the var/www folder on Linux (in case of a 403 error)

If you make /var/www writeable by its group and add the user to the group, that user will not have to use sudo. Try this:
sudo adduser <username> www-data
sudo chown -R www-data:www-data /var/www
sudo chmod -R g+rw /var/www
The user should then be able to edit /var/www/ files without hassle.

The first line adds the user to the www-data group, the second line clears up any files with messed up ownership, and the third makes it so that all users who are members of the www-data group can read and write all files in /var/www.

source : http://askubuntu.com/questions/19898/whats-the-simplest-way-to-add-files-to-var-www


Location of the Apache error log :

/var/log/apache2/error.log

Quickly access the last few lines of the Apache access log tail -f  /var/log/apache2/error.log

http://php.net/manual/en/function.exec.php
http://php.net/manual/en/function.exec.php