鍍金池/ 問答/PHP  Linux  網(wǎng)絡(luò)安全/ 為什麼無法用 php 取得IP? XAMPP的ProFTPD壞了!

為什麼無法用 php 取得IP? XAMPP的ProFTPD壞了!

$_SERVER["REMOTE_ADDR"]
error_reporting (E_ERROR | E_WARNING | E_PARSE);
  if($HTTP_SERVER_VARS["HTTP_X_FORWARDED_FOR"]){
   $ip = $HTTP_SERVER_VARS["HTTP_X_FORWARDED_FOR"];
  }
  elseif($HTTP_SERVER_VARS["HTTP_CLIENT_IP"]){
   $ip = $HTTP_SERVER_VARS["HTTP_CLIENT_IP"];
  }
  elseif ($HTTP_SERVER_VARS["REMOTE_ADDR"]){
   $ip = $HTTP_SERVER_VARS["REMOTE_ADDR"];
  }
  elseif (getenv("HTTP_X_FORWARDED_FOR")){
   $ip = getenv("HTTP_X_FORWARDED_FOR");
  }
  elseif (getenv("HTTP_CLIENT_IP")){
   $ip = getenv("HTTP_CLIENT_IP");
  }
  elseif (getenv("REMOTE_ADDR")){
   $ip = getenv("REMOTE_ADDR");
  }
  else{
   $ip = "Unknown";
  }

好怪!不管用哪種
我的IP都會(huì)顯示 ::1
怎麼會(huì)這樣?

我看xampp的LOG寫

Starting ProFTPD...
Exit code: 8
Stdout:
Checking syntax of configuration file
proftpd config test fails, aborting
Stderr:
xxx-2.local proftpd[1549]: warning: unable to determine IP address of 'xxx-2.local'
xxx-2.local proftpd[1549]: error: no valid servers configured
xxx-2.local proftpd[1549]: Fatal: error processing configuration file '/Applications/XAMPP/xamppfiles/etc/proftpd.conf'

補(bǔ)充

clipboard.png

回答
編輯回答
爛人

macos sierra 的問題

2017年11月9日 22:12