0

I'm setting up a new CentOS 7 server,

I installed apache httpd successfully and get the html welcome page then I installed php 5.4 then tried to test it using test page:

<?php
phpinfo();
?>

placed it in /var/www/html but I got a blank page. apache error log says:

[Mon Jan 26 21:20:12.474636 2015] [:error] [pid 8352] [client ::1:60206] PHP Fatal error:  Unknown: Failed opening required '/var/www/html/test.php' (include_path='.:/php/includes') in Unknown on line 0

What I tried is:

in /etc/httpd/conf/httpd.conf I added:

LoadModule php5_module "/usr/lib64/php"
AddType application/x-httpd-php  .php

and found: DirectoryIndex index.html then add index.php

I also uncommitted include_path='.:/php/includes' in /etc/php.ini

then restart apache. Nothing changed! Any idea?

UPDATE

When I checked: apachectl configtest I got:

[Mon Jan 26 22:22:49.748764 2015] [so:warn] [pid 4984] AH01574: module php5_module is already loaded, skipping
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message
Syntax OK

So I listed my hosts:

[admin@localhost etc]$ cat hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

then replaced ServerName www.example.com:80 in httpd.conf with ServerName localhost4.localdomain4 and also tried ServerName localhost:80

but still the issue exists. However the apachectl configtest result became:

[Mon Jan 26 22:49:46.968433 2015] [so:warn] [pid 5841] AH01574: module php5_module is already loaded, skipping
Syntax OK

and error_log:

[Mon Jan 26 22:58:27.110725 2015] [:error] [pid 6103] [client ::1:47747] PHP Fatal error:  Unknown: Failed opening required '/var/www/html/test.php' (include_path='.:/php/includes') in Unknown on line 0

SOLUTION

I finally decided to uninstall php54 then re install php with the following command:

yum install php php-pear

then changed ServerName in conf to localhost:80 and it works!

Thanks all for your time

2
  • 1
    Shadin - you need to figure out why apachectl configtest says you've got php5_module loading twice. Find that out, and you've got a big hint about the error_log message.
    – user732
    Jan 26, 2015 at 20:21
  • Thanks Bruce. I managed to remove that error but I still couldn't figure out how proceed and fix the problem.
    – Shadin
    Jan 26, 2015 at 20:55

3 Answers 3

2

I've got a somewhat different httpd.conf entry for enabling PHP:

LoadModule php5_module /etc/httpd/modules/libphp5.so
<FilesMatch \.php$>
    SetHandler application/x-httpd-php
</FilesMatch>

My observation is that the "LoadModule" directive you post above doesn't specify a .so file to load. Try to find the specific .so file, not just the directory it lives, or the file name without ".so" suffix.

What does apachectl configtest say when you run it?

1
  • Thank you for your answer. I tried your suggestion with no luck. please take a look at my updated post.
    – Shadin
    Jan 26, 2015 at 19:32
1

LoadModule Needs to point to a shared object versus whatever /usr/lib64/php is. For example:

LoadModule php5_module modules/libphp5.so
AddHandler php5-script .php

Loading something else as php5_module might be preventing the actual module from loading (judging from the "already loaded" error message).

5
  • Thank you for your answer. I did as you suggested but nothing changed.
    – Shadin
    Jan 26, 2015 at 19:43
  • 2
    Can you take out the php5_module you have in your original question and update the post with what the other LoadModule directive is set to being? The error is saying there's two of them in your config.
    – Bratchley
    Jan 26, 2015 at 19:46
  • 1
    Also the "Could not reliably determine the server's fully qualified domain name" error isn't related to your problem but it is probably good to get resolved. That's just saying it did a reverse lookup of your IP and couldn't find a hostname for this server. Updating ServerName like it says will probably good advice for getting rid of that error.
    – Bratchley
    Jan 26, 2015 at 19:48
  • Thanks! this error gone now but I'm still not able to get the file to work. I have no idea what I'm missing here.
    – Shadin
    Jan 26, 2015 at 19:53
  • I replaced "/usr/lib64/php" with /etc/httpd/modules/libphp5.so but still the worning appears!
    – Shadin
    Jan 26, 2015 at 19:54
0

For centos 6.7 x86-x64, this

LoadModule php5_module /etc/httpd/modules/libphp5.so
<FilesMatch \.php$>
    SetHandler application/x-httpd-php
</FilesMatch>

solved my problem about <?php phpinfo(); ?>

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .