安云网 - AnYun.ORG | 专注于网络信息收集、网络数据分享、网络安全研究、网络各种猎奇八卦。
当前位置: 安云网 > 技术关注 > 系统文档 > Linux环境下PHP安装

Linux环境下PHP安装

时间:2014-06-24来源: 作者:点击:
Linux环境下PHP安装 1.1.   安装基本程序   [[email protected] src]# yum install -y bison bison-devel ncurses ncurses-devel zlib zlib-devel libpng libpng-devel libxml* openssl openssl-devel gcc gcc-c++ cmake 以下为单独安装支持图形处理

Linux环境下PHP安装

1.1.  安装基本程序

 [[email protected] src]# yum install -y bison bison-devel ncurses ncurses-devel zlib zlib-devel libpng libpng-devel libxml* openssl openssl-devel gcc gcc-c++ cmake

  //内容来自安云网

以下为单独安装支持图形处理,自己可以找最新的安装

//copyright AnYun.ORG

1.2.  安装zlib

[[email protected] src]# wget http://sourceforge.net/projects/libpng/files/zlib/1.2.5/zlib-1.2.5.tar.gz/download //本文来自安云网

[[email protected] src]# tar -zxvf zlib-1.2.5.tar.gz //安云网咨询系统

[[email protected] src]# cd zlib-1.2.5

//安云网咨询系统

[[email protected] zlib-1.2.5]#./configure –prefix=/usr/local/zlib –shared //ANYUN.ORG

[[email protected] zlib-1.2.5]# make //安云网咨询系统

[[email protected] zlib-1.2.5]# make install //copyright AnYun.ORG

[[email protected] zlib-1.2.5]# ln -sf /usr/local/zlib/lib/libz.so.1.2.5 /usr/lib/libz.so

//安云网咨询系统

[[email protected] zlib-1.2.5]# ln -sf /usr/local/zlib/lib/libz.so.1.2.5 /usr/lib/libz.so.1

1.3.  安装FreeType

[[email protected] src]# wget http://sourceforge.net/projects/freetype/files/freetype2/2.4.8/freetype-2.4.8.tar.gz/download

//ANYUN.ORG

[[email protected] src]# tar -zxvf freetype-2.4.8.tar.gz

//内容来自安云网

[[email protected] src]# cd freetype-2.4.8

//ANYUN.ORG

[[email protected] freetype-2.4.8]# ./configure –prefix=/usr/local/freetype //安云网咨询系统

[[email protected] freetype-2.4.8]# make //内容来自AnYun.ORG

[[email protected] freetype-2.4.8]# make install

1.4.  安装LibPNG

[[email protected] src]# wget http://prdownloads.sourceforge.net/libpng/libpng-1.5.5.tar.gz?download //本文来自安云网

[[email protected] src]# tar -zxvf libpng-1.5.5.tar.gz //安云网,anyun.org

[[email protected] src]# cd libpng-1.5.5 //安云网,anyun.org

[[email protected] libpng-1.5.5]# ./configure –prefix=/usr/local/libpng //本文来自安云网

[[email protected] libpng-1.5.5]# make //安云网咨询系统

[[email protected] libpng-1.5.5]# make install

1.5.  安装Jpeg

[[email protected] src]# wget http://www.ijg.org/files/jpegsrc.v8c.tar.gz //内容来自安云网

[[email protected] src]# tar -zxvf jpegsrc.v8c.tar.gz //内容来自AnYun.ORG

[[email protected] src]# cd jpeg-8c //ANYUN.ORG

[[email protected] jpeg-8c]# mkdir /usr/local/jpeg

//ANYUN.ORG

[[email protected] jpeg-8c]# mkdir /usr/local/jpeg/bin //copyright AnYun.ORG

[[email protected] jpeg-8c]# mkdir /usr/local/jpeg/lib //安云网咨询系统

[[email protected] jpeg-8c]# mkdir /usr/local/jpeg/include //copyright AnYun.ORG

[[email protected] jpeg-8c]# mkdir /usr/local/jpeg/man

//内容来自AnYun.ORG

[[email protected] jpeg-8c]# mkdir /usr/local/jpeg/man/man1

//本文来自安云网

[[email protected] jpeg-8c]# ./configure –prefix=/usr/local/jpeg –enable-shared –enable-static //安云网咨询系统

[[email protected] jpeg-8c]# make

//本文来自安云网

[[email protected] jpeg-8c]# make install

1.6.  安装gd(php已自带)

[[email protected] src]# yum remove gd //内容来自AnYun.ORG

[[email protected] src]# wget http://google-desktop-for-linux-mirror.googlecode.com/files/gd-2.0.35.tar.gz

//本文来自安云网

[[email protected] src]# tar -zxvf gd-2.0.35.tar.gz //copyright AnYun.ORG

[[email protected] src]# cd gd/2.0.35

//安云网,anyun.org

[[email protected] 2.0.35]# ./configure –prefix=/usr/local/gd –with-jpeg=/usr/local/jpeg –with-freetype=/usr/local/freetype –with-png=/usr/local/libpng

//ANYUN.ORG

[[email protected] 2.0.35]# make

//安云网,anyun.org

[[email protected] 2.0.35]# make install

若安装过程中,出现以下错误: //ANYUN.ORG

make[2]: *** [gd_png.lo] Error 1

//内容来自安云网

make[2]: Leaving directory `/usr/local/src/gd/2.0.35′ //内容来自安云网

make[1]: *** [all-recursive] Error 1 //本文来自安云网

make[1]: Leaving directory `/usr/local/src/gd/2.0.35′

//安云网,anyun.org

make: *** [all] Error 2 //内容来自安云网

 

//ANYUN.ORG

找到“png.h”改成“/usr/local/libpng/include/png.h //ANYUN.ORG

//安云网,anyun.org

[[email protected] src]# vi /usr/local/src/gd/2.0.35/gd_png.c //copyright AnYun.ORG

将第十六行 //内容来自安云网

#include “png.h” //本文来自安云网

改为:

//copyright AnYun.ORG

#include “/usr/local/libpng/include/png.h” //本文来自安云网

然后再: //copyright AnYun.ORG

[[email protected] 2.0.35]# ./configure –prefix=/usr/local/gd –with-jpeg=/usr/local/jpeg –with-freetype=/usr/local/freetype –with-png=/usr/local/libpng

//本文来自安云网

[[email protected] 2.0.35]# make

//安云网咨询系统

[[email protected] 2.0.35]# make install

  //内容来自AnYun.ORG

1.7.  安装libmcrypt

[[email protected] src]# wget http://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz/download

//内容来自安云网

[[email protected] src]# tar -zxvf libmcrypt-2.5.8.tar.gz

//安云网,anyun.org

[[email protected] src]# cd libmcrypt-2.5.8

//ANYUN.ORG

[[email protected] libmcrypt-2.5.8]# ./configure –prefix=/usr/local/libmcrypt

//安云网,anyun.org

[[email protected] libmcrypt-2.5.8]# make //ANYUN.ORG

[[email protected] libmcrypt-2.5.8]# make install

1.8.  安装mhash

[[email protected] src]# wget http://sourceforge.net/projects/mhash/files/mhash/0.9.9.9/mhash-0.9.9.9.tar.gz/download

//ANYUN.ORG

[[email protected] src]# tar -zxvf mhash-0.9.9.9.tar.gz //本文来自安云网

[[email protected] src]# cd mhash-0.9.9.9 //内容来自AnYun.ORG

[[email protected] mhash-0.9.9.9]# ./configure //本文来自安云网

[[email protected] mhash-0.9.9.9]# make //内容来自AnYun.ORG

[[email protected] mhash-0.9.9.9]# make install

1.9.  安装mcrypt

[[email protected] src]# wget http://sourceforge.net/projects/mcrypt/files/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz/download //安云网,anyun.org

[[email protected] src]# tar -zxvf  mcrypt-2.6.8.tar.gz //安云网,anyun.org

[[email protected] src]# cd mcrypt-2.6.8 //安云网,anyun.org

[[email protected] mcrypt-2.6.8]# ./configure –prefix=/usr/local/mcrypt –with-libmcrypt-prefix=/usr/local/libmcrypt //内容来自AnYun.ORG

[[email protected] mcrypt-2.6.8]# make //copyright AnYun.ORG

[[email protected] mcrypt-2.6.8]# make install

若安装过程中,出现以下错误: //本文来自安云网

checking for libmcrypt-config… /usr/local/libmcrypt/bin/libmcrypt-config //安云网,anyun.org

checking for libmcrypt – version >= 2.5.0… no

//ANYUN.ORG

*** Could not run libmcrypt test program, checking why… //安云网咨询系统

*** The test program compiled, but did not run. This usually means //本文来自安云网

*** that the run-time linker is not finding LIBMCRYPT or finding the wrong

//copyright AnYun.ORG

*** version of LIBMCRYPT. If it is not finding LIBMCRYPT, you’ll need to set your //安云网,anyun.org

*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point

//安云网,anyun.org

*** to the installed location  Also, make sure you have run ldconfig if that //安云网咨询系统

*** is required on your system //内容来自安云网

*** //copyright AnYun.ORG

*** If you have an old version installed, it is best to remove it, although //copyright AnYun.ORG

*** you may also be able to get things to work by modifying LD_LIBRARY_PATH //copyright AnYun.ORG

*** //安云网咨询系统

configure: error: *** libmcrypt was not found //内容来自安云网

如果自己在安装libmcryptmhash时,指定了–prefix,则binincludeshare以及lib目录都会放置到自己指定的目录下。如果没有指定,默认情况下,bin目录下的文件放到 /usr/local/bin下,lib目录下的文件放置到/usr/local/lib下,bin同理放到/usr/local/bin下。 //安云网,anyun.org

以我的Redhat5.x为例:libmcrypt安装到/usr/local/libmcrypt目录下,而mhash是默认安装的。

//copyright AnYun.ORG

 [[email protected] mcrypt-2.6.8]# LD_LIBRARY_PATH=/usr/local/libmcrypt/lib:/usr/local/lib ./configure –with-libmcrypt-prefix=/usr/local/libmcrypt

//安云网咨询系统

[[email protected] mcrypt-2.6.8]# make

//安云网,anyun.org

[[email protected] mcrypt-2.6.8]# make install

1.10.     安装PHP

[[email protected] src]# yum remove php* //安云网咨询系统

[[email protected] src]# wget http://cn.php.net/get/php-5.4.4.tar.bz2/from/cn2.php.net/mirror //内容来自AnYun.ORG

[[email protected] src]# tar -jxvf php-5.4.4.tar.bz2 //内容来自AnYun.ORG

[[email protected] src]# cd php-5.4.4 //copyright AnYun.ORG

[[email protected] src]# yum -y install gdbm gdbm-devel libxml2 libxml2-devel curl curl-devel openldap openldap-devel libtool libmcrypt libmcrypt-devel 

//内容来自安云网

[[email protected] php-5.4.4]# ./configure –prefix=/usr/local/php –with-config-file-path=/usr/local/php/etc –with-mysql=/usr/local/mysql –with-gdbm=/usr/lib –enable-gd-native-ttf –enable-gd-jis-conv –with-freetype-dir=/usr/local/freetype –with-jpeg-dir=/usr/local/jpeg –with-png-dir=/usr/local/libpng –with-zlib –with-mhash –enable-sockets –enable-ftp –with-libxml-dir –enable-xml –disable-rpath –enable-bcmath –enable-shmop –enable-sysvsem -enable-inline-optimization –with-curl –with-curlwrappers –enable-mbregex  –enable-fpm –enable-mbstring –with-mcrypt –with-openssl –with-mhash –enable-pcntl –enable-sockets –with-ldap –with-ldap-sasl –with-xmlrpc –enable-zip –enable-soap –with-pear  –enable-pdo –with-pdo-mysql –with-gettext –enable-exif –enable-wddx –enable-calendar –enable-ftp  –enable-dba –enable-sysvmsg  –enable-sysvshm –enable-debug –enable-embed –with-pcre-regex #FastCGI模式

//内容来自AnYun.ORG

//内容来自AnYun.ORG

[[email protected] php-5.4.4]# ./configure –prefix=/usr/local/php –with-config-file-path=/usr/local/php/etc –with-apxs2 //本文来自安云网

=/usr/local/apache2/bin/apxs –with-mysql=/usr/local/mysql –with-gd=/usr/local/gd –with-gdbm=/usr/lib –enable-gd-native-ttf –with-freetype-dir=/usr/local/freetype –with-jpeg-dir=/usr/local/jpeg –with-png-dir=/usr/local/libpng –with-zlib=/usr/local/zlib –with-mhash –enable-sockets –enable-ftp –with-libxml-dir –enable-xml –disable-rpath –enable-bcmath –enable-shmop –enable-sysvsem -enable-inline-optimization –with-curl –with-curlwrappers –enable-mbregex –enable-mbstring  –with-openssl –with-mhash –enable-pcntl –enable-sockets –with-ldap –with-ldap-sasl –with-xmlrpc –enable-zip –enable-soap  #CGI模式

//安云网咨询系统

[[email protected] php-5.4.4]# make

//内容来自AnYun.ORG

[[email protected] php-5.4.4]# make install

//安云网咨询系统

[[email protected] php-5.4.4]# libtool –finish /usr/local/src/php-5.4.4/libs

//安云网咨询系统

[[email protected] php-5.4.4]# chmod 755 /usr/local/apache2/modules/libphp5.so

//安云网咨询系统

[[email protected] php-5.4.4]# cp php.ini-production /usr/local/php/etc/php.ini //安云网,anyun.org

[[email protected] php-5.4.4]# cp /usr/local/php/etc/php.ini /usr/local/php/etc/php.ini.old

make后出现以下错误:

//内容来自安云网

PEAR package PHP_Archive not installed: generated phar will require PHP’s phar extension be enabled. //安云网,anyun.org

//本文来自安云网

[[email protected] php-5.4.4]# wget http://pear.php.net/go-pear -O go-pear.php

//本文来自安云网

[[email protected] php-5.4.4]# /usr/local/php/bin/php go-pear.php

//安云网咨询系统

 make后出现以下错误:

//安云网,anyun.org

In file included from /usr/local/src/php-5.4.4/ext/gd/libgd/gd_compat.c:8: //本文来自安云网

/usr/local/jpeg/include/jpeglib.h:954: error: expected declaration specifiers or ‘…’ before ‘FILE’

//内容来自AnYun.ORG

/usr/local/jpeg/include/jpeglib.h:955: error: expected declaration specifiers or ‘…’ before ‘FILE’

//安云网,anyun.org

make: *** [ext/gd/libgd/gd_compat.lo] Error 1 //本文来自安云网

//ANYUN.ORG

[[email protected] src]# vi /usr/local/src/php-5.4.4/ext/gd/libgd/gd_compat.c

//内容来自安云网

将第八行

//ANYUN.ORG

# include <jpeglib.h> //本文来自安云网

改为: //安云网,anyun.org

# include </usr/local/jpeg/include/jpeglib.h> //安云网,anyun.org

