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 SPSS分类模型实训题步骤
  • ¥15 求解决扩散模型代码问题
  • ¥15 工创大赛太阳能电动车项目零基础要学什么
  • ¥20 limma多组间分析最终p值只有一个
  • ¥15 nopCommerce开发问题
  • ¥15 torch.multiprocessing.spawn.ProcessExitedException: process 1 terminated with signal SIGKILL
  • ¥15 QuartusⅡ15.0编译项目后,output_files中的.jdi、.sld、.sof不更新怎么解决
  • ¥15 pycharm输出和导师的一样,但是标红
  • ¥15 想问问富文本拿到的html怎么转成docx的
  • ¥15 我看了您的文章,遇到了个问题。