I have PHP5 installed on my CentOS 5 server running Apache 2.2.3 (did a yum install)

I ensured the httpd.conf file has all the necessary AddType and LoadModule commands. Even tried restarting httpd.

But when I run a php file, instead of it being executed, the file just downloads. Any ideas what I might be missing?

I did see the different threads returned by Google. Also tried the solutions posted on other similar SF questions (here and here) but didn't find a resolution. Tried a manual install of php as well. But php files just don't get executed.

More on this

Now I can get the php file to show and not get downloaded. From the httpd.conf, removed the AddType directive and added AddHandler.

On further investigation, if I run a command php -f my_php_file.php on my server, the file executes fine. So php installation is not the issue. But somewhere in the configuration file, the mapping is missing (i.e. execute .php files using php). Any ideas?


  • Logs, config files... all useful information. – womble Jul 15 '11 at 6:25
  • no error logs generated wrt the files. Which files should I post the content of? httpd.conf, any others? – lostInTransit Jul 15 '11 at 8:37

I wild shot in the dark (since you did not tell us the exact yum command(s) you entered):

I guess you installed PHP CGI/CLI version which needs further configuration to actually work, but what you meant to install was Apache mod_php module. Maybe you installed php-cli instead of php?

  • I ran this command - yum install php. This installs both php and the apache php module (doesn't it)? – lostInTransit Jul 15 '11 at 8:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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