然后再: //安云网咨询系统

 [[email protected] php-5.4.4]# ./configure –prefix=/usr/local/php –with-config-file-path=/usr/local/php/etc –with-apxs2=/usr/local/apache2/bin/apxs –with-mysql=/usr/local/mysql –with-gdbm=/usr/lib –enable-gd-native-ttf –with-freetype-dir=/usr/local/freetype –with-jpeg-dir=/usr/local/jpeg –with-png-dir=/usr/local/libpng –with-zlib=/usr/local/zlib –with-mhash –enable-sockets –enable-ftp –with-libxml-dir –enable-xml –disable-rpath –enable-bcmath –enable-shmop –enable-sysvsem -enable-inline-optimization –with-curl –with-curlwrappers –enable-mbregex –enable-mbstring  –with-openssl –with-mhash –enable-pcntl –enable-sockets –with-ldap –with-ldap-sasl –with-xmlrpc –enable-zip –enable-soap  #CGI模式 //安云网,anyun.org

[[email protected] php-5.4.4]# make clean

//安云网咨询系统

[[email protected] php-5.4.4]# make

//copyright AnYun.ORG

[[email protected] php-5.4.4]# make install //ANYUN.ORG

[[email protected] php-5.4.4]# libtool –finish /usr/local/src/php-5.4.4/libs //安云网咨询系统

 make后出现以下错误: //安云网咨询系统

Generating phar.php

//本文来自安云网

/usr/local/src/php-5.4.4/sapi/cli/php: error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory

//ANYUN.ORG

make: *** [ext/phar/phar.php] Error 127

//copyright AnYun.ORG

//安云网,anyun.org

[[email protected] php-5.4.4]# ln -s /usr/local/mysql/lib/libmysqlclient.so.18  /usr/lib/

//内容来自AnYun.ORG

[[email protected] php-5.4.4]# make clean

//安云网咨询系统

[[email protected] php-5.4.4]# make

//内容来自AnYun.ORG

[[email protected] php-5.4.4]# make install //copyright AnYun.ORG

 make后出现以下错误: //内容来自安云网

make: *** [sapi/cli/php] Error 1 //本文来自安云网

//内容来自安云网

[[email protected] php-5.4.4]# make clean //安云网,anyun.org

[[email protected] php-5.4.4]# make //本文来自安云网

[[email protected] php-5.4.4]# make install //安云网咨询系统

  //内容来自AnYun.ORG

修改配置文件 //安云网,anyun.org

[[email protected] php-5.4.4]#vi /usr/local/php/etc/php.ini

找到include_path = “.:/php/includes ” 这一行,并修改为:

//内容来自AnYun.ORG

include_path = “.:/usr/local/php/includes” //ANYUN.ORG

 

//copyright AnYun.ORG

php.ini默认关掉了短标记,只能用<?php ?>

//内容来自安云网

解决方法: //安云网咨询系统

php.ini里修改 //内容来自安云网

查找

//ANYUN.ORG

short_open_tag = Off //ANYUN.ORG

改为

//内容来自AnYun.ORG

short_open_tag = On //ANYUN.ORG

  //内容来自AnYun.ORG

1.11.     配置php-fpm

 

//内容来自安云网

修改php-fpm.conf

//copyright AnYun.ORG

[[email protected] php-5.4.4]# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf

//本文来自安云网

[[email protected] php-5.4.4]# vi /usr/local/php/etc/php-fpm.conf

根据需要调整参数,即修改下面几行的内容数值为: //内容来自安云网

pid = run/php-fpm.pid

//内容来自AnYun.ORG

user = nginx

//内容来自AnYun.ORG

group = www

//安云网咨询系统

pm.max_children = 300 //ANYUN.ORG

pm.start_servers = 20 //安云网咨询系统

pm.min_spare_servers = 40 //安云网,anyun.org

pm.max_spare_servers = 60 //ANYUN.ORG

pm.max_requests = 3000

//内容来自AnYun.ORG

启动php-fpm并在后台运行 //ANYUN.ORG

[[email protected] php-5.4.4]# /usr/local/php/sbin/php-fpm &

若启动时出现:

//copyright AnYun.ORG

Segmentation fault (段错误)

//ANYUN.ORG

原因是:开启了PHP的线程安全模式,参数是 configure –enable-maintainer-zts,从而让部分PHP的扩展组件(EA,即eaccelerator.so)不能在线程安全模式下很好地工作导致的 //copyright AnYun.ORG

解决:configure时去掉 –enable-maintainer-zts

//本文来自安云网

检查php-fpm配置语法是否正确

//内容来自安云网

[[email protected] php-5.4.4]# /usr/local/php/sbin/php-fpm -t

若出现NOTICE: configuration file  /usr/local/php/etc/php-fpm.conf test is successful 说明测试成功

//内容来自AnYun.ORG

 

//本文来自安云网

设置开机启动 //copyright AnYun.ORG

[[email protected] php-5.4.4]# vi /etc/rc.d/rc.local

在行末加入: //安云网咨询系统

/usr/local/php/sbin/php-fpm & //安云网,anyun.org

  //ANYUN.ORG

关闭php-fpm //本文来自安云网

[root@os11728 php-5.4.4]# kill -INT `cat  /usr/local/php/var/run/php-fpm.pid`

  //安云网,anyun.org

重启php-fpm //安云网,anyun.org

[root@os11728 php-5.4.4]# kill -USR2 `cat /usr/local/php/var/run/php-fpm.pid`

此处我们也可以不用cat /usr/local/php/var/run/php-fpm.pid来查看主进程号,面通过ps -eaf命令来查看主进程号

//内容来自安云网

 

//安云网咨询系统

查看php-fpm进程总数:

//内容来自AnYun.ORG

[root@os11728 php-5.4.4]# ps -A | grep php-fpm |wc -l

 

//安云网,anyun.org

1.12.     PHP设置apache

 

//安云网,anyun.org

[root@os11728 php-5.4.4]#vi /usr/local/apache2/conf/httpd.conf

1)设置php文件后缀及解析器

//安云网咨询系统

查找 “IfModule mime_module” 并在里面添加下面代码:

//内容来自安云网

  //ANYUN.ORG

<IfModule mime_module>
//安云网,anyun.org

ScriptAlias /fcgi-bin/ “/usr/local/php/bin/”   #定义目录映射 //ANYUN.ORG

AddType application/x-httpd-php .php //安云网,anyun.org

AddHandler php-fastcgi .php   #.php结尾的请求都要用php-fastcgi来处理 //内容来自安云网

Action php-fastcgi /fcgi-bin/php-cgi    #设置php-fastcgi的解释器。

//本文来自安云网

</IfModule> //安云网咨询系统

 

 

//内容来自AnYun.ORG

2)添加FastCGIExternalServer及目录属性 //ANYUN.ORG

<IfModule fastcgi_module>

//本文来自安云网

  FastCGIExternalServer /fcgi-bin/php-cgi -host 127.0.0.1:9000 #配置fastcgi外部server127.0.0.1:9000地址为php-fpm的监听地址。或:FastCGIExternalServer /usr/local/php/sbin/php-fpm -host 127.0.0.1:9000 //安云网,anyun.org

</IfModule> //内容来自安云网

 

//内容来自AnYun.ORG

 

//内容来自安云网

<Directory “/usr/local/php/bin/”> //内容来自安云网

Options none //安云网咨询系统

Order allow,deny

//本文来自安云网

Allow from all

//ANYUN.ORG

</Directory>

  //安云网,anyun.org

 

//安云网,anyun.org

 

//安云网,anyun.org

新建PHP测试文件info.php,内容为:

//内容来自安云网

<?php //ANYUN.ORG

echo phpinfo();

//ANYUN.ORG

?>

//安云网,anyun.org

浏览器输入地址:http://WebServer IP/info.php //内容来自AnYun.ORG

检测PHP是否安装成功。 //内容来自安云网

  //安云网咨询系统

查看正在运行的PHP进程: //安云网,anyun.org

[root@os11728 php-5.4.4]# ps aux|grep php

  //安云网咨询系统

注:安装PHP后,若系统环境变量未加入apachectl,则需使用绝对路径启动apache

//内容来自AnYun.ORG

//内容来自安云网

/usr/local/apache2/bin/apachectl start //内容来自AnYun.ORG

否则有可能出现下载PHP文件提示。 //安云网,anyun.org

  //本文来自安云网

若安装过程中出现以下错误:

//内容来自AnYun.ORG

//安云网,anyun.org

是由于libtool版本不一致造成的。

//本文来自安云网

apache 目录build下面的libtool拷贝到了php编译安装的目录下,重新make clean make  make install,就行了。 //内容来自安云网

  //安云网,anyun.org

比如我的apache安装在/usr/local/apache/ php-5.4.4为下载的php解压目录 //本文来自安云网

cp /usr/local/apache/build/libtool php-5.4.4/

//安云网咨询系统

———————————————- //本文来自安云网

PHP Compilation ERROR “:configure: error: DBA: Could not find necessary header file(s).” //内容来自安云网

因为目前新版本 php5 默认不支持DBA qdbmgdbm等等),所以我们需要手工配置变异,如果大家在编译php时出错PHP Compilation ERROR :configure: error: DBA: Could not find necessary header file(s). //ANYUN.ORG

原因是因为缺少:qdbm开发包。 //内容来自安云网

 ———————————————- //内容来自AnYun.ORG

下面这个是关于gdbm的。 //内容来自安云网

  //copyright AnYun.ORG

For redhat users # yum install gdbm-devel

//内容来自安云网

For ubuntu users # apt-get install libgdbm-dev //内容来自AnYun.ORG

 

//copyright AnYun.ORG

  //安云网,anyun.org

  //本文来自安云网

帮助输出:.configure –help > /tem/xxx.txt //内容来自AnYun.ORG

 

//安云网,anyun.org

 

//本文来自安云网

———————————————-

//安云网,anyun.org

关于php编译时SAPI错误

//ANYUN.ORG

———————————————-

//安云网,anyun.org

关于php编译时SAPI错误错误截图如下: //安云网咨询系统

 

//内容来自安云网

关于php编译时SAPI错误You’ve configured multiple SAPIs to be build.You can build only one SAPI module and CLI binary at the same time.(你已经配置了多个SAPIs,你只可以建立一个SAPI模块和一个CLI binary。) //内容来自安云网

