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

Linux环境下PHP安装

时间:2014-06-24来源: 作者:点击:
Linux环境下PHP安装 1.1.   安装基本程序   [root@os11728 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.  安装基本程序

 [root@os11728 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

[root@os11728 src]# wget http://sourceforge.net/projects/libpng/files/zlib/1.2.5/zlib-1.2.5.tar.gz/download

//ANYUN.ORG

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

[root@os11728 src]# cd zlib-1.2.5 //内容来自AnYun.ORG

[root@os11728 zlib-1.2.5]#./configure –prefix=/usr/local/zlib –shared

//内容来自AnYun.ORG

[root@os11728 zlib-1.2.5]# make

//ANYUN.ORG

[root@os11728 zlib-1.2.5]# make install

//ANYUN.ORG

[root@os11728 zlib-1.2.5]# ln -sf /usr/local/zlib/lib/libz.so.1.2.5 /usr/lib/libz.so //内容来自安云网

[root@os11728 zlib-1.2.5]# ln -sf /usr/local/zlib/lib/libz.so.1.2.5 /usr/lib/libz.so.1

1.3.  安装FreeType

[root@os11728 src]# wget http://sourceforge.net/projects/freetype/files/freetype2/2.4.8/freetype-2.4.8.tar.gz/download //本文来自安云网

[root@os11728 src]# tar -zxvf freetype-2.4.8.tar.gz

//内容来自安云网

[root@os11728 src]# cd freetype-2.4.8

//本文来自安云网

[root@os11728 freetype-2.4.8]# ./configure –prefix=/usr/local/freetype //内容来自安云网

[root@os11728 freetype-2.4.8]# make

//内容来自AnYun.ORG

[root@os11728 freetype-2.4.8]# make install

1.4.  安装LibPNG

[root@os11728 src]# wget http://prdownloads.sourceforge.net/libpng/libpng-1.5.5.tar.gz?download

//内容来自AnYun.ORG

[root@os11728 src]# tar -zxvf libpng-1.5.5.tar.gz //安云网咨询系统

[root@os11728 src]# cd libpng-1.5.5 //内容来自AnYun.ORG

[root@os11728 libpng-1.5.5]# ./configure –prefix=/usr/local/libpng

//ANYUN.ORG

[root@os11728 libpng-1.5.5]# make //本文来自安云网

[root@os11728 libpng-1.5.5]# make install

1.5.  安装Jpeg

[root@os11728 src]# wget http://www.ijg.org/files/jpegsrc.v8c.tar.gz //copyright AnYun.ORG

[root@os11728 src]# tar -zxvf jpegsrc.v8c.tar.gz

//内容来自安云网

[root@os11728 src]# cd jpeg-8c //安云网咨询系统

[root@os11728 jpeg-8c]# mkdir /usr/local/jpeg //内容来自安云网

[root@os11728 jpeg-8c]# mkdir /usr/local/jpeg/bin

//安云网咨询系统

[root@os11728 jpeg-8c]# mkdir /usr/local/jpeg/lib

//本文来自安云网

[root@os11728 jpeg-8c]# mkdir /usr/local/jpeg/include

//本文来自安云网

[root@os11728 jpeg-8c]# mkdir /usr/local/jpeg/man //本文来自安云网

[root@os11728 jpeg-8c]# mkdir /usr/local/jpeg/man/man1

//安云网咨询系统

[root@os11728 jpeg-8c]# ./configure –prefix=/usr/local/jpeg –enable-shared –enable-static

//ANYUN.ORG

[root@os11728 jpeg-8c]# make

//ANYUN.ORG

[root@os11728 jpeg-8c]# make install

1.6.  安装gd(php已自带)

[root@os11728 src]# yum remove gd //ANYUN.ORG

[root@os11728 src]# wget http://google-desktop-for-linux-mirror.googlecode.com/files/gd-2.0.35.tar.gz //本文来自安云网

[root@os11728 src]# tar -zxvf gd-2.0.35.tar.gz

//本文来自安云网

[root@os11728 src]# cd gd/2.0.35 //copyright AnYun.ORG

[root@os11728 2.0.35]# ./configure –prefix=/usr/local/gd –with-jpeg=/usr/local/jpeg –with-freetype=/usr/local/freetype –with-png=/usr/local/libpng //copyright AnYun.ORG

[root@os11728 2.0.35]# make

//ANYUN.ORG

[root@os11728 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′

//copyright AnYun.ORG

make[1]: *** [all-recursive] Error 1 //ANYUN.ORG

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

//内容来自AnYun.ORG

make: *** [all] Error 2

//安云网,anyun.org

  //安云网,anyun.org

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

//内容来自安云网

[root@os11728 src]# vi /usr/local/src/gd/2.0.35/gd_png.c //内容来自AnYun.ORG

将第十六行

//ANYUN.ORG

#include “png.h”

//copyright AnYun.ORG

改为: //内容来自AnYun.ORG

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

然后再:

//安云网,anyun.org

[root@os11728 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

[root@os11728 2.0.35]# make

//本文来自安云网

[root@os11728 2.0.35]# make install

  //内容来自安云网

1.7.  安装libmcrypt

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

[root@os11728 src]# tar -zxvf libmcrypt-2.5.8.tar.gz //内容来自安云网

[root@os11728 src]# cd libmcrypt-2.5.8

//安云网咨询系统

[root@os11728 libmcrypt-2.5.8]# ./configure –prefix=/usr/local/libmcrypt //内容来自安云网

[root@os11728 libmcrypt-2.5.8]# make //安云网,anyun.org

[root@os11728 libmcrypt-2.5.8]# make install

1.8.  安装mhash

[root@os11728 src]# wget http://sourceforge.net/projects/mhash/files/mhash/0.9.9.9/mhash-0.9.9.9.tar.gz/download

//安云网咨询系统

[root@os11728 src]# tar -zxvf mhash-0.9.9.9.tar.gz

//内容来自AnYun.ORG

[root@os11728 src]# cd mhash-0.9.9.9

//安云网,anyun.org

[root@os11728 mhash-0.9.9.9]# ./configure

//安云网咨询系统

[root@os11728 mhash-0.9.9.9]# make

//安云网,anyun.org

[root@os11728 mhash-0.9.9.9]# make install

1.9.  安装mcrypt

[root@os11728 src]# wget http://sourceforge.net/projects/mcrypt/files/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz/download

//安云网咨询系统

[root@os11728 src]# tar -zxvf  mcrypt-2.6.8.tar.gz

//copyright AnYun.ORG

[root@os11728 src]# cd mcrypt-2.6.8

//内容来自AnYun.ORG

[root@os11728 mcrypt-2.6.8]# ./configure –prefix=/usr/local/mcrypt –with-libmcrypt-prefix=/usr/local/libmcrypt

//内容来自安云网

[root@os11728 mcrypt-2.6.8]# make

//安云网咨询系统

[root@os11728 mcrypt-2.6.8]# make install

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

checking for libmcrypt-config… /usr/local/libmcrypt/bin/libmcrypt-config

//安云网咨询系统

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

//安云网咨询系统

*** version of LIBMCRYPT. If it is not finding LIBMCRYPT, you’ll need to set your //内容来自安云网

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

//内容来自安云网

*** to the installed location  Also, make sure you have run ldconfig if that

//copyright AnYun.ORG

*** is required on your system

//内容来自AnYun.ORG

***

//本文来自安云网

*** If you have an old version installed, it is best to remove it, although

//内容来自AnYun.ORG

*** you may also be able to get things to work by modifying LD_LIBRARY_PATH //安云网,anyun.org

***

//内容来自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是默认安装的。

//内容来自AnYun.ORG

 [root@os11728 mcrypt-2.6.8]# LD_LIBRARY_PATH=/usr/local/libmcrypt/lib:/usr/local/lib ./configure –with-libmcrypt-prefix=/usr/local/libmcrypt
//安云网,anyun.org

[root@os11728 mcrypt-2.6.8]# make //本文来自安云网

[root@os11728 mcrypt-2.6.8]# make install

1.10.     安装PHP

[root@os11728 src]# yum remove php* //内容来自AnYun.ORG

[root@os11728 src]# wget http://cn.php.net/get/php-5.4.4.tar.bz2/from/cn2.php.net/mirror

//安云网咨询系统

[root@os11728 src]# tar -jxvf php-5.4.4.tar.bz2 //安云网,anyun.org

[root@os11728 src]# cd php-5.4.4 //ANYUN.ORG

[root@os11728 src]# yum -y install gdbm gdbm-devel libxml2 libxml2-devel curl curl-devel openldap openldap-devel libtool libmcrypt libmcrypt-devel 

//copyright AnYun.ORG

[root@os11728 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模式 //copyright AnYun.ORG

//安云网,anyun.org

[root@os11728 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模式

//内容来自AnYun.ORG

[root@os11728 php-5.4.4]# make

//内容来自安云网

[root@os11728 php-5.4.4]# make install //copyright AnYun.ORG

[root@os11728 php-5.4.4]# libtool –finish /usr/local/src/php-5.4.4/libs

//copyright AnYun.ORG

[root@os11728 php-5.4.4]# chmod 755 /usr/local/apache2/modules/libphp5.so //本文来自安云网

[root@os11728 php-5.4.4]# cp php.ini-production /usr/local/php/etc/php.ini

//安云网,anyun.org

[root@os11728 php-5.4.4]# cp /usr/local/php/etc/php.ini /usr/local/php/etc/php.ini.old

make后出现以下错误:

//copyright AnYun.ORG

PEAR package PHP_Archive not installed: generated phar will require PHP’s phar extension be enabled.

//本文来自安云网

//安云网,anyun.org

[root@os11728 php-5.4.4]# wget http://pear.php.net/go-pear -O go-pear.php //ANYUN.ORG

[root@os11728 php-5.4.4]# /usr/local/php/bin/php go-pear.php //内容来自AnYun.ORG

 make后出现以下错误:

//安云网咨询系统

In file included from /usr/local/src/php-5.4.4/ext/gd/libgd/gd_compat.c:8: //内容来自AnYun.ORG

/usr/local/jpeg/include/jpeglib.h:954: error: expected declaration specifiers or ‘…’ before ‘FILE’ //内容来自安云网

/usr/local/jpeg/include/jpeglib.h:955: error: expected declaration specifiers or ‘…’ before ‘FILE’ //本文来自安云网

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

//安云网咨询系统

[root@os11728 src]# vi /usr/local/src/php-5.4.4/ext/gd/libgd/gd_compat.c

//内容来自AnYun.ORG

将第八行

//安云网,anyun.org

# include <jpeglib.h> //ANYUN.ORG

改为:

//内容来自AnYun.ORG

# include </usr/local/jpeg/include/jpeglib.h> //安云网咨询系统

然后再:

//内容来自AnYun.ORG

 [root@os11728 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

[root@os11728 php-5.4.4]# make clean

//内容来自安云网

[root@os11728 php-5.4.4]# make //安云网咨询系统

[root@os11728 php-5.4.4]# make install //ANYUN.ORG

[root@os11728 php-5.4.4]# libtool –finish /usr/local/src/php-5.4.4/libs

//内容来自安云网

 make后出现以下错误: //内容来自AnYun.ORG

Generating phar.php

//copyright AnYun.ORG

/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 //安云网,anyun.org

//内容来自安云网

[root@os11728 php-5.4.4]# ln -s /usr/local/mysql/lib/libmysqlclient.so.18  /usr/lib/ //安云网咨询系统

[root@os11728 php-5.4.4]# make clean //本文来自安云网

[root@os11728 php-5.4.4]# make //内容来自安云网

[root@os11728 php-5.4.4]# make install

//安云网,anyun.org

 make后出现以下错误: //ANYUN.ORG

make: *** [sapi/cli/php] Error 1

//安云网咨询系统

//安云网,anyun.org

[root@os11728 php-5.4.4]# make clean

//本文来自安云网

[root@os11728 php-5.4.4]# make //内容来自安云网

[root@os11728 php-5.4.4]# make install

//安云网咨询系统

 

//内容来自AnYun.ORG

修改配置文件 //内容来自安云网

[root@os11728 php-5.4.4]#vi /usr/local/php/etc/php.ini

找到include_path = “.:/php/includes ” 这一行,并修改为: //本文来自安云网

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

//ANYUN.ORG

 

//安云网,anyun.org

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

//内容来自AnYun.ORG

解决方法: //安云网,anyun.org

php.ini里修改

//copyright AnYun.ORG

查找

//ANYUN.ORG

short_open_tag = Off

//copyright AnYun.ORG

改为 //安云网咨询系统

short_open_tag = On //ANYUN.ORG

  //内容来自安云网

1.11.     配置php-fpm

 

//copyright AnYun.ORG

修改php-fpm.conf //内容来自安云网

[root@os11728 php-5.4.4]# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf //安云网,anyun.org

[root@os11728 php-5.4.4]# vi /usr/local/php/etc/php-fpm.conf

根据需要调整参数,即修改下面几行的内容数值为:

//内容来自AnYun.ORG

pid = run/php-fpm.pid

//内容来自安云网

user = nginx

//ANYUN.ORG

group = www //ANYUN.ORG

pm.max_children = 300

//内容来自AnYun.ORG

pm.start_servers = 20

//本文来自安云网

pm.min_spare_servers = 40

//copyright AnYun.ORG

pm.max_spare_servers = 60 //内容来自AnYun.ORG

pm.max_requests = 3000 //内容来自安云网

启动php-fpm并在后台运行

//安云网,anyun.org

[root@os11728 php-5.4.4]# /usr/local/php/sbin/php-fpm &

若启动时出现: //安云网,anyun.org

Segmentation fault (段错误) //安云网,anyun.org

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

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

//安云网,anyun.org

检查php-fpm配置语法是否正确 //copyright AnYun.ORG

[root@os11728 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

 

//安云网咨询系统

设置开机启动 //本文来自安云网

[root@os11728 php-5.4.4]# vi /etc/rc.d/rc.local

在行末加入:

//ANYUN.ORG

/usr/local/php/sbin/php-fpm &

//本文来自安云网

 

//内容来自安云网

关闭php-fpm //copyright AnYun.ORG

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

  //ANYUN.ORG

重启php-fpm

//本文来自安云网

[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命令来查看主进程号

//安云网,anyun.org

 

//安云网,anyun.org

查看php-fpm进程总数: //本文来自安云网

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

  //内容来自安云网

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

 

//内容来自AnYun.ORG

<IfModule mime_module>

//copyright 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来处理 //内容来自AnYun.ORG

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

//本文来自安云网

</IfModule> //copyright AnYun.ORG

  //安云网咨询系统

 

//安云网,anyun.org

<Directory “/usr/local/php/bin/”> //ANYUN.ORG

Options none

//本文来自安云网

Order allow,deny //安云网,anyun.org

Allow from all

//本文来自安云网

</Directory>

 

//安云网,anyun.org

 

//安云网咨询系统

 

//内容来自安云网

新建PHP测试文件info.php,内容为: //安云网,anyun.org

<?php //内容来自安云网

echo phpinfo();

//ANYUN.ORG

?>

//安云网咨询系统

浏览器输入地址:http://WebServer IP/info.php

//安云网咨询系统

检测PHP是否安装成功。

//ANYUN.ORG

  //内容来自安云网

查看正在运行的PHP进程:

//本文来自安云网

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

 

//copyright AnYun.ORG

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

//copyright AnYun.ORG

/usr/local/apache2/bin/apachectl start

//本文来自安云网

否则有可能出现下载PHP文件提示。

//copyright AnYun.ORG

 

//安云网,anyun.org

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

//内容来自AnYun.ORG

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

//内容来自AnYun.ORG

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/ //安云网,anyun.org

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

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

 ———————————————- //安云网,anyun.org

下面这个是关于gdbm的。

//ANYUN.ORG

  //内容来自AnYun.ORG

For redhat users # yum install gdbm-devel //内容来自AnYun.ORG

For ubuntu users # apt-get install libgdbm-dev

//copyright AnYun.ORG

  //安云网咨询系统

  //ANYUN.ORG

 

//安云网,anyun.org

帮助输出:.configure –help > /tem/xxx.txt

//内容来自安云网

 

//内容来自安云网

  //本文来自安云网

———————————————- //ANYUN.ORG

关于php编译时SAPI错误

//copyright AnYun.ORG

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

//本文来自安云网

关于php编译时SAPI错误错误截图如下: //内容来自AnYun.ORG

  //ANYUN.ORG

关于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。) //copyright AnYun.ORG

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

 

//安云网,anyun.org

 

//ANYUN.ORG

1.13.     安装PHP扩展之memcache

 [root@os11728 ~]#cd /usr/local/src //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 //copyright AnYun.ORG

或:

//安云网咨询系统

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

//内容来自AnYun.ORG

 

//内容来自安云网

[root@os11728 src]#cd memcache-3.0.6 //copyright 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

//内容来自AnYun.ORG

[root@os11728 memcache-3.0.6]#make install

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

In file included from /usr/local/php/include/php/main/php.h:34, //内容来自安云网

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

//内容来自AnYun.ORG

/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 //安云网,anyun.org

                                                                               /usr/local/src/memcache-3.0.6/memcache.c:721: error: too few arguments to function 鈥榸end_list_insert //安云网,anyun.org

/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

//内容来自安云网

/usr/local/src/memcache-3.0.6/memcache.c: In function 鈥榩hp_mmc_connect //内容来自安云网

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

make: *** [memcache.lo] Error 1 //安云网,anyun.org

则到http://svn.php.net/viewvc/pecl/memcache/trunk/

//ANYUN.ORG

memcache.c下载下来覆盖3.0.6的里的memcache.c,然后再重编译

//本文来自安云网

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

//内容来自安云网

然后编辑 php.ini文件

//本文来自安云网

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

增加行extension = memcache.so重启apache //安云网,anyun.org

1.14.      安装PHP扩展之ImageMagick

先安装ImageMagick相关套件

//安云网,anyun.org

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

 

//本文来自安云网

安装基本程序 //内容来自安云网

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

  //内容来自安云网

安装re2c

//内容来自AnYun.ORG

 [root@os11728 src]# wget http://sourceforge.net/projects/re2c/files/re2c/0.13.5/re2c-0.13.5.tar.gz/download //本文来自安云网

[root@os11728 src]# tar -zxvf re2c-0.13.5.tar.gz //内容来自安云网

[root@os11728 src]# cd re2c-0.13.5 //本文来自安云网

[root@os11728 re2c-0.13.5#./configure

//安云网,anyun.org

[root@os11728 re2c-0.13.5]# make

//本文来自安云网

[root@os11728 re2c-0.13.5]# make install

 

//内容来自安云网

安装imagick

//内容来自安云网

 [root@os11728 src]# wget http://pecl.php.net/get/imagick-3.1.0RC2.tgz //内容来自AnYun.ORG

[root@os11728 src]# tar -zxvf imagick-*

//安云网,anyun.org

或: //copyright AnYun.ORG

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

//内容来自AnYun.ORG

  //安云网咨询系统

[root@os11728 src]# cd imagick-* //安云网咨询系统

[root@os11728 imagick-3.1.0RC2]# /usr/local/php/bin/phpize //本文来自安云网

[root@os11728 imagick-3.1.0RC2]#./configure –prefix=/usr/local/imagick –with-php-config=/usr/local/php/bin/php-config //安云网,anyun.org

[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

//安云网咨询系统

则:

//内容来自AnYun.ORG

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

查找‘MagickWand.h’,找到有价值结果如下: //安云网咨询系统

  if test -z “$IMAGICK_AFTER_BWC_BREAK”; then //本文来自安云网

    { $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 //内容来自安云网

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

//安云网咨询系统

$as_echo “found in $WAND_DIR/include/wand/magick-wand.h” >&6; } //安云网咨询系统

        else

//本文来自安云网

                as_fn_error “Cannot locate header file magick-wand.h” “$LINENO” 5 //安云网,anyun.org

    fi //内容来自AnYun.ORG

  else //copyright AnYun.ORG

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

//ANYUN.ORG

$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 //ANYUN.ORG

      { $as_echo “$as_me:${as_lineno-$LINENO}: result: found in $WAND_DIR/include/ImageMagick/wand/MagickWand.h” >&5 //内容来自安云网

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

//内容来自AnYun.ORG

    else //安云网,anyun.org

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

//安云网咨询系统

    fi

//安云网,anyun.org

  //内容来自AnYun.ORG

 [root@os11728 imagick-3.1.0RC2] # ln -s /usr/include/wand/MagickWand.h /usr/local/include/ImageMagick/wand/MagickWand.h //本文来自安云网

[root@os11728 imagick-3.1.0RC2]#./configure –prefix=/usr/local/imagick –with-php-config=/usr/local/php/bin/php-config

//安云网,anyun.org

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

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

 

//内容来自AnYun.ORG

 

//安云网,anyun.org

然后编辑 php.ini文件

//copyright AnYun.ORG

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

在最底下加入..

//本文来自安云网

extension = imagick.so //安云网咨询系统

1.15.     安装PHP扩展之 curl

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

//本文来自安云网

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

//copyright 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

//ANYUN.ORG

[root@os11728 curl]#make

//内容来自安云网

[root@os11728 curl]#make install

  //本文来自安云网

就会在PHPDIR/ext/curl/moudles/下生成curl.so的文件。 //内容来自安云网

复制curl.so文件到extensions的配置目录,修改php.ini就好了

//copyright AnYun.ORG

然后编辑 php.ini文件 //安云网咨询系统

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

在最底下加入..

//copyright AnYun.ORG

extension=curl.so //ANYUN.ORG

执行 //copyright AnYun.ORG

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

出现以下错误:

//本文来自安云网

PHP Warning:  PHP Startup: Invalid library (maybe not a PHP library) ‘curl.so’ in Unknown on line 0

//安云网,anyun.org

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

//安云网,anyun.org

Copyright (c) 1997-2011 The PHP Group

//内容来自安云网

Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies //内容来自AnYun.ORG

解决方法:

//安云网咨询系统

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

//本文来自安云网

[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 –with-php-config=/usr/local/php/bin/php-config

//内容来自安云网

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

[root@os11728 curl]#make

//安云网,anyun.org

[root@os11728 curl]#make install

  //本文来自安云网

1.16.     安装PHP扩展之 zip

 [root@os11728 src]# wget http://pecl.php.net/get/zip //copyright AnYun.ORG

[root@os11728 src]# tar -zxvf zip //本文来自安云网

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

[root@os11728 zip-1.10.2]# /usr/local/php/bin/phpize //内容来自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

//copyright AnYun.ORG

[root@os11728 zip-1.10.2]# make install

//安云网咨询系统

进入安装原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 //本文来自安云网

[root@os11728 zip]#make clean

//内容来自AnYun.ORG

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

[root@os11728 zip]#make install

  //安云网,anyun.org

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

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

//内容来自安云网

 

//内容来自AnYun.ORG

编辑 php.ini文件

//copyright AnYun.ORG

[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; //ANYUN.ORG

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

//内容来自安云网

  //内容来自AnYun.ORG

  //安云网,anyun.org

1.17.     安装PHP扩展之 gd

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

//安云网咨询系统

[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 //内容来自AnYun.ORG

[root@os11728 gd]#make clean

//内容来自AnYun.ORG

[root@os11728 gd]#make //内容来自安云网

[root@os11728 gd]#make install

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

//安云网,anyun.org

configure: error: png.h not found. //内容来自安云网

//本文来自安云网

[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

 

//安云网,anyun.org

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

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

//安云网咨询系统

 

//内容来自安云网

编辑 php.ini文件

//安云网咨询系统

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

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

最后别忘了重启一下Apacheapachectl restart; //内容来自AnYun.ORG

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

//安云网,anyun.org

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