dongyi7901 2016-05-06 21:48
浏览 53
已采纳

apache无法运行任何php [关闭]

I've installed an apache server on my raspberry pi and everything seems to be running fine unless I try to serve php.

/var/www/html/index.html serves fine
/var/www/html/foo/index/index.html serves fines

But if I add index.php, let's say :

<?php echo "hello world"; ?>

I get 403 -Forbbiden by accessing /var/www/html but I can still access /var/www/html/foo/index.html (DirectoryIndex set to .php .html .htm).

And if I run $php index.php : hello world

So, it does can serves .html, it can run .php but it cannot serve .php.

How can I fix this ? I found many solutions but none worked for me.

Note : I access the sites from the LAN. Server OS (uname -a) : Linux raspbian-AH 4.1.19-v7+ #858 SMP Tue Mar 15 15:56:00 GMT 2016 armv7l GNU/Linux

As stated in the comments, we could easily deduce module is not loaded but I here it is :

pi@raspbian-AH:/etc/apache2/mods-available $ cat php5.conf 
<FilesMatch ".+\.ph(p[345]?|t|tml)$">
    SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch ".+\.phps$">
    SetHandler application/x-httpd-php-source
    # Deny access to raw php sources by default
    # To re-enable it's recommended to enable access to the files
    # only in specific virtual host or directory
    Require all denied
</FilesMatch>
# Deny access to files without filename (e.g. '.php')
<FilesMatch "^\.ph(p[345]?|t|tml|ps)$">
    Require all denied
</FilesMatch>

# Running PHP scripts in user directories is disabled by default
# 
# 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/*/public_html>
        php_admin_flag engine Off
    </Directory>
</IfModule>

and the php5.load:

pi@raspbian-AH:/etc/apache2/mods-available $ cat php5.load
LoadModule php5_module /usr/lib/apache2/modules/libphp5.so
  • 写回答

1条回答 默认 最新

  • douqian1835 2016-05-07 00:24
    关注

    Thanks to dan08, I found out my set up was messed up is some way. So rather than to pinpoint the problem I purged everything and install it anew. There wasn't anything to save anyway.

    So the solution was :

    sudo apt-get purge apache2 php5 libapache2-mod-php5
    sudo apt-get install apache2 php5 libapache2-mod-php5
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