Search code examples
netbeans-8php-5.5glassfish-4.1quercus

How to run Php Pages in Netbeans


I have just successfully deployed Quercus on Glassfish 4.1. I tested in the browser

http://localhost:8080/quercus-4.0.39/ and saw this:

Congratulations! Quercus™ Open Source 4.0.39 is interpreting PHP pages. Have fun!

Then ran Netbeans Tools > Options > PHP > Activate PHP Support

It worked. I now see this:

Netbeans Php 5 Interpreter

So I made 3 tests:

  1. I ran a php page in an html application but instead of displaying the page it prompts a download box to open in Notepad

  2. I created a new PHP project with below configuration: enter image description here

But when I run the app with above configuration I receive this error:

Firefox can't establish a connection to the server at localhost.

  1. So I tried with a third test with other configuration: enter image description here

When I run this third test I get a HTTP Status 404 - Not Found error on GlassFish server.

What am I doing wrong? Thank you!


Solution

  • The problems with your tests are:

    1. PHP needs to be interpreted by a web server. Your browser doesn't know what to do with a PHP file, so it just treats it like a file rather than a page to render. Apache is the most common and easiest server to do that with, GlassFish is unnecessary and probably not the best choice for PHP.

    2. In this test, you are trying to visit a web server which doesn't exist. You don't have any server that listens on port 80.

    3. Here, GlassFish is reporting that it can't find the resource you requested. Have you made sure to put your PHP project in the right directory for Quercus (like in step 4 of your documentation link) and made sure you're visiting a valid URL?

    I think the best thing for you to do is move away from Quercus. The latest version of it is very old and implements an old version of PHP (version 5, whereas the latest is 5.6). Looking at the official website, the project appears to be dead, with broken links and very old documentation.

    I would suggest you investigate installing a WAMP (Windows, Apache, MySQL, PHP) or LAMP (Linux, Apache, MySQL, PHP) stack. There are lots of very easy installers for this approach which will help you get up to speed and a lot of helpful tutorials and documentation.