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 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键失灵