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

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.

图片转代码服务由CSDN问答提供 功能建议

我正在关注此netbean指南 https://netbeans.org/kb/docs/php/configure-php-environment-ubuntu.html#createDocumentRootLocation < / p>

但我坚持创建虚拟主机。 我尝试按照教程中的说明进行操作,但“000-default.conf”文件中没有&lt; Directory&gt; 标记。 我继续前进并忽略了它。

我在教程中做了并将它放在我的/ home / user / public_html中。 但现在当我运行它时,PHP代码不被解释

如果我a2ensite默认我可以访问虚拟主机设置在/ var / www / html并且php被解释

php没有错误没有被解释,我在这里做错了什么。

我正在使用:

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

    编辑: 我的“TestPhp.conf”文件:

     &lt; VirtualHost *:80&gt; 
     ServerAdmin webmaster @ localhost 
     DocumentRoot /  home / jelly / public_html 
     
     ErrorLog $ {APACHE_LOG_DIR} /error.log
     CustomLog $ {APACHE_LOG_DIR} /access.log合并
    &lt; / VirtualHost&gt; 
       
     
      

    编辑2并回答:

    原来我的“php7.2.conf”文件中的某些行必须被注释掉,作为该文件中的注释行 解释。 因为默认情况下禁用在用户目录中运行PHP脚本。

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

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

    已采纳该答案
    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题