Linux环境下PHP安装

  • A+
所属分类:系统文档

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

 

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

1.2.  安装zlib

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

[root@os11728 src]# tar -zxvf zlib-1.2.5.tar.gz

[root@os11728 src]# cd zlib-1.2.5

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

[root@os11728 zlib-1.2.5]# make

[root@os11728 zlib-1.2.5]# make install

[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

[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

[root@os11728 src]# tar -zxvf libpng-1.5.5.tar.gz

[root@os11728 src]# cd libpng-1.5.5

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

[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

[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

[root@os11728 jpeg-8c]# make

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

1.6.  安装gd(php已自带)

[root@os11728 src]# yum remove gd

[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

[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

[root@os11728 2.0.35]# make

[root@os11728 2.0.35]# make install

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

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′

make: *** [all] Error 2

 

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

[root@os11728 src]# vi /usr/local/src/gd/2.0.35/gd_png.c

将第十六行

#include “png.h”

改为:

#include “/usr/local/libpng/include/png.h”

然后再:

[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

[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

[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

[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

[root@os11728 src]# cd mhash-0.9.9.9

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

[root@os11728 mhash-0.9.9.9]# make

[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

[root@os11728 src]# cd mcrypt-2.6.8

[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

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

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

checking for libmcrypt – version >= 2.5.0… no

*** 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

*** is required on your system

***

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

*** you may also be able to get things to work by modifying LD_LIBRARY_PATH

***

configure: error: *** libmcrypt was not found

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

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

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

[root@os11728 mcrypt-2.6.8]# make

[root@os11728 mcrypt-2.6.8]# make install

1.10.     安装PHP

[root@os11728 src]# yum remove php*

[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

[root@os11728 src]# cd php-5.4.4

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

[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模式

[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模式

[root@os11728 php-5.4.4]# make

[root@os11728 php-5.4.4]# make install

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

[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

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

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

[root@os11728 php-5.4.4]# /usr/local/php/bin/php go-pear.php

 make后出现以下错误:

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’

/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

将第八行

# include <jpeglib.h>

改为:

# include </usr/local/jpeg/include/jpeglib.h>

然后再:

 [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模式

[root@os11728 php-5.4.4]# make clean

[root@os11728 php-5.4.4]# make

[root@os11728 php-5.4.4]# make install

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

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

[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

 make后出现以下错误:

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

[root@os11728 php-5.4.4]# make clean

[root@os11728 php-5.4.4]# make

[root@os11728 php-5.4.4]# make install

 

修改配置文件

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

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

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

 

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

解决方法:

php.ini里修改

查找

short_open_tag = Off

改为

short_open_tag = On

 

1.11.     配置php-fpm

 

修改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

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

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

pid = run/php-fpm.pid

user = nginx

group = www

pm.max_children = 300

pm.start_servers = 20

pm.min_spare_servers = 40

pm.max_spare_servers = 60

pm.max_requests = 3000

启动php-fpm并在后台运行

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

若启动时出现:

Segmentation fault (段错误)

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

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

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

[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 说明测试成功

 

设置开机启动

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

在行末加入:

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

 

关闭php-fpm

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

 

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

 

查看php-fpm进程总数:

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

 

1.12.     PHP设置apache

 

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

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

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

 

<IfModule mime_module>

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

AddType application/x-httpd-php .php

AddHandler php-fastcgi .php   #.php结尾的请求都要用php-fastcgi来处理

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

</IfModule>

 

 

2)添加FastCGIExternalServer及目录属性

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

 

 

<Directory “/usr/local/php/bin/”>

Options none

Order allow,deny

Allow from all

</Directory>

 

 

 

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

<?php

echo phpinfo();

?>

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

检测PHP是否安装成功。

 

查看正在运行的PHP进程:

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

 

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

/usr/local/apache2/bin/apachectl start

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

 

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

Linux环境下PHP安装

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

apache 目录build下面的libtool拷贝到了php编译安装的目录下,重新make clean make  make install,就行了。

 

比如我的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).

原因是因为缺少:qdbm开发包。

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

下面这个是关于gdbm的。

 

For redhat users # yum install gdbm-devel

For ubuntu users # apt-get install libgdbm-dev

 

 

 

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

 

 

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

关于php编译时SAPI错误

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

关于php编译时SAPI错误错误截图如下:

 Linux环境下PHP安装

关于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

[root@os11728 src]# wget http://pecl.php.net/get/memcache-3.0.6.tgz

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

或:

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

 

[root@os11728 src]#cd memcache-3.0.6

[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过程中出现以下错误:

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

                 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

/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

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

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

1.14.      安装PHP扩展之ImageMagick

先安装ImageMagick相关套件

[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

 [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

[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

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

或:

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

 

[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

[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’,找到有价值结果如下:

  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; }

    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

    fi

  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; }

 

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

      { $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; }

    else

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

    fi

 

 [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

[root@os11728 imagick-3.1.0RC2]# make

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

 

 

然后编辑 php.ini文件

[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

[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

[root@os11728 curl]#make install

 

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

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

然后编辑 php.ini文件

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

在最底下加入..

extension=curl.so

执行

[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

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

Copyright (c) 1997-2011 The PHP Group

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

解决方法:

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

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

[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

[root@os11728 curl]#make install

 

1.16.     安装PHP扩展之 zip

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

[root@os11728 src]# tar -zxvf zip

[root@os11728 src]# cd zip-1.10.2

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

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

[root@os11728 zip-1.10.2]# make

[root@os11728 zip-1.10.2]# make install

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

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

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

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

[root@os11728 zip]#make clean

[root@os11728 zip]#make

[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()来查看):

 

编辑 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;

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

 

 

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

[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

[root@os11728 gd]#make install

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

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

[root@os11728 gd]#make clean

[root@os11728 gd]#make

[root@os11728 gd]#make install

 

其中,在最后使用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

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

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

  • 我的微信
  • 这是我的微信扫一扫
  • weinxin
  • 我的微信公众号
  • 我的微信公众号扫一扫
  • weinxin

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: