简体   繁体   English

使用Netbeans在远程Web服务器上运行PHP项目

[英]Running a PHP project on a remote webserver using Netbeans

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. 我是PHP的新手,但据我了解,您无法在本地运行.php文件,您需要安装了php的服务器。 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. 因此,我将Netbeans设置为以“远程网站”运行,并为其提供了登录凭据以及放置文件的路径,所有这些都很好。

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. 问题是,当我尝试运行该项目时,它在chrome中以空白页打开,并且源代码中也没有任何内容。 The URL for this is http://localhost/public_html/index.php , which you can set in the Project Url field of the project settings. 其URL是http://localhost/public_html/index.php ,您可以在项目设置的“项目URL”字段中进行设置。

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. 在我看来,netbeans试图从我的本地计算机(因此为localhost)运行,即使它已将所有文件放在远程Web服务器上。 What URL should I be using if I want chrome to access the remote machine? 如果我希望Chrome访问远程计算机,应该使用哪个URL? I don't want to use my domain name obviously, so is there any way to run a php project like this? 我不想明显使用我的域名,所以有没有办法运行这样的php项目?

Set the remote URL to the ip address of your remote server including any additional folders that are relative to your web root. 将远程URL设置为远程服务器的IP地址,包括相对于Web根目录的所有其他文件夹。

for example, a common web root on a linux server is /var/www/ . 例如,Linux服务器上的通用Web根目录是/ 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/ . 如果已将文件放置在服务器上的该文件夹中,则将远程URL设置为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/ 但是,如果将代码放置在该目录下的文件夹中,例如/var/www/myproject您的网址将为http://the.ip.add.ress/myproject/

Alternatively, it's perfectly normal to run a webserver on your local machine. 另外,在本地计算机上运行Web服务器是完全正常的。 If your on Windows, you can install the services your require such as apache/php/mysql and configure them manually. 如果在Windows上,则可以安装所需的服务(例如apache / php / mysql)并手动配置它们。 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. 或者只是简单地获得一个预制的Web服务器捆绑包,例如wamp,xampp,uniserver或其他很多可以通过google找到的捆绑包之一。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM