PHP 7: cannot connect to FTP server from outside. What's wrong?

Hello. On Debian installed Nginx + PHP7.0-FPM + MariaDB. Somehow, cannot connect to FTP through a PHP script MonstaFTP (as in the new version and old) - if you specify an address like myftpsite.com then does not connect. If specified as 192.168.0.1 or 127.0.0.1, that's fine comes. In PHP5-FPM connected. What could be wrong?

Package php7.0-ftp installed.
July 2nd 19 at 18:09
2 answers
July 2nd 19 at 18:11
It would be nice to see a log from a failed server or directly the script...

If specified as 192.168.0.1 or 127.0.0.1, that's fine comes. In PHP5-FPM connected. What could be wrong?

Most likely, the fact that either "address like myftpsite.com" is not indicated on the IP: 192.168.0.1 or 127.0.0.1 or the script can't map the IP address with the person. To check this You can open a command prompt and writing the following command:
ping myftpsite.com

If you see that ping is trying to appeal to the 192.168.01 IP or 127.0.0.1 - then the script can't map the domain to the address. If there is some other IP that You are trying to connect to the wrong FTP server located at 192.168.0.1. What would locally to prescribe the matching of an address (domain) IP schnick - you can edit the file C:\Windows\System32\drivers\etc\hosts
July 2nd 19 at 18:13
so maybe it's in the ftp? for example, it is not accessible from the outside world. or listens to a local address
No, in other ways (not using PHP) - connects fine. - bud_OReilly47 commented on July 2nd 19 at 18:16
and if instead of a name enter the external IP that myftpsite? - Arielle15 commented on July 2nd 19 at 18:19
: if you specify an external IP, it connects. - bud_OReilly47 commented on July 2nd 19 at 18:22
:

<?php
$host= '192.168.0.1';
$user = 'test';
$password = 'test';
$ftpConn = ftp_connect($host);
$login = ftp_login($ftpConn,$user,$password);
if ((!$ftpConn) || (!$login)) {
 echo 'FTP connection has failed! Attempted to connect to '. $host. ' for user '.$user.'.';
}else{
 echo 'FTP connection was a success.';
 $directory = ftp_nlist($ftpConn,");
 echo '<pre-->'.print_r($directory,true).'
'; } ftp_close($ftpConn); ?>

Even in the test script, if you specify a domain name instead of IP, the connection will not take place. If you specify IP, all is fine. - bud_OReilly47 commented on July 2nd 19 at 18:25
: perhaps the name wrong resolvida - Tod commented on July 2nd 19 at 18:28
: Solved! Just added to the file /etc/dhcp/dhclient.conf the line:

supersede domain-name-servers 8.8.8.8, 8.8.4.4;

then ifdown eth0; ifup eth0 - bud_OReilly47 commented on July 2nd 19 at 18:31

Find more questions by tags LinuxPHP