Reputation: 663
I am trying to learn PHP and use Netbeans as my IDE along with a PHP plug-in, but the problem is that when I run the script, my browser (Firefox) couldn't connect to localhost.
My code is a simple query to my current PHP information.
<?php
phpinfo();
?>
This is the address I'm trying to access:
http://localhost/PhpProject1/index.php
Upvotes: 1
Views: 25277
Reputation: 1
be sure that you don't have index.php file on directory, if you have made any file with this name it can cause conflict
Upvotes: 0
Reputation: 1
If You have XAMPP, then Start services for Apache and Mysql. Your problem would be resolved.
Upvotes: 0
Reputation: 1371
Netbeans, a fine text editor, now owned by Oracle, has an internal web server of its own. They have a quickstart page for NB PHP here:
NetBeans IDE PHP Quick Start Tutorial
That will take you through XAMPP setup if you follow the Windows setup. I prefer WAMP over XAMPP myself. That being said, NB's internal web server is a bit easier to set up; although I don't see a guide anywhere. It requires no additional software, too (aside from needed runtimes).
Download the latest PHP Zip from PHP Downloads. Extract it into some folder, such as in "C:\Program Files\PHP" for Win7 x86.
Here's what they do not tell you, and they really should: You will need a VC++ runtime if you don't already have it installed. Here's a link to one I needed:
Visual C++ Redistributable for Visual Studio 2015
I spent quite some time searching for the reason why it wouldn't load my page from localhost on this one, until I tried running PHP.exe from the command line - when it complained about the missing runtime. The Netbeans docs didn't say anything about it. You have to observe the recommendation for the runtime in the left column of the PHP download page. The readme says nothing about it.
In NB, go to Tools | Options | General and select the browser you want to use. (There is also an internal Netbeans browser, but it's not that great.)
Go to Tools | Options | PHP | General | PHP Interpreter and Browse to the PHP.exe from the folder you extracted your PHP archive into.
Create your NB PHP project, and edit the body of "index.php" so that you will see some message indicating that it works.
(Optional) Right-click on your project in the Projects window, and choose Properties. Under Run Configuration, set it to use whatever hostname and port you want for your local machine. It should default to something usable.
Right-click on you project in the Projects window, and choose Run. You should see "Internal Webserver ()" on the Status Bar on the bottom right. If you don't, there was probably a problem running PHP.exe. The webpage will probably pop up in the selected browser when you run the project by this point.
Using this method, the server displays all of my webpages perfectly, as far as I can tell. (Note: this answer previously mentioned M$ specific HTML code that didn't render correctly; but that problem appeared to have stemmed from different versions of IE - and now does not appear to have been the fault of the NB web server.)
This procedure may look complicated, but it is actually a bit easier; as most of these steps are required for XAMPP and WAMP as well.
Upvotes: 1
Reputation: 516
Create a folder PhpProject1 in xampp/htdoc folder. Suppose you have installed xampp at c drive root then folder structure will be c:/xampp/htdoc/PhpProject1/ and place index.php it it, after that you may add any php code i.e
<?php
phpinfo();
?>
Hopefully this is the answer of your question. Takecare
Upvotes: 1
Reputation: 516
Make sure your system has a Apache MySQL and PHP stack installed on machine, if you are using windows then WAMPSERVER www.wampserver.com/en/ is most easy to install and manage otherwise LAMP and MAMP are options for Linux and Mac respectively.
Once Apache MySQL and PHP are installed on your machine, run the WAMP, MAMP or LAMP application, as this is called running the web-server on local machine.
Now open your favorite browser and type localhost in address bar if there is no error message on your browser screen, then you can place your php files in www folder for further experiments.
If you still have a question don't hesitate to ask
Upvotes: 2