-1

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?

Headspin
  • 129
  • 2

1 Answers1

1

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.

Yanick Girouard
  • 2,385
  • 1
  • 18
  • 19