doucan4815 2018-10-22 12:23
浏览 198
已采纳

Netbeans灯PHP解释器不工作

I am following this netbean guide https://netbeans.org/kb/docs/php/configure-php-environment-ubuntu.html#createDocumentRootLocation

But I am stuck at creating the virtual host. I try to do as in the tutorial but there is no <Directory> tags in the "000-default.conf" file. I kept going and ignored that.

I did as in the tutorial and put it in my /home/user/public_html. but now when I run it the php code is not interpreted

If I a2ensite the default I can access virtual host set at /var/www/html and that php is interpreted

There are no errors the php is just not being interpreted, what am I doing wrong here.

Im using:

  • Ubuntu 18.10 LTS
  • PHP 7.2.10-0ubuntu1 (cli)
  • Apache/2.4.34

Edit: My "TestPhp.conf" file:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /home/jelly/public_html

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Edit 2 and answer:

Turned out to be some lines in my "php7.2.conf" file that had to be commented out as the out-commented lines in that file explains. as running PHP scripts in user directories is disabled by default.

  • 写回答

1条回答 默认 最新

  • doujing1967 2018-10-22 12:43
    关注

    what is your test script like? if you start with <? try <?php instead.

    Also check php.ini for expose_php = false (may hide php form the headers)

    If the error persists, include your config and test script, along with any errors in http.log

    You need to find a config file which enables php

    I only have a Ubuntu, and the files in my installation may vary compared to yours:

    Enable PHP engine [php.load]

    This is the part that loads the PHP interpreter, and allows you to use php scripts

    LoadModule php5_module /usr/lib/apache2/modules/libphp5.so
    

    Enable .php file directed to php [php5.conf]

    This is the part tells apache to send *.php (and in this case some other extensions like *.phtml) to the php interpreter

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

    EDIT I noticed that you were on UBUNTU as well

    use sudo a2enmod and select php in the list

    EDIT 2

    Note that if you are following a general Guide and not a UBUNTU specific one, you may encounter several issues since the UBUNTU apache config is spread out in several files, as opposed to one big file, which is what you may encounter in other distros

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥200 uniapp长期运行卡死问题解决
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?
  • ¥15 乘性高斯噪声在深度学习网络中的应用