dongzhouji4021
2017-01-16 16:28
浏览 48
已采纳

尝试在Eclipse中运行PHP Hello World时出错

I installed the PDT PhP Development Tool in eclipse in order to run PhP files, but when I click in "Run as > PhP Web Aplication" it shows me a white page with the message:

Not Found

The requested URL /teste/teste.php was not found on this server.

Apache/2.4.23 (Debian) Server at localhost Port 80

Apache is running normally in 127.0.0.1.

I have an info.php file at /var/www/info.php, I tryend to tun http://localhost/info.php but it gives the same Not Found error.

Yes, I'm newbie in PhP, I'm trying to run a simple Hello World Program.

<?php
    echo "Hello!";
?>

My info.php is:

<?php phpinfo(); ?> 

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

我在eclipse中安装了PDT PhP开发工具以运行PhP文件,但是当我点击“运行为”时 &gt; PhP Web Aplication“它显示了一个带有消息的白页:

未找到

请求的URL / teste 在此服务器上找不到/teste.php。

本地主机端口80上的Apache / 2.4.23(Debian)服务器 < p> Apache在127.0.0.1中正常运行。

我在/var/www/info.php上有一个info.php文件,我试着修改 http://localhost/info.php 但是它给出了相同的Not Found错误。

是的, 我是PhP的新手,我正在尝试运行一个简单的Hello World程序。

 &lt;?php 
 echo“Hello!”; 
?&gt;  
   
 
 

我的info.php是:

 &lt;?php phpinfo();  ?&GT;  
   
 
  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • duanhong4274 2017-01-20 18:22
    已采纳

    Solved, I created a symlink for my project at /var/www/html, now it works!

    已采纳该答案
    评论
    解决 无用
    打赏 举报
  • douju7245 2017-01-17 13:58

    Apache/Hosts

    When you tried to open http://localhost/info.php direct in your Browser (firefox etc.) and this won't work, the problem is in your apache/hosts configuration.

    • Check in your apache.conf/httpd.conf the DocumentRoot
    • Check your VirtualHost config (in httpd.conf or separate file)
    • Check your /etc/hosts they should contain:

    127.0.0.1 localhost.localdomain localhost ::1 localhost.localdomain localhost

    When the url works in your browser:

    Eclipse You have to create the Run Configurations:

    1. Menu "Run" > "Run Configuration"
    2. Select "PHP Web Application" and click the "New Button"
    3. PHP Server: click on "New"
    4. ServerName: just a name. Tipp: name it after your domain: "localhost"
    5. Base URL: http://localhost
    6. Document Root: path to your source folder
    7. Finish (Back in Run Configuration)
    8. File: your start file (index.php or in your case teste.php)
    9. check if the url is correct, otherwise remove the check on "Auto Generate" and fix it
    10. run > will open the url in the Built-In browser

    To open the page in FireFox etc.: Menu "Preferences" > "General" > "Web Browser" > "Use external browser"

    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题