服务器配置系列之二 Install php-5.3.2 on linux

来源:互联网 发布:龙虎大师软件怎么样 编辑:程序博客网 时间:2024/05/20 03:48

本文为 服务器配置系列之一 Install apache2 on linux 的续篇

(原文链接 http://ddbiz.com/?p=178)

php 的安装要比 httpd 复杂一些,主要可能是他的相关模块以及对系统环境的相关行很强。

 

1. 下载 http://www.php.net/get/php-5.3.2.tar.bz2/from/a/mirror

 

2. 安装前的准备工作

    php 很多模块需要相关的动态库, 因此安装前需要先设定一下。本文仅仅符合 CentOS 5.3/x86 环境,其他环境下的安装还需要参考其文档。

 

yum install freetype-devel jpeg-devel libpng-devel 

 

安装 libmcrypt libltdl 

说明: 这个安装是如果要把 mcrypt 安装进php,则需要特别安装 libmcrypt, libmcrypt/libltdl, 否则可能会在make php的时候发生cannot find -lltdl的错误。

 

 

wget http://downloads.sourceforge.net/project/mcrypt/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz?use_mirror=voxel

tar xzvf mcrypt-2.6.8.tar.gz

cd mcrypt-2.6.8

./configure

make && make install

ldconfig

 

cd libltdl

./configure  --enable-ltdl-install

make && make install

 

3. 配置 php

cd php-5.3.2

./configure --prefix=/usr/local/webserver/php / --with-apxs2=/usr/local/webserver/httpd/bin/apxs / --with-mysql=/usr/lib/mysql / --enable-mbstring / --with-pdo-mysql / --with-mhash / --with-zlib-dir / --enable-zip / --with-gettext / --with-gd / --with-freetype-dir=/usr/include/freetype2/ / --with-iconv / --with-pear / --with-png-dir=/usr/local/lib / --enable-magic-quotes / --with-curl / --with-jpeg-dir=/usr/local/lib / --with-openssl / --with-mcrypt

 

make && make install

 

4. 查看 php 的编译加载模块

 

[PHP Modules]

Core

ctype

curl

date

dom

ereg

fileinfo

filter

gd

gettext

hash

iconv

json

libxml

mbstring

mcrypt

memcache

mhash

mysql

openssl

pcre

PDO

pdo_mysql

pdo_sqlite

Phar

posix

Reflection

session

SimpleXML

SPL

SQLite

sqlite3

standard

tokenizer

uuid

xml

xmlreader

xmlwriter

zip

zlib

 

[Zend Modules]

根据列表确定所有需要的模块都已经静态加载

 

 

5. 设置httpd加载php, 创建一个 httpd-php.conf, 并让其能够在 httpd.conf 中加载

 

#######################################################################

#LoadModule php5_module modules/libphp5.so

# loadmodule will be add by php make install into httpd.conf

######################################################################

 

<FilesMatch "/.ph(p[2-6]?|tml)$">

   SetHandler application/x-httpd-php

</FilesMatch>

<FilesMatch "/.phps$">

   SetHandler application/x-httpd-php-source

</FilesMatch>

DirectoryIndex index.php

 


6. 查看httpd加载

service httpd restart

 

7. 为php 安装其他的动态模块

修改php.iniextension_dir="/usr/local/webserver/php/lib/ext"extension=memcache.so

extension=uuid.so

 

7.1 uuid

$wget http://pecl.php.net/get/uuid-1.0.2.tgz$tar xzvf uuid-1.0.2.tgz$cd uuid-1.0.2$phpize && ./configure --enable-uuid && makecp modules/uuid.so /usr/local/webserver/php/lib/ext/

 

7.2 memcache

 

wget http://pecl.php.net/get/memcache-2.2.5.tgz /*this file seems to be a inline module for php compile*/

phpize && ./configure -enable-memcache && make

cp modules/memcache.so /usr/local/webserver/php/lib/ext

 

(原文链接 http://ddbiz.com/?p=178)

原创粉丝点击