This question already has an answer here:

I installed apache2, php5 and mysql. http://localhost/ url in browser shows it works. I saved a php file in /var/www/ as testphp.php. Code in the file is..


Now on entering http://localhost/testphp.php in browser, it gives this error..

enter image description here

I don't understand why this is happening. Can anyone explain how to work with php? Also please explain how to connect php with mysql server installed on my system.

EDIT : I open the file from terminal in gedit. When I edit some text in the file, these warnings appear in the terminal..

(gedit:28157): Gtk-WARNING **: Calling Inhibit failed: 
GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.gnome.SessionManager was not provided by any .service files

EDIT2 : I saved the file to /var/www/html but still get the error.

marked as duplicate by karel, Byte Commander, Eric Carvalho, Kevin Bowen, TheWanderer Jul 29 '16 at 0:05

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Just save it in /var/www/html – Parto Jun 18 '15 at 8:14
  • @Parto I still get the same error on saving in /var/www/html – vinayawsm Jun 18 '15 at 8:18
  • 1
    Check permissions -> askubuntu.com/questions/19898/… – Parto Jun 18 '15 at 8:29
  • How did you install Apache2 and PHP? – muru Jun 18 '15 at 8:30
  • @muru sudo apt-get install apache2 and sudo apt-get install php5 libapache2-mod-php – vinayawsm Jun 18 '15 at 8:32

The path where php file should be stored should be correct. Store your php file of /var/www/html/yourdirectory/filename.php follow above path and then in the browser type:


Not the answer you're looking for? Browse other questions tagged or ask your own question.