0

I'm new to PHP, but as I understand, you can't run .php files locally, you need a server with php installed to do so. So I set Netbeans to run as "Remote Web Site", gave it the login credentials, and the path to put the files, all of which is does fine.

The problem is, when I try to run the project, it opens in chrome with a blank page, and there's nothing in the source code either. The URL for this is http://localhost/public_html/index.php, which you can set in the Project Url field of the project settings.

It seems to me that netbeans is trying to run from my local machine (hence localhost), even though it put all the files on my remote webserver. What URL should I be using if I want chrome to access the remote machine? I don't want to use my domain name obviously, so is there any way to run a php project like this?

1 Answer 1

1

Set the remote URL to the ip address of your remote server including any additional folders that are relative to your web root.

for example, a common web root on a linux server is /var/www/ . If you have placed your files in that folder on the server then you set the remote URL to http://the.ip.add.ress/. However if you have placed your code inside a folder within that directory such as /var/www/myproject your url would be http://the.ip.add.ress/myproject/

Alternatively, it's perfectly normal to run a webserver on your local machine. If your on Windows, you can install the services your require such as apache/php/mysql and configure them manually. Or simply get a premade web server bundle like wamp, xampp, uniserver or one of the very many other ones out there you will find via google.

Sign up to request clarification or add additional context in comments.

4 Comments

Using the ip doesn't work. But why would my browser have access to something that's not public on the webserver? The issue could also be that I have several virtual hosts on that machine, and the ip address redirects to the first one (which doesn't contain the netbeans content)
right ok, if your using virtual hosts you either need to get a new ip for that website to run on, set it up as the default website for that ip (make sure its the first vhost config that gets loaded), or use a domain name (if you dont want to get a real one, set a fake one up in your hosts file that only you can see/use)
So basically it has to be somewhere public on the webserver? That's a little annoying since I don't really want it to be accessible to anyone else. I might consider using WAMP.
well yes, it has to be publically accessible in order for you to access it. If your worried about others seeing it, you could use htaccess to limit access to the website either by password or only allowing your own ip address. However i'd always recommend a local web server for development, you'll find having a local web server to be a god-send when you get out of using remote FTP and start looking at things like git repos. It also means you can easily work on a development version rather than editing the live site once you go public

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.