LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Apache downloads php file instead of running script (https://www.linuxquestions.org/questions/linux-server-73/apache-downloads-php-file-instead-of-running-script-807606/)

cov 05-13-2010 10:28 AM

Apache downloads php file instead of running script
 
I trashed my Karmic Ubuntu install and installed Lucid (I had heard that the boot times were much reduced and I didn't see any improvement in my normal upgrade).

I reinstalled Drupal but find that my installation of Apache does not run the scripts, but rather passes the php text file to the browser.

IIRC when I installed it apt configured Apache correctly without me having to edit .htaccess or /etc/apache2/httpd.conf which makes me think that I am missing a key dependency.

Does anyone know of a check list to which I can refer to make sure that I've installed everything?

My installation has Postgres instead of MySQL.

Failing which, in the event that my memory is faulty, where can I find which changes need to be applied to the configuration files above?

tronayne 05-13-2010 11:15 AM

There are, usually, two reasons that PHP won't run in Apache -- PHP is not being loaded or index.php is missing.

PHP gets loaded by, down toward the bottom of httpd.conf
Code:

# Uncomment the following line to enable PHP:
#
Include /etc/httpd/mod_php.conf

or you may need (in httpd.conf)
Code:

#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
<IfModule dir_module>
    DirectoryIndex index.html index.php
</IfModule>

And a third reason may be that PHP is not installed at all?

Hope this helps some -- and don't forget to stop and restart httpd if you change anything in httpd.conf.

cov 05-13-2010 11:27 AM

Quote:

Originally Posted by tronayne (Post 3967158)
There are, usually, two reasons that PHP won't run in Apache -- PHP is not being loaded or index.php is missing.

PHP gets loaded by, down toward the bottom of httpd.conf
Code:

# Uncomment the following line to enable PHP:
#
Include /etc/httpd/mod_php.conf

or you may need (in httpd.conf)
Code:

#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
<IfModule dir_module>
    DirectoryIndex index.html index.php
</IfModule>

And a third reason may be that PHP is not installed at all?

Hope this helps some -- and don't forget to stop and restart httpd if you change anything in httpd.conf.

???

My /etc/apache2/httpd.conf file is EMPTY!

Moreover there is no /etc/httpd/ directory.

So the installation is borked. Reinstall apache?

space_mokey 05-13-2010 02:30 PM

selinux
 
I was having a similar problem on a centos server a while back, It turned out to be selinux, I set it to passive and worked like a charm.

tronayne 05-13-2010 04:33 PM

Quote:

My /etc/apache2/httpd.conf file is EMPTY!

Moreover there is no /etc/httpd/ directory.

So the installation is borked. Reinstall apache?
Uh, OK, do you have httpd.conf somewhere else? Or do you have a "httpd.whatever" that is to be copied to httpd.conf and edited (possibly in /etc/apache2)?

Sometimes your mileage may vary -- looks like your installation is in /etc/apache2 rather than /etc/httpd. There ought to be an httpd.something-or-other file that you're supposed to copy into httpd.conf and edit. There also ought to be a php.ini (or php.ini-recommended or php.ini-dist) sitting in there (or someplace else?) for you to edit (you want to wind up with php.ini and include that in your httpd.conf) and the same for php_mod.conf).

Seems like most distributions install stuff where it ought to be and yours may just have used apache2; files and methods are the same, however.

Hope this helps some.


All times are GMT -5. The time now is 01:51 PM.