‘壹’ 编译php要用什么样的参数,才能支持远程连接Mysql服务器
和PHP没关系,要设置MYSQL
用root用户进数据库,选择mysql库,user表里,把对应用户(比如root)的Host改为%号(任意IP,不分本地远程),或者改为某一IP(指定IP登录),再重启下MYSQL,就可以远程访问MYSQL了。
‘贰’ php编译后漏掉一些参数怎么办
比如添加bcmath模块:(在编译时没有添加 --enable-bcmath)
# cd php-5.3.10/ext/bcmath
# /usr/local/php/bin/phpize
# ./configure --with-php-config=/usr/local/php/bin/php-config
# make && make install
# cp /usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/bcmath.so
/usr/lib/php/moles
# vi /usr/local/php/etc/php.ini
[bcmath]
extension=bcmath.so
:wq
重启apache:
# /usr/local/apache/bin/apachectl restart
‘叁’ ./configure编译php时这个问题如何解决
PHP的安装虽然有时候很简单,可是如果应用一多,我们安装起来就很头痛了!出错最多的就是安装PHP扩展的时候了。其实不管是你是Apache类的应用还是Nginx类的,PHP的安装都不是很简单,虽然网上有很多configure参数,但是那不一定是适合你的,因为很多都直接关系着你的系统版本和内核。因此要自己亲自不断的调试,才能完全安装成功。
本文总结了一些常见的configure错误信息和解决这些错误的经验。
1、configure: error: No curses/termcap library found
网上有的说法是:–with-named-curses-libs=/usr/lib/libncursesw.so.5
其实是不对的,虽然能解决configure的错误,但是make的时候会提示错误,正确的做法应该是
centos: yum -y install ncurses-devel
debian: apt-get install libncurses5-dev
2、configure: error: xml2-config not found. Please check your libxml2 installation.
centos: yum -y install libxml2 libxml2-devel
debian: apt-get install libxml2-dev
3、configure: error: Cannot find OpenSSL’s
centos: yum -y install openssl-devel
4、configure: error: libjpeg.(a|so) not found
centos: yum -y install gd
centos: yum -y install gd-devel
debian: apt-get install libjpeg-dev
5、configure: error: libpng.(a|so) not found.
apt-get install libpng12-dev
6、configure: error: cannot find output from lex; giving up
yum -y install flex
7、configure: error: mod_deflate has been requested but can not be built e to prerequisite failures
centos: yum -y install zlib-devel openssl-devel
debian: apt-get install zlib1g-dev
8、configure: error: libxpm.(a|so) not found.
centos: yum -y install libxpm-dev
debian: apt-get install libxpm-dev
9、configure: error: freetype.h not found.
centos: yum install freetype-devel
debian: apt-get install libfreetype6-dev
10、configure: error: …No recognized SSL/TLS toolkit detected
centos: yum -y install libssl-dev
debian: apt-get install libssl-dev
11、Configure: error: Please reinstall the BZip2 distribution
centos: yum install bzip2 bzip2-devel
debian: apt-get install bzip2-devel
12、Configure: error: Please reinstall the libcurl distribution – easy.h should be in /include/curl/
centos: yum install curl curl-devel (For Redhat & Fedora)
# install libcurl4-gnutls-dev (For Ubuntu)
13、Configure: error: Unable to locate gmp.h
centos: yum install gmp-devel
14、Configure: error: Cannot find MySQL header files under /usr. Note that the MySQL client library is not bundled anymore!
yum install mysql-devel (For Redhat & Fedora)
# apt-get install libmysql++-dev (For Ubuntu)
15、Configure: error: Please reinstall the ncurses distribution
Solutions :
centos: yum install ncurses ncurses-devel
16、Checking for unixODBC support… configure: error: ODBC header file ‘/usr/include/sqlext.h’ not found!
Solutions :
centos: yum install unixODBC-devel
17、Configure: error: Cannot find pspell
Solutions :
centos: yum install pspell-devel
18、configure: error: mcrypt.h not found. Please reinstall libmcrypt.
Solutions :
yum install libmcrypt libmcrypt-devel (For Redhat & Fedora)
# apt-get install libmcrypt-dev
19、Configure: error: snmp.h not found. Check your SNMP installation.
Solutions :
yum install net-snmp net-snmp-devel
20、开启LDAP服务还需要
yum -y install openldap-devel openldap-servers openldap-clients
21、configure: error: cannot find output from lex; giving up
centos: yum -y install flex
22、configure: error: mod_deflate has been requested but can not be built e to prerequisite failures
centos: yum -y install zlib-devel openssl-devel
debian: apt-get install zlib1g-dev
‘肆’ 求助,centos7编译源码php时加载库的问题
php-fpm参数:
--start 启动
--stop 强制终止
--quit 平滑终止
--restart 重启
--reload 重新平滑加载php的php.ini
--logrotate 重新启用log文件
‘伍’ 编译PHP提示出错找不到libc-client.无法编译PHP怎么办
I. 安装devel库
yum install pam-devel libc-client libc-client-devel -y
如果使用了yum安装了libc-client,那么在以后编译参数--with-imap=/usr/local/php-imap中的路径应该删除,即--with-imap。
如果这样还不能解决,那么就需要手动编译imap2007f了!
II. 手动编译imap2007f
脚本取自 http://forum.directadmin.com/showthread.php?t=45434
在/usr/src目录下运行以下脚本,将会在/usr/local/php-imap目录下生成imap需要的库
#!/bin/sh
# Script for PHP-IMAP installation. 0.1b
# Written by Martynas Bendorius (smtalk)
CWD=`pwd`
OS=`uname`
#Is it a 64-bit OS?
B64=0
B64COUNT=`uname -m | grep -c 64`
if [ "$B64COUNT" -eq 1 ]; then
B64=1
LD_LIBRARY_PATH=/lib64:/usr/lib64:/usr/local/lib64:/lib:/usr/lib:/usr/local/lib
export LD_LIBRARY_PATH
fi
if [ ! -e /usr/include/krb5.h ] && [ -e /etc/redhat-release ]; then
echo "Installing krb5-devel"
yum -y install krb5-devel
fi
VERSION=2007f
PROTOCOL=ftp
URL="${PROTOCOL}://ftp.cac.washington.e/imap/imap-${VERSION}.tar.Z"
FILENAME=imap-${VERSION}
TARBALL=${FILENAME}.tar.Z
echo "Downloading ${TARBALL}..."
wget -O ${TARBALL} ${URL}
tar xzf ${TARBALL}
cd ${FILENAME}
echo "Installing ${FILENAME}..."
if [ ${OS} = "FreeBSD" ]; then
if [ ${B64} -eq 0 ]; then
make bsf
else
make bsf EXTRACFLAGS=-fPIC
fi
else
perl -pi -e 's#SSLDIR=/usr/local/ssl#SSLDIR=/etc/pki/tls#' src/osdep/unix/Makefile
perl -pi -e 's#SSLINCLUDE=\$\(SSLDIR\)/include#SSLINCLUDE=/usr/include/openssl#' src/osdep/unix/Makefile
perl -pi -e 's#SSLLIB=\$\(SSLDIR\)/lib#SSLLIB=/usr/lib/openssl#' src/osdep/unix/Makefile
if [ ${B64} -eq 0 ]; then
make slx
else
make slx EXTRACFLAGS=-fPIC
fi
fi
echo "Copying files to /usr/local/php-imap"
mkdir -p /usr/local/php-imap/include
mkdir -p /usr/local/php-imap/lib
chmod -R 077 /usr/local/php-imap
cp -f c-client/*.h /usr/local/php-imap/include/
cp -f c-client/*.c /usr/local/php-imap/lib/
cp -f c-client/c-client.a /usr/local/php-imap/lib/libc-client.a
cd ..
rm -rf ${FILENAME}
if [ -d /usr/lib/x86_64-linux-gnu ] && [ ! -d /usr/kerberos/lib ]; then
mkdir -p /usr/kerberos
ln -s /usr/lib/x86_64-linux-gnu /usr/kerberos/lib
fi
exit 0;
III. 开始编译
下面是编译PHP的参数,如果出现问题,请参考编译PHP5.6 和 PHP编译错误的解决办法。
./configure --prefix=/usr/local/php --with-pdo-pgsql --with-zlib-dir --with-freetype-dir --enable-mbstring --with-libxml-dir=/usr --enable-soap --enable-calendar --with-curl --with-mcrypt --with-zlib --with-gd --with-pgsql --disable-rpath --enable-inline-optimization --with-bz2 --with-zlib --enable-sockets --enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex --enable-exif --enable-bcmath --with-mhash --enable-zip --with-pcre-regex --with-mysql --with-pdo-mysql --with-mysqli --with-jpeg-dir=/usr --with-png-dir=/usr --enable-gd-native-ttf --with-openssl --enable-ftp --with-imap=/usr/local/php-imap --with-imap-ssl --with-kerberos --with-gettext --with-xmlrpc --with-xsl --enable-opcache --enable-fpm --with-fpm-user=www --with-fpm-group=www --disable-fileinfo
IV. 其他问题
在本次编译中,老高又遇到了几个怪事
set --enable-opcache=no
configure: error: Don't know how to define struct flock on this system, set --enable-opcache=no
这个问题还是库文件的链接问题
解决:
echo /usr/local/lib > /etc/ld.so.conf.d/local.conf
ldconfig -v
让编译的PHP支持memcache
‘陆’ linux下安装php编译参数
在Linux下安装PHP,源代码方式安装,总需要配置很多参数。这里列出常用配置参数,并详细用中文解释说明了。给大家一些参考./configure
--prefix=/usr/local/php
php
安装目录
--with-apxs2=/usr/local/apache/bin/apxs
--with-config-file-path=/usr/local/php/etc
指定php.ini位置
--with-MySQL=/usr/local/mysql
mysql安装目录,对mysql的支持
--with-mysqli=/usr/local/mysql/bin/mysql_config
mysqli文件目录,优化支持
--enable-safe-mode
打开安全模式
--enable-ftp
打开ftp的支持
--enable-zip
打开对zip的支持
--with-bz2
打开对bz2文件的支持
--with-jpeg-dir
打开对jpeg图片的支持
--with-png-dir
打开对png图片的支持
--with-freetype-dir
打开对freetype字体库的支持
--without-iconv
关闭iconv函数,种字符集间的转换
--with-libXML-dir
打开libxml2库的支持
--with-xmlrpc
打开xml-rpc的c语言
--with-zlib-dir
打开zlib库的支持
--with-gd
打开gd库的支持
--enable-gd-native-ttf
支持TrueType字符串函数库
--with-curl
打开curl浏览工具的支持
--with-curlwrappers
运用curl工具打开url流
--with-ttf
打开freetype1.*的支持,可以不加了
--with-xsl
打开XSLT
文件支持,扩展了libxml2库
,需要libxslt软件
--with-gettext
打开gnu
的gettext
支持,编码库用到
--with-pear
打开pear命令的支持,php扩展用的
--enable-calendar
打开日历扩展功能
--enable-mbstring
多字节,字符串的支持
--enable-bcmath
打开图片大小调整,用到zabbix监控的时候用到了这个模块
--enable-sockets
打开
sockets
支持
--enable-exif
图片的元数据支持
--enable-magic-quotes
魔术引用的支持
--disable-rpath
关闭额外的运行库文件
--disable-debug
关闭调试模式
--with-mime-magic=/usr/share/file/magic.mime
魔术头文件位置
CGI方式安装才用的参数
--enable-fpm
打上php-fpm
补丁后才有这个参数,cgi方式安装的启动程序
--enable-fastcgi
支持fastcgi方式启动php
--enable-force-cgi-redirect
同上
,帮助里没有解释
--with-ncurses
支持ncurses
屏幕绘制以及基于文本终端的图形互动功能的动态库
--enable-pcntl
freeTDS需要用到的,可能是链接mssql
才用到
mhash和mcrypt算法的扩展
--with-mcrypt
算法
--with-mhash
算法
--with-gmp
--enable-inline-optimization
--with-openssl
openssl的支持,加密传输时用到的
--enable-dbase
--with-pcre-dir=/usr/local/bin/pcre-config
perl的正则库案安装位置
--disable-dmalloc
--with-gdbm
dba的gdbm支持
--enable-sigchild
--enable-sysvsem
--enable-sysvshm
--enable-zend-multibyte
支持zend的多字节
--enable-mbregex
--enable-wddx
--enable-shmop
--enable-soap
‘柒’ 哪些是编译php时的常用configure参数
分版本的,不同版本有一点点区别。大部分都是一样的。
比如PHP7.1.5可以参考以下:
./configure --prefix=/ueidc/php715 --with-config-file-path=/ueidc/php715/ --with-config-file-scan-dir=/ueidc/php715/etc --with-openssl=/ueidc/openssl110f --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-mysqlnd --enable-sockets --enable-mbstring --enable-fpm --enable-soap --enable-gd-native-ttf --enable-opcache=no --with-gettext --with-png-dir=/ueidc/libpng162 --with-jpeg-dir=/ueidc/jpeg9 --with-zlib-dir=/ueidc/zlib128 --with-libxml-dir=/ueidc/libxml228 --with-mhash=/ueidc/mhash099 --with-curl=/ueidc/curl7531 --with-gd=/ueidc/gd210 --with-mcrypt=/ueidc/libmcrypt257 --with-freetype-dir=/ueidc/freetype254 -with-iconv-dir=/ueidc/libiconv115
‘捌’ 在编译 php 时,为了使用 php 内置的 fpm 功能,应该使用什么参数
php5.3.3以后源码中已经内嵌了php-fpm,不用象以前的php版本一样专门打补丁了,只需要在configure的时候添加编译参数即可。关于php-fpm的编译参数有–enable-fpm–with-fpm-user=www–with-fpm-group=www–with-libevent-dir=libevent位置。但是,php5.3.3以后的php-fpm不再支持php-fpm以前具有的/usr/local/php/sbin/php-fpm(start|stop|reload)等命令,需要使用信号控制:master进程可以理解以下信号:INT,TERM立刻终止QUIT平滑终止USR1重新打开日志文件USR2平滑重载所有worker进程并重新载入配置和二进制模块有了以上信号,php-fpm进程重启就方便多了。例子:php-fpm关闭:代码示例:kill-INT`cat/usr/local/php/var/run/php-fpm.pid`php-fpm重启:代码示例:kill-USR2`cat/usr/local/php/var/run/php-fpm.pid`说明:cat部分是php-fpm的进程号,可能是我用的5.4的问题。没有用php-fpm.pid,就没有这个文件。可以用psaux|grepphp-fpm,使用第一个进程的进程号,测试可行。
‘玖’ 编译安装php时怎么使用源码安装的参数
1、Linux下,默认是在/usr/local/bin/,假如你设置--prefix=/usr/local/php那么就在/usr/local/php/bin/ 2、sbin道理相同。sbin的意思就是server bin 3、EPREFIX没用过 4、如果要用2套版本,用prefix区分开不同的安装目录。
‘拾’ PHP编译时需要同时支持gd jpeg freetype什么意思
gd库:一个图片处理的php内置
既然你知道编译php那么什么是依赖我就不说了,如果你不用php自带的gd库,那么--without-gd
同样的,如果你要编译时带了参数--with-gd那么,就老老实实的装jpeg,libpng和freetype吧
最好加上:
--enable-gd-native-ttf
这个参数,允许gd中使用自定义字体