简体   繁体   English

在本地主机上使用数据库的亚马逊AWS服务器,我如何ssh以便我可以在localhost上运行我的php webservices?

[英]Amazon AWS server with database on localhost, how do I ssh so that my php webservices on localhost can run on it?

Server newbie here! 服务器新手在这里!

I have access to an amazon AWS server, and I have a php webservice on my localhost. 我可以访问亚马逊AWS服务器,我的localhost上有一个php webservice。 The php is working properly on the webservice. php在webservice上正常工作。 The MySQL is set up on the server. MySQL已在服务器上设置。 However, I cannot connect to my server. 但是,我无法连接到我的服务器。 I set up everything on the amazon AWS server by SSH-ing in to it and working from there. 我在亚马逊AWS服务器上设置了所有内容,通过SSH连接到它并在那里工作。 Is there a way to allow me to ssh into the server with my webservice? 有没有办法让我用我的webservice ssh到服务器?

Just to reiterate: -My php script is at localhost/ ... -My server is accessed by ssh and then on my localhost, it is hosted by amazon aws (default port 3306) 只是重申: - 我的php脚本是在localhost / ... - 我的服务器是由ssh访问然后在我的localhost上,它由amazon aws(默认端口3306)托管

I attempted the process suggested by one user which was to enter the following into my terminal: 我尝试了一个用户建议的进程,即在我的终端中输入以下内容:

ssh -L 8080:127.0.0.1:3306 -f -C -q -N -i ./password.pem user@host.com ssh -L 8080:127.0.0.1:3306 -f -C -q -N -i ./password.pem user@host.com

and then when I used mysqli connect I entered: 然后当我使用mysqli connect时我输入了:

new mysqli('127.0.0.1:8080','root','mypassword'); 新的mysqli('127.0.0.1:8080','root','mypassword');

Thanks so much for any assistance! 非常感谢您的帮助!

It sounds like you are trying to connect to your remote database from your local server (if I understand correctly). 听起来您正试图从本地服务器连接到远程数据库(如果我理解正确)。 You want to double check your security groups in AWS that they are allowing your computers ip address to connect to the server instance / that port 3306 is open to your pc. 您希望仔细检查AWS中的安全组,他们允许您的计算机IP地址连接到服务器实例/端口3306对您的PC开放。 If that is all set, then you should be able to connect to the instance using the public dns or elastic ip if it is an EC2 instance, or the endpoint if it is an RDS instance. 如果已全部设置,那么您应该能够使用公共DNS或弹性IP连接到实例(如果它是EC2实例),或端点(如果它是RDS实例)。

暂无
暂无

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

相关问题 我如何使用zend服务器在本地主机上运行.php? - How do i run .php on localhost using zend server? 我可以在这个 Laravel 应用程序的本地 Apache 服务器上运行 reCAPTCHA 吗? - Can I run reCAPTCHA on my localhost Apache server in this Laravel application? PHP函数在localhost上运行,但在我的服务器上运行 - PHP function run on localhost but not on my server 如何使用本地IP地址而不是localhost访问数据库mysql服务器 - How can I access my database mysql server using my local ip address instead of using localhost 如何设置Eclipse以使用XAMPP在本地主机上运行php文件? - How do I set up Eclipse to run php files on my localhost using XAMPP? 如何限制我的PHP脚本仅在本地主机请求时运行? - How do I limit my PHP script to only run when requested by localhost? 如何在本地主机上连续运行PHP脚本? - How do I run a PHP script continuously on localhost? 如何使用 PHP 和 SSH 连接到 Amazon EC2 服务器 - How do i connect to Amazon EC2 Server with PHP and SSH Codeigniter对于本地主机是可以的,但是在实时服务器上它显示“ database.php不存在”,如果使用linux cPanel,如何定位数据库? - Codeigniter is ok with localhost, but on a live server it says “database.php does not exist”, how can I locate my database if I use linux cPanel? 如何将我的本地主机站点上传到在线服务器? - How do I upload my localhost site to an online server?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM