Apache没有';无法执行php文件,但已启用mod_php5

Apache没有';无法执行php文件,但已启用mod_php5,php,module,apache2,installation,execution,Php,Module,Apache2,Installation,Execution,我不明白为什么。他不是执行php文件,而是为我提供下载服务 在下载的文件中有php源代码 我的测试文件非常简单,名为info.php <?php phpinfo(); 支持Apache的模块: apache2ctl -M Loaded Modules: core_module (static) log_config_module (static) logio_module (static) mpm_prefork_module (static) http_module (st

我不明白为什么。他不是执行php文件,而是为我提供下载服务

在下载的文件中有php源代码

我的测试文件非常简单,名为info.php

<?php

phpinfo();
支持Apache的模块:

apache2ctl -M
Loaded Modules:
 core_module (static)
 log_config_module (static)
 logio_module (static)
 mpm_prefork_module (static)
 http_module (static)
 so_module (static)
 actions_module (shared)
 alias_module (shared)
 auth_basic_module (shared)
 auth_digest_module (shared)
 authn_file_module (shared)
 authz_default_module (shared)
 authz_groupfile_module (shared)
 authz_host_module (shared)
 authz_user_module (shared)
 autoindex_module (shared)
 bw_module (shared)
 cgi_module (shared)
 dav_module (shared)
 dav_fs_module (shared)
 dav_lock_module (shared)
 dav_svn_module (shared)
 authz_svn_module (shared)
 deflate_module (shared)
 dir_module (shared)
 env_module (shared)
 fcgid_module (shared)
 include_module (shared)
 mime_module (shared)
 negotiation_module (shared)
 perl_module (shared)
 php5_module (shared)
 python_module (shared)
 reqtimeout_module (shared)
 rewrite_module (shared)
 setenvif_module (shared)
 ssl_module (shared)
 status_module (shared)
 suexec_module (shared)
 userdir_module (shared)
 wsgi_module (shared)
Syntax OK
我必须试着调试和解决这个问题吗?


我也安装了phpmyadmin,它工作正常。

检查您是否将此文件“php5.conf”和“php5.load”放入“mods available”(默认路径:/etc/apache2/mods available)

如果没有,则按如下方式创建:

php5.conf:

<IfModule mod_php5.c>
    <FilesMatch ".ph(p3?|tml)$">
        SetHandler application/x-httpd-php
    </FilesMatch>
    <FilesMatch ".phps$">
        SetHandler application/x-httpd-php-source
    </FilesMatch>
    # To re-enable php in user directories comment the following lines
    # (from <IfModule ...> to </IfModule>.) Do NOT set it to On as it
    # prevents .htaccess files from disabling it.
    <IfModule mod_userdir.c>
        <Directory /home/*/site>
            php_admin_value engine Off
        </Directory>
    </IfModule>
</IfModule>
Phpmyadmin将配置文件名“Phpmyadmin.conf”的链接添加到“/etc/apache2/conf.d”中,并提供启用php的必要说明:

<Directory /usr/share/phpmyadmin>
    Options FollowSymLinks
    DirectoryIndex index.php

    <IfModule mod_php5.c>
        AddType application/x-httpd-php .php

        php_flag magic_quotes_gpc Off
        php_flag track_vars On
        php_flag register_globals Off
        php_value include_path .
    </IFModule>
</Directory>

选项如下符号链接
DirectoryIndex.php
AddType应用程序/x-httpd-php.php
php_标志魔术_引号_gpc关闭
php_标志跟踪_变量打开
php_标志寄存器_全局关闭
php_值包括_路径。
找到了问题

他们是2:

  • plesk,哪个配置让我感到困惑,并将要下载的文件还给了我
  • 我的虚拟主机中缺少
    NameVirtualHost 111.22.33.44:80
所以我排除了plesk的所有include,然后问题就清楚了;无法解析虚拟主机,因为在此之前存在另一个基于ip的虚拟主机


谢谢大家的帮助。

可能是.htaccess或其他.conf文件中的add-type指令,覆盖apache2.conf中的指令。是否缺少DirectoryIndex?应该如何设置?普通HTML正常呈现吗?@avastreg.htaccess中有什么?是的,我有两个,还有phpmyadmin配置。因此myadmin可以工作,但我的vhosts没有。谢谢!我需要那一小段文本
php5_模块
!我不得不从PHP7降级到PHP5,并且
LoadModule
语句的格式和文件名完全不同。我还有其他的一切,但是mod_php5不起作用。
<IfModule mod_php5.c>
    <FilesMatch ".ph(p3?|tml)$">
        SetHandler application/x-httpd-php
    </FilesMatch>
    <FilesMatch ".phps$">
        SetHandler application/x-httpd-php-source
    </FilesMatch>
    # To re-enable php in user directories comment the following lines
    # (from <IfModule ...> to </IfModule>.) Do NOT set it to On as it
    # prevents .htaccess files from disabling it.
    <IfModule mod_userdir.c>
        <Directory /home/*/site>
            php_admin_value engine Off
        </Directory>
    </IfModule>
</IfModule>
# default PATH : /usr/lib/apache2/module/libphp5.so
LoadModule php5_module PATH/libphp5.so
<Directory /usr/share/phpmyadmin>
    Options FollowSymLinks
    DirectoryIndex index.php

    <IfModule mod_php5.c>
        AddType application/x-httpd-php .php

        php_flag magic_quotes_gpc Off
        php_flag track_vars On
        php_flag register_globals Off
        php_value include_path .
    </IFModule>
</Directory>