导致的原因是我的配置参数中同时使用了–enable-fpm –with-apxs2= ,因此编译的时候出错了,去掉其中的任意一个参数编译成功。

//本文来自安云网

  //本文来自安云网

 

//本文来自安云网

1.13.     安装PHP扩展之memcache

 [root@os11728 ~]#cd /usr/local/src

//copyright AnYun.ORG

[root@os11728 src]# wget http://pecl.php.net/get/memcache-3.0.6.tgz //内容来自安云网

[root@os11728 src]# tar -zxvf memcache-3.0.6.tgz

//内容来自AnYun.ORG

或:

//ANYUN.ORG

[root@os11728 src]# svn export –force http://svn.php.net/repository/pecl/memcache/trunk memcache-3.0.6

//内容来自安云网

  //copyright AnYun.ORG

[root@os11728 src]#cd memcache-3.0.6 //安云网,anyun.org

[root@os11728 memcache-3.0.6]# /usr/local/php/bin/phpize //安云网咨询系统

[root@os11728 memcache-3.0.6]# ./configure –enable-memcache –with-php-config=/usr/local/php/bin/php-config –with-zlib-dir

//内容来自安云网

[root@os11728 memcache-3.0.6]#make

//内容来自安云网

[root@os11728 memcache-3.0.6]#make install

make过程中出现以下错误: //安云网,anyun.org

In file included from /usr/local/php/include/php/main/php.h:34,

//ANYUN.ORG

                 from /usr/local/src/memcache-3.0.6/memcache.c:26:

//内容来自安云网

/usr/local/php/include/php/Zend/zend.h:576:1: warning: this is the location of the previous definition //内容来自安云网

/usr/local/src/memcache-3.0.6/memcache.c: In function 鈥榤mc_find_persistent

//安云网咨询系统

                                                                               /usr/local/src/memcache-3.0.6/memcache.c:721: error: too few arguments to function 鈥榸end_list_insert

//内容来自安云网

/usr/local/src/memcache-3.0.6/memcache.c:738: error: too few arguments to function 鈥榸end_list_insert //本文来自安云网

/usr/local/src/memcache-3.0.6/memcache.c: In function 鈥榩hp_mmc_pool_addserver

//安云网咨询系统

                                                         /usr/local/src/memcache-3.0.6/memcache.c:778: error: too few arguments to function 鈥榸end_list_insert //ANYUN.ORG

/usr/local/src/memcache-3.0.6/memcache.c: In function 鈥榩hp_mmc_connect

//copyright AnYun.ORG

                                                                                /usr/local/src/memcache-3.0.6/memcache.c:839: error: too few arguments to function 鈥榸end_list_insert

//ANYUN.ORG

make: *** [memcache.lo] Error 1 //内容来自安云网

则到http://svn.php.net/viewvc/pecl/memcache/trunk/ //安云网咨询系统

memcache.c下载下来覆盖3.0.6的里的memcache.c,然后再重编译 //安云网咨询系统

在该目录下生成memcache.so,将其复制到php.iniextension_dir指向的目录。 //ANYUN.ORG

然后编辑 php.ini文件 //内容来自安云网

[root@os11728 src] # vim /usr/local/php/etc/php.ini

增加行extension = memcache.so重启apache

//本文来自安云网

1.14.      安装PHP扩展之ImageMagick

先安装ImageMagick相关套件

//内容来自安云网

[root@os11728 src]# yum -y install ImageMagick ImageMagick-devel

 

//安云网,anyun.org

安装基本程序

//ANYUN.ORG

 [root@os11728 src]# yum install -y bison bison-devel ncurses ncurses-devel zlib-devel libxml* openssl openssl-devel gcc gcc-c++ cmake

 

//安云网,anyun.org

安装re2c

//内容来自AnYun.ORG

 [root@os11728 src]# wget http://sourceforge.net/projects/re2c/files/re2c/0.13.5/re2c-0.13.5.tar.gz/download
//内容来自AnYun.ORG

[root@os11728 src]# tar -zxvf re2c-0.13.5.tar.gz //安云网,anyun.org

[root@os11728 src]# cd re2c-0.13.5

//安云网,anyun.org

[root@os11728 re2c-0.13.5#./configure //安云网,anyun.org

[root@os11728 re2c-0.13.5]# make

//内容来自安云网

[root@os11728 re2c-0.13.5]# make install

  //copyright AnYun.ORG

安装imagick

//copyright AnYun.ORG

 [root@os11728 src]# wget http://pecl.php.net/get/imagick-3.1.0RC2.tgz
//安云网咨询系统

[root@os11728 src]# tar -zxvf imagick-* //安云网,anyun.org

或: //内容来自安云网

[root@os11728 src]# svn export –force http://svn.php.net/repository/pecl/imagick/trunk/ imagick-3.1.0 //copyright AnYun.ORG

 

//安云网,anyun.org

[root@os11728 src]# cd imagick-*

//copyright AnYun.ORG

[root@os11728 imagick-3.1.0RC2]# /usr/local/php/bin/phpize

//内容来自AnYun.ORG

[root@os11728 imagick-3.1.0RC2]#./configure –prefix=/usr/local/imagick –with-php-config=/usr/local/php/bin/php-config //安云网咨询系统

[root@os11728 imagick-3.1.0RC2]# make //安云网咨询系统

[root@os11728 imagick-3.1.0RC2]# make install

(注:若此步报类似:-bash: phpize: command not found -bash: /usr/bin/phpize: No such file or directory 的错误,则需执行命令:#yum -y install php-devel 安装php-devel //安云网咨询系统

configure后出现以下错误信息: //内容来自安云网

configure: error: Cannot locate header file MagickWand.h //内容来自安云网

则:

//内容来自安云网

[root@os11728 imagick-3.1.0RC2] # vi configure

查找‘MagickWand.h’,找到有价值结果如下:

//内容来自AnYun.ORG

  if test -z “$IMAGICK_AFTER_BWC_BREAK”; then //内容来自AnYun.ORG

    { $as_echo “$as_me:${as_lineno-$LINENO}: checking for magick-wand.h header file” >&5

//本文来自安云网

$as_echo_n “checking for magick-wand.h header file… ” >&6; }

//内容来自AnYun.ORG

    if test -r $WAND_DIR/include/wand/magick-wand.h; then //ANYUN.ORG

      { $as_echo “$as_me:${as_lineno-$LINENO}: result: found in $WAND_DIR/include/wand/magick-wand.h” >&5

//内容来自AnYun.ORG

$as_echo “found in $WAND_DIR/include/wand/magick-wand.h” >&6; }

//ANYUN.ORG

        else

//内容来自AnYun.ORG

                as_fn_error “Cannot locate header file magick-wand.h” “$LINENO” 5

//本文来自安云网

    fi

//内容来自AnYun.ORG

  else //本文来自安云网

    { $as_echo “$as_me:${as_lineno-$LINENO}: checking for MagickWand.h header file” >&5 //内容来自安云网

$as_echo_n “checking for MagickWand.h header file… ” >&6; } //内容来自AnYun.ORG

 

//安云网,anyun.org

    if test -r $WAND_DIR/include/ImageMagick/wand/MagickWand.h; then

//copyright AnYun.ORG

      { $as_echo “$as_me:${as_lineno-$LINENO}: result: found in $WAND_DIR/include/ImageMagick/wand/MagickWand.h” >&5

//内容来自AnYun.ORG

$as_echo “found in $WAND_DIR/include/ImageMagick/wand/MagickWand.h” >&6; } //安云网,anyun.org

    else //安云网咨询系统

      as_fn_error “Cannot locate header file MagickWand.h” “$LINENO” 5

//内容来自AnYun.ORG

    fi

//copyright AnYun.ORG

 

//copyright AnYun.ORG

 [root@os11728 imagick-3.1.0RC2] # ln -s /usr/include/wand/MagickWand.h /usr/local/include/ImageMagick/wand/MagickWand.h
//安云网,anyun.org

[root@os11728 imagick-3.1.0RC2]#./configure –prefix=/usr/local/imagick –with-php-config=/usr/local/php/bin/php-config //内容来自安云网

[root@os11728 imagick-3.1.0RC2]# make

//copyright AnYun.ORG

[root@os11728 imagick-3.1.0RC2]# make install

  //安云网咨询系统

  //copyright AnYun.ORG

然后编辑 php.ini文件 //内容来自AnYun.ORG

[root@os11728 src] # vim /usr/local/php/etc/php.ini

在最底下加入..

//安云网,anyun.org

extension = imagick.so

//内容来自AnYun.ORG

1.15.     安装PHP扩展之 curl

进入安装原PHP的源码目录,执行命令

//内容来自AnYun.ORG

[root@os11728 src]# cd /usr/local/src/php-5.4.4/ext/curl //内容来自AnYun.ORG

[root@os11728 curl]# /usr/local/php/bin/phpize

//本文来自安云网

[root@os11728 curl]#./configure –with-curl=/usr/local/curl –with-php-config=/usr/local/php/bin/php-config

//内容来自安云网

[root@os11728 curl]#make

//ANYUN.ORG

[root@os11728 curl]#make install

 

//本文来自安云网

就会在PHPDIR/ext/curl/moudles/下生成curl.so的文件。

//安云网咨询系统

复制curl.so文件到extensions的配置目录,修改php.ini就好了 //内容来自安云网

然后编辑 php.ini文件 //内容来自AnYun.ORG

[root@os11728 src] # vim /usr/local/php/etc/php.ini

在最底下加入..

//ANYUN.ORG

extension=curl.so

//内容来自AnYun.ORG

执行

//copyright AnYun.ORG

[root@os11728 src] # /usr/local/php/bin/php -v

出现以下错误:

//ANYUN.ORG

PHP Warning:  PHP Startup: Invalid library (maybe not a PHP library) ‘curl.so’ in Unknown on line 0 //本文来自安云网

PHP 5.3.8 (cli) (built: Oct 21 2011 14:20:41)

//内容来自AnYun.ORG

Copyright (c) 1997-2011 The PHP Group //内容来自AnYun.ORG

Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies

//本文来自安云网

解决方法:

//内容来自AnYun.ORG

进入安装原PHP的源码目录,执行命令 //ANYUN.ORG

[root@os11728 src]# cd /usr/local/src/php-5.4.4/ext/curl

//本文来自安云网

[root@os11728 curl]# /usr/local/php/bin/phpize

//安云网,anyun.org

[root@os11728 curl]#./configure –with-curl –with-php-config=/usr/local/php/bin/php-config

//ANYUN.ORG

[root@os11728 curl]#make clean //内容来自AnYun.ORG

[root@os11728 curl]#make //安云网咨询系统

[root@os11728 curl]#make install

  //copyright AnYun.ORG

1.16.     安装PHP扩展之 zip

 [root@os11728 src]# wget http://pecl.php.net/get/zip //安云网咨询系统

[root@os11728 src]# tar -zxvf zip //内容来自AnYun.ORG

[root@os11728 src]# cd zip-1.10.2 //ANYUN.ORG

[root@os11728 zip-1.10.2]# /usr/local/php/bin/phpize //copyright AnYun.ORG

[root@os11728 zip-1.10.2]#./configure –prefix=/usr/local/zip –with-php-config=/usr/local/php/bin/php-config

//ANYUN.ORG

[root@os11728 zip-1.10.2]# make //ANYUN.ORG

[root@os11728 zip-1.10.2]# make install

//ANYUN.ORG

进入安装原php的源码目录,执行命令 //内容来自AnYun.ORG

[root@os11728 src]# cd /usr/local/src/php-5.4.4/ext/zip //本文来自安云网

[root@os11728 zip]# /usr/local/php/bin/phpize

//ANYUN.ORG

[root@os11728 zip]# ./configure –prefix=/usr/local/zip –with-php-config=/usr/local/php/bin/php-config //内容来自AnYun.ORG

[root@os11728 zip]#make clean //copyright AnYun.ORG

[root@os11728 zip]#make //安云网,anyun.org

[root@os11728 zip]#make install

  //安云网咨询系统

其中,在最后使用make install命令的时候,可能需要用到root的权限,所以建议使用sudo来运行。安装完之后,屏幕上会提示zip.so的位置。然后将其记录下来,如:/usr/local/lib/php/extensions/zip.so //本文来自安云网

使用root权限修改php.ini(通常可能会在/usr/local/lib/文件夹下,不过视当初安装php而定,可以通过phpinfo()来查看): //ANYUN.ORG

  //ANYUN.ORG

编辑 php.ini文件

//安云网咨询系统

[root@os11728 src] # vim /usr/local/php/etc/php.ini

增加extension = /usr/local/lib/php/extensions/zip.so,然后同样在php.ini文件中,将 zlib.output_compression = Off 改为 zlib.output_compression = On //内容来自安云网

最后别忘了重启一下Apacheapachectl restart;

//copyright AnYun.ORG

这个针对phpzip模块就安装完成了。

//copyright AnYun.ORG

 

//安云网,anyun.org

  //内容来自安云网

1.17.     安装PHP扩展之 gd

进入安装原php的源码目录,执行命令

//copyright AnYun.ORG

[root@os11728 src]# cd /usr/local/src/php-5.4.4/ext/gd

//内容来自安云网

[root@os11728 gd]# /usr/local/php/bin/phpize //ANYUN.ORG

[root@os11728 gd]# ./configure –prefix=/usr/local/gd –with-php-config=/usr/local/php/bin/php-config –with-png=/usr/local/libpng

//安云网咨询系统

[root@os11728 gd]#make clean

//安云网咨询系统

[root@os11728 gd]#make

//内容来自AnYun.ORG

[root@os11728 gd]#make install

./configure过程中,出现以下错误: //copyright AnYun.ORG

configure: error: png.h not found. //内容来自AnYun.ORG

//本文来自安云网

[root@os11728 src]# yum -y install libpng libpng-devel

然后再: //安云网咨询系统

[root@os11728 gd]# ./configure –prefix=/usr/local/gd –with-php-config=/usr/local/php/bin/php-config –with-png=/usr/local/libpng
//内容来自AnYun.ORG

[root@os11728 gd]#make clean

//ANYUN.ORG

[root@os11728 gd]#make

//安云网,anyun.org

[root@os11728 gd]#make install

 

//内容来自安云网

其中,在最后使用make install命令的时候,可能需要用到root的权限,所以建议使用sudo来运行。安装完之后,屏幕上会提示gd.so的位置。然后将其记录下来,如:/usr/local/lib/php/extensions/gd.so //copyright AnYun.ORG

使用root权限修改php.ini(通常可能会在/usr/local/lib/文件夹下,不过视当初安装php而定,可以通过phpinfo()来查看):

//ANYUN.ORG

  //copyright AnYun.ORG

编辑 php.ini文件

//本文来自安云网

[root@os11728 src] # vim /usr/local/php/etc/php.ini

增加extension = /usr/local/lib/php/extensions/gd.so //ANYUN.ORG

最后别忘了重启一下Apacheapachectl restart; //安云网咨询系统

这个针对phpgd模块就安装完成了。 //内容来自安云网

顶一下
(0)
0%
踩一下
(0)
0%
------分隔线----------------------------
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
验证码: 点击我更换图片
相关内容
推荐内容