I have recently downloaded and compiled the latest version of PHP on to my server. However, realized I did all of this as root. PHP shows as successfully installed, however php pages do not render, and just display as plain text. Was installing php as root the problem, and if so, do I need to re-install, or is there something I can do?
-
More details please: web server, configuration directives, etc – Joel E Salas Mar 15 '12 at 18:38
-
1and why did you compile php ??? PHP in for example remi repo is in quite new versions 5.3.10 i think now. – B14D3 Mar 15 '12 at 18:47
-
I have since re installed with yum from a repo. still the same problem. shows installed, but does not render any php – Headspin Mar 15 '12 at 19:03
-
Show yum install command and/or rpm -qa | grep php – HTTP500 Mar 15 '12 at 19:39
-
php-common-5.3.10-1.w5, php-cli-5.3.10-1.w5, php-5.3.10-1.w5 – Headspin Mar 15 '12 at 19:44
-
I don't know what repo you got those from but do you have a /etc/httpd/conf.d/php.conf that does a LoadModule, AddHandler, etc.? Or is that in your httpd.conf? – HTTP500 Mar 15 '12 at 19:48
-
I have the /etc/httpd/conf.d/php.conf which does a LoadModule and AddHandler – Headspin Mar 15 '12 at 19:53
-
How are you determining that it isn't rendering php? index.php in DocumentRoot is doing a phpinfo? – HTTP500 Mar 15 '12 at 19:57
-
let us [continue this discussion in chat](http://chat.stackexchange.com/rooms/2788/discussion-between-headspin-and-http500) – Headspin Mar 15 '12 at 20:05
1 Answers
First, you need to restart Apache (I'm assuming that's your webserver since you didn't mention it). If you didn't, that's your problem.
If you already did... It's not all to install PHP, you have to make sure it's properly loaded by apache. The default PHP rpm install will detect Apache and create a php.conf file in /etc/httpd/conf.d. All you gotta do after is restart Apache and it should work.
My php.conf contains this:
#
# PHP is an HTML-embedded scripting language which attempts to make it
# easy for developers to write dynamically generated webpages.
#
<IfModule prefork.c>
LoadModule php5_module modules/libphp5.so
</IfModule>
<IfModule worker.c>
LoadModule php5_module modules/libphp5-zts.so
</IfModule>
#
# Cause the PHP interpreter to handle files with a .php extension.
#
AddHandler php5-script .php
AddType text/html .php
#
# Add index.php to the list of files that will be served as directory
# indexes.
#
DirectoryIndex index.php
#
# Uncomment the following line to allow PHP to pretty-print .phps
# files as PHP source code:
#
#AddType application/x-httpd-php-source .phps
If you don't have a php.conf file in /etc/httpd/conf.d, then look for those lines (the uncommented ones) in your /etc/httpd/conf/httpd.conf file, and make sure the paths are good. If you say you compiled it first and then reinstalled using a package, my guess is that you have conflicting lines (duplicates) pointing to different paths. You should clean that out first and try to restart Apache after.
If it still doesn't work, look in the error log of Apache and see if there's an error. This should tell you more.

- 2,385
- 1
- 18
- 19