Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I run apache (Apache/2.2.14 Ubuntu). PHP is not executed. I noticed that the line

AddType application/x-httpd-php .php .html .htm

was missing from /etc/apache2/apache.conf I tried adding the line on several places in the .conf file. Nothing worked.

I tried chown www-data /var/www/ and chmod 777 /var/www (i am new to linux)

I read that you might have to add

AddType application/x-httpd-php .php

to httpd.conf. This also yields no result

I also tried executing this simple code (placed in /var/www/)

<?php
  phpinfo();
?>

Firefox prompts me to save the file instead of executing it.

And yes, I did restart apache every time I made changes.

I am stuck.

edit:

ls - l /var/ gives,

.....
.....
drwxrwxrwx  3 www-data www-data 4096 2011-12-05 14:39 www

Since apache runs in this group, the owner should be www-data, right?

the access log gives me:

127.0.0.1 - - [05/Dec/2011:14:39:58 -0500] "GET /info.php HTTP/1.1" 200 327 "-" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.18) Gecko/20110628 Ubuntu/10.04 (lucid) Firefox/3.6.18"
127.0.0.1 - - [05/Dec/2011:14:45:35 -0500] "GET /info.php HTTP/1.1" 304 187 "-" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.18) Gecko/20110628 Ubuntu/10.04 (lucid) Firefox/3.6.18"
127.0.0.1 - - [05/Dec/2011:14:46:44 -0500] "GET /info.php HTTP/1.1" 304 187 "-" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.18) Gecko/20110628 Ubuntu/10.04 (lucid) Firefox/3.6.18"
127.0.0.1 - - [05/Dec/2011:14:53:26 -0500] "GET /info.php HTTP/1.1" 304 187 "-" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.18) Gecko/20110628 Ubuntu/10.04 (lucid) Firefox/3.6.18"

AND THE ERROR LOG:

[Mon Dec 05 14:25:08 2011] [notice] caught SIGTERM, shutting down
[Mon Dec 05 14:25:09 2011] [notice] Apache/2.2.14 (Ubuntu) configured -- resuming normal operations
[Mon Dec 05 14:27:08 2011] [notice] caught SIGTERM, shutting down
[Mon Dec 05 14:27:09 2011] [notice] Apache/2.2.14 (Ubuntu) configured -- resuming normal operations
[Mon Dec 05 14:35:33 2011] [notice] caught SIGTERM, shutting down
[Mon Dec 05 14:35:34 2011] [notice] Apache/2.2.14 (Ubuntu) configured -- resuming normal operations
[Mon Dec 05 14:35:52 2011] [notice] caught SIGTERM, shutting down
[Mon Dec 05 14:35:53 2011] [notice] Apache/2.2.14 (Ubuntu) configured -- resuming normal operations
[Mon Dec 05 14:45:29 2011] [notice] caught SIGTERM, shutting down
[Mon Dec 05 14:45:30 2011] [notice] Apache/2.2.14 (Ubuntu) configured -- resuming normal operations
[Mon Dec 05 14:46:38 2011] [notice] caught SIGTERM, shutting down
[Mon Dec 05 14:46:39 2011] [notice] Apache/2.2.14 (Ubuntu) configured -- resuming normal operations
[Mon Dec 05 14:54:16 2011] [notice] caught SIGTERM, shutting down
[Mon Dec 05 14:54:17 2011] [notice] Apache/2.2.14 (Ubuntu) configured -- resuming normal operations
share|improve this question
    
What do you get in apache access logs when you access the page? –  Sachin Divekar Dec 5 '11 at 20:07
    
@sachin see my edit please. –  jorrebor Dec 5 '11 at 20:21
add comment

2 Answers

up vote 1 down vote accepted

Did you actually install PHP? Package libapache2-mod-php5? Normally, you should't need to edit any config files to activate PHP when installing this package.

share|improve this answer
    
I guess i did: root@ubuntu:/var/log/apache2# php -v PHP 5.3.2-1ubuntu4.10 with Suhosin-Patch (cli) (built: Oct 15 2011 00:09:58) –  jorrebor Dec 5 '11 at 20:27
    
php5-cli is installed, but that doesn't mean the Apache module from libapache2-mod-php5 is also installed. Please enter the command aptitude show libapache2-mod-php5 and see if the state is installed. –  SvW Dec 5 '11 at 20:49
    
was not installed indeed, installed the package, it works! thanks a bunch! –  jorrebor Dec 5 '11 at 22:02
add comment

Check the error log of apache. Check if you have the LoadModule php5_module modules/libphp5.so or similar in apache configuration. Check that the libphp5.so file exist. Check that libphp5.so is loaded by apache with pmap <apache_worker_PID>|grep php. E.g. run:

ps -edf |grep apache|grep -v root|head -1|awk '{print $2}'|xargs pmap|grep php

You can enable php in apache on Ubuntu with:

sudo a2enmod php5
sudo /etc/init.d/apache2 force-reload

See also: https://help.ubuntu.com/community/ApacheMySQLPHP#Installing_PHP_5

share|improve this answer
    
running this in the terminal gives me: root@ubuntu:/var/log/apache2# pmap <apache_worker_PID>|grep php bash: apache_worker_PID: No such file or directory I tried replaicing apche_worker_PID with the path to apache2 ? i didnt understand pmap program. –  jorrebor Dec 5 '11 at 20:29
    
you have to find a PID (process ID) of an apache worker using ps. E.g. ps -edf|grep apache|grep -v root –  Mircea Vutcovici Dec 5 '11 at 20:37
    
<apache_worker_PID> is a placeholder for the number that is the process identificator of apache worker. To see the processes, PIDs and other information you can use the ps command. pmap shows the how the memory was allocated for a process and will show all dynamic libraries loaded (both those loaded at startup and those loaded during the life of the process). –  Mircea Vutcovici Dec 5 '11 at 20:51
    
Thanks alot, the libapache package was not installed. that fixed it. it all boiled down to the same solution i guess, but thanks for the thorough explaination –  jorrebor Dec 5 '11 at 22:04
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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