简体   繁体   中英

PHP won't parse on Apache2 - CentOS 7

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 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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM