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 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 来真人,不要ai!matlab有关常微分方程的问题求解决,
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算