简体   繁体   English

我如何将我的 php 脚本放在我的 WAN IP 地址上,因为它目前在我的本地主机上?

[英]How do I put my php script on my WAN IP address as it's currently on my local host?

I currently can successfully enter user inputted information to the DB using MySQL with a React.js frontend.我目前可以使用带有 React.js 前端的 MySQL 成功地将用户输入的信息输入到数据库中。

I'm using MAMP and my php script lives inside the htdocs folder.我正在使用 MAMP,我的 php 脚本位于htdocs文件夹中。

I have a php script that runs on local host but now I'd like to expose it.我有一个在本地主机上运行的 php 脚本,但现在我想公开它。 I've already gained access to my WAN IP address via http://www.whatismyip.com/ .我已经通过http://www.whatismyip.com/获得了对我的 WAN IP 地址的访问权限。 How do I put my php script on my WAN IP address as it's currently on my local host so I can expose it to the world?我如何将我的 php 脚本放在我的 WAN IP 地址上,因为它目前在我的本地主机上,以便我可以向全世界公开它?

It sounds like you're trying to expose your script publicly from your own private network.听起来您正试图从您自己的专用网络公开公开您的脚本。 In that case, you need to configure something called "port forwarding" on your router.在这种情况下,您需要在路由器上配置称为“端口转发”的东西。

The concept is pretty simple: if someone attempts to visit your public-facing IP address, that traffic passes through your router.这个概念非常简单:如果有人试图访问您面向公众的 IP 地址,该流量将通过您的路由器。 Your router has no idea what to do with this traffic, so it simply drops it by default.您的路由器不知道如何处理此流量,因此默认情况下它只是将其丢弃。 Port forwarding tells your router "if you receive traffic on this specific port of yours, then direct it to this other port on this other device".端口转发告诉你的路由器“如果你在你的这个特定端口上接收到流量,那么将它定向到另一个设备上的另一个端口”。 For a typical web interface, you would want to forward the router's port 80 for HTTP and 443 for HTTPS traffic, to the appropriate equivalents for your local web server's configuration.对于典型的 Web 界面,您可能希望将路由器的 HTTP 端口80和 HTTPS 流量的443端口转发到本地 Web 服务器配置的适当等效项。

Common ways to view your router's admin interface would be the IP addresses 192.168.0.1 or 10.0.0.1 .查看路由器管理界面的常用方法是 IP 地址192.168.0.110.0.0.1 Other possibilities may exist, which (for most residential users, anyway) can usually be listed as a "default gateway" entry when listing your network settings from the command line.可能存在其他可能性,在从命令行列出您的网络设置时,通常可以将其(无论如何对于大多数住宅用户)列为“默认网关”条目。 Specific instructions for setting up port forwarding on your router will depend largely on the specific router you own, and are thus beyond the scope of this question.在路由器上设置端口转发的具体说明在很大程度上取决于您拥有的特定路由器,因此超出了本问题的范围。 You should be able to find the settings pretty quickly just by digging around through the admin interface, however.但是,您应该能够通过浏览管理界面很快找到设置。

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

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