一个PHP项目需要添加ftp的模块,需要添加。 解决备注:
1
centos 6.5
PHP 5.3.28
iptable selinux 全部关闭
2
PHP简单安装
yum install -y libxml2 libxml2-devel libcurl libcurl-devel gd gd-devel
tar -zxvf php-5.3.28.tar.gz
cd php-5.3.28
'./configure' '--prefix=/usr/local/php' '--with-config-file-path=/usr/local/php/etc' '--with-mysql=mysqlnd' '--with-mysqli=mysqlnd' '--with-pdo-mysql=mysqlnd' '--with-iconv=/usr/local' '--with-freetype-dir' '--with-jpeg-dir' '--with-png-dir' '--with-zlib' '--with-libxml-dir=/usr' '--enable-xml' '--disable-rpath' '--enable-safe-mode' '--enable-bcmath' '--enable-shmop' '--enable-sysvsem' '--enable-inline-optimization' '--with-curl' '--with-curlwrappers' '--enable-mbregex' '--enable-fpm' '--enable-mbstring' '--with-mcrypt' '--with-gd' '--enable-gd-native-ttf' '--with-openssl' '--with-mhash' '--with-gettext' '--enable-pcntl' '--enable-sockets' '--with-xmlrpc' '--enable-zip' '--enable-soap'
make
make install
这里面有一个技巧:make -j4 表示4个处理器一起进行编译 这样速度会快很多。
查看安装模块
[root@cyf bin]# ./php -m
[PHP Modules]
bcmath
Core
ctype
curl
date
dom
ereg
fileinfo
filter
gd
gettext
hash
iconv
json
libxml
mbstring
mcrypt
mhash
mysql
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
Reflection
session
shmop
SimpleXML
soap
sockets
SPL
SQLite
sqlite3
standard
sysvsem
tokenizer
xml
xmlreader
xmlrpc
xmlwriter
zip
zlib
[Zend Modules]
没有ftp的模块
添加模块:
[root@cyf bin]# find /root/php-5.3.28 -name ftp
/root/php-5.3.28/ext/ftp
[root@cyf ftp]# cd /root/php-5.3.28/ext/ftp/
[root@cyf ftp]# ls
config.m4 config.w32 CREDITS ftp.c ftp.h package.xml php_ftp.c php_ftp.h tests
[root@cyf ftp]# /usr/local/php/bin/phpize
Configuring for:
PHP Api Version: 20090626
Zend Module Api No: 20090626
Zend Extension Api No: 220090626
[root@cyf ftp]# ./configure --with-php-config=/usr/local/php/bin/php-config
[root@cyf ftp]# make && make install
[root@cyf php-5.3.28]# cp php.ini-development /usr/local/php/etc/php-ini
[root@cyf php-5.3.28]# pwd
/root/php-5.3.28
[root@cyf ~]# extension=ftp.so >> /usr/local/php/etc/php—ini
[root@cyf php]# pkill php
[root@cyf php]# ps -ef | grep php
root 44786 1689 0 13:25 pts/0 00:00:00 grep php
[root@cyf php]# cd sbin
[root@cyf sbin]# ./php-fpm
[root@cyf sbin]#
[root@cyf sbin]# /usr/local/php/bin/php -m
[PHP Modules]
bcmath
Core
ctype
curl
date
dom
ereg
fileinfo
filter
ftp
gd
gettext
hash
iconv
json
libxml
mbstring
mcrypt
mhash
mysql
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
Reflection
session
shmop
SimpleXML
soap
sockets
SPL
SQLite
sqlite3
standard
sysvsem
tokenizer
xml
xmlreader
xmlrpc
xmlwriter
zip
zlib
[Zend Modules]
看PHP已经加入ftp。