cuteftp 2018-2-9 20:40
在 Centos7+PHP7 使用 yum 安裝 php-geoip
相信有玩過 GeoIP 的都清楚其實他就是個查表的行為, 會需要查 ip 對應的國家或城市,<br>所以在 Centos7 下可以這樣安裝<br><br>檢查<br># php -m | grep 'geoip'<br><空的結果代表沒裝,預設沒有,如果有裝會顯示'geoip'><br><br># php -v<br>PHP 7.0.27 (cli) (built: Jan 2 2018 12:38:03) ( NTS )<br><br>首先下載安裝 Remi 及 EPEL Repository:<br># rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-<strong><font color="#FF0000">7</font></strong>.noarch.rpm<br># rpm -Uvh http://rpms.remirepo.net/enterprise/remi-release-<strong><font color="#FF0000">7</font></strong>.rpm<br><br>(1)安裝 PHP 7.0<br># yum install --enablerepo=remi-php70 php php-fpm php-mysql php-gd php-ldap php-odbc php-xml php-xmlrpc php-mbstring php-snmp php-soap curl curl-devel<br># yum install php-devel gcc php-pear<br># rpm -Uvh http://mirror.centos.org/centos/7/os/x86_64/Packages/GeoIP-devel-1.5.0-11.el7.x86_64.rpm<br><br># pecl install geoip-1.1.1<br>安裝完後在 php extension 目錄(/usr/lib64/php/modules)會有這個檔 geoip.so<br><br># cd /etc/php.d<br><br># vi geoip.ini<br>extension=geoip.so<br><br>加上一行後,存檔離開重啟 nginx