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 如何证明高斯噪声的包络公式
  • ¥150 寻找王者荣耀开发作者,合作或者解答
  • ¥15 乳腺癌数据集 相关矩阵 特征选择
  • ¥15 我的游戏账号被盗取,请问我该怎么做
  • ¥15 通关usb3.0.push文件,导致usb频繁断连
  • ¥15 有没有能解决微信公众号,只能实时拍照,没有选择相册上传功能,我不懂任何技术,,有没有给我发个软件就能搞定的方法
  • ¥15 Pythontxt文本可视化
  • ¥15 如何基于Ryu环境下使用scapy包进行数据包构造
  • ¥15 springboot国际化
  • ¥15 搭建QEMU环境运行OP-TEE出现错误