5

I am trying for days to enable php on my server. The web server is up, but php is not parsed.

  1. First things first: the server is a CentOS 7 running apache2 and php 7. Everythign seems to be correctly installed:

    OS: uname -a

    Linux rafiki 3.10.0-327.10.1.el7.x86_64 #1 SMP Tue Feb 16 17:03:50 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
    

    and :cat /etc/redhat-release

    CentOS Linux release 7.2.1511 (Core)
    

    apache: httpd -v

    Server version: Apache/2.4.6 (CentOS)
    Server built:   Jul 18 2016 15:30:14
    

    PHP: php -v

    PHP 7.0.10 (cli) (built: Aug 20 2016 07:47:25) ( NTS )
    Copyright (c) 1997-2016 The PHP Group
    Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
        with Zend OPcache v7.0.10, Copyright (c) 1999-2016, by Zend Technologies
    
  2. Then, in /etc/httpd/conf/httpd.conf there is this line:

    Include conf.modules.d/*.conf
    

    And in /etc/httpd/conf.modules.d/:

    10-php.conf  00-base.conf  00-dav.conf  00-lua.conf  00-mpm.conf  00-proxy.conf  00-systemd.conf  01-cgi.conf
    

    10-php.conf content:

    <IfModule prefork.c>
        LoadModule php7_module modules/libphp7.so
    </IfModule>
    
    <IfModule !prefork.c>
       LoadModule php7_module modules/libphp7-zts.so
    </IfModule>
    
  3. Here is output for ls /etc/httpd/modules/ | grep php

    libphp7.so
    libphp7-zts.so
    
  4. In /var/www/, there is a test.php file, which content is:

    <?php phpinfo(); ?>
    

    When I try http://[myserver.domain]/test.php, apache serves the raw file, without parsing php code.

I went through a lot of researches including StackOverflow, but none of the results had a solution working for me.

Can someone please help me to get php run properly? Is there something I am doing wrong ?

Solution:

As pointed out by @kyshel, a simple reboot worked.

3
  • I met your condition once, but after i reboot the server, it works well. You can have a try. Commented Sep 6, 2016 at 9:23
  • Thanks for your help, it worked. However, I still don't know why. Do you know why restarting services didn't get the job done ? Commented Sep 6, 2016 at 9:32
  • I do not know. Maybe apache was not load php module, or the cache or something cause this. Commented Sep 6, 2016 at 10:37

1 Answer 1

3

Try rebooting the server (as others have already suggested). It worked for me.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.