dsh1956 2016-09-06 09:09
浏览 220

PHP不会解析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

    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.

  • 写回答

1条回答 默认 最新

  • dsafgdafgdf45345 2018-12-03 07:44
    关注

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

    评论

报告相同问题?

悬赏问题

  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用