简体   繁体   English

在单独的服务器上设置脚本和mysql数据库

[英]Setting up scripting and mysql database on separate servers

Hello I have a unique setup for a web ap that I need to get my head around. 您好,我有一个独特的Web AP设置程序,需要掌握一下。

I have two servers that will need to talk to each other, Server A will host the actual PHP based application; 我有两个需要互相通信的服务器,服务器A将托管实际的基于PHP的应用程序; Server B will host the MySQL database and the server connection details. 服务器B将托管MySQL数据库和服务器连接详细信息。 Server B will also be within a closed network, so that only people on the local network will be able to access the server, whereas Server A will be web based. 服务器B也将位于封闭的网络中,因此只有本地网络上的人才能访问该服务器,而服务器A将基于Web。

If the visitor has access to the local network for Server B, they should then be able to, through the scripting on Server A, connect to and access the database on Server B to complete the picture. 如果访问者可以访问服务器B的本地网络,则他们应该能够通过服务器A上的脚本连接并访问服务器B上的数据库以完成操作。

My first question is: is this possible? 我的第一个问题是:这可能吗? I think it is but am not 100% sure. 我认为是,但不确定100%。

Secondly: how would I write the script for accessing the Server B script? 其次:如何编写用于访问服务器B脚本的脚本? Is it similar to accessing an include file or would it be a remote https call? 它类似于访问包含文件,还是一个远程https调用? I'm just not sure how to go about making this happen. 我只是不确定如何实现这一目标。

Any advice is GREATLY appreciated!! 任何意见是极大的赞赏!!

Thanks in advance! 提前致谢!

Remotely connecting to a MySQL database should be no problem. 远程连接到MySQL数据库应该没有问题。 Here is a pretty thorough guide Enabling Remote MySQL Access . 这是一个相当详尽的指南,《 启用远程MySQL访问》 I was able to get this to work by a simple setting in WHM called Additional MySQL Access Hosts . 我能够通过WHM中的一个名为“ 其他MySQL访问主机”的简单设置来使其工作。 Visiting this area from Server B you would be able to add the IP address of Server A, allowing Server A to connect to Server B's Database by using this format: 从服务器B访问此区域,您将能够添加服务器A的IP地址,从而允许服务器A通过使用以下格式连接到服务器B的数据库:
mysql_connect("IP Address of Server B","DB_username","DB_pass")
or whatever your preferred MySQL connection function is. 或您首选的MySQL连接功能是什么。

If this doesn't work right away though, you may need to make some changes to firewall settings, but to my knowledge what you need should be possible. 如果仍然无法立即执行此操作,则可能需要对防火墙设置进行一些更改,但是据我所知,应该可以实现所需的设置。

I'm not sure but I dont think this is possible using PHP. 我不确定,但我认为使用PHP不可能做到这一点。 PHP is server sided so It's the server that has to have access to the mysql server, the client doesnt come into play... PHP是服务器端的,因此它是必须有权访问mysql服务器的服务器,客户端没有作用。

There is many way to secure the mysql server to accept connection only from server A thought... 有很多方法可以确保mysql服务器仅接受来自服务器A的连接,这是...

First point is that it's not a good architecture for availability. 第一点是,它不是可用性的良好架构。 If you just had a single machine running both PHP and DBMS, then you've got a single point of failure. 如果您只有一台同时运行PHP和DBMS的计算机,那么您将遇到单点故障。 This is not a good scenario for availability. 这不是可用性的好方案。 With PHP and DB on seperate machines you've now got 2 single points of failure! 在单独的计算机上使用PHP和DB,您现在有2个单点故障! Worse!! 更差!!

But we'll leave that for now. 但是,我们暂时将其保留。

Yes it would be posible to gate access via PHP, but PHP does not natively implement the mysql protocol - so you'd either have to 是的,可以通过PHP进行门禁访问,但是PHP本身并不实现mysql协议-因此您要么必须

1) do an awful lot of programming to implement a mysql protocol proxy with additional functionality. 1)进行了大量编程,以实现具有附加功能的mysql协议代理。

2) update the mysql permissions table to allow the remote host on a temporary basis 2)更新mysql权限表以允许远程主机临时

Really you don't want any access to your webserver from outside your subnet. 确实,您不希望从子网外部访问您的Web服务器。

However if the machine has access to the "local network" then all you need to do is drop a port reflector somewhere on that not network and then point the clients at that instead of the DBMS. 但是,如果计算机可以访问“本地网络”,那么您要做的就是将端口反射器放在该非网络上的某个位置,然后将客户端指向该位置而不是DBMS。 The DBMS would see the client address as that of wherever the port-reflector was running (it might even be running on a different port of the DBMS server itself. 无论端口反射器在哪里运行,DBMS都将其视为客户端地址(甚至可能在DBMS服务器本身的其他端口上运行)。

However we'd need to know a lot more about what you mean by "access to the local network" 但是,我们需要更多地了解“访问本地网络”的含义。

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

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