`

CentOS 编译安装 Nginx 1.2 + PHP 5.3.14 + APC 3.1.9 + php-memcached + php-redis + php

 
阅读更多

CentOS 编译安装 Nginx 1.2 + PHP 5.3.14 + APC 3.1.9 + php-memcached + php-redis + php-mcrypt + php-mhash

 

参考资料

*************************************************************************

CentOS 6.0 x64编译LNMP环境

    http://blog.renhao.org/2011/09/centos-6-x64-compile-lnmp-environment/

CentOS 5.6(X64)下编译安装LNMP平台(Nginx1.0+PHP5.3.6+Mysql5.5.11)

    http://www.mike.org.cn/articles/centos56-x64-compile-install-lemp/6/

php安装加速扩展 APC 详解  

    http://leepiao.blog.163.com/blog/static/48503130201121811722907/

centos下nginx+postgresql+php+memcached+apc安装与配置

    http://j3j5.com/post-122.html

CentOS-5.2-x86_64(AMD)编译安装PHP小记

    http://hi.baidu.com/mcspring/blog/item/5cf6c513080a832bdd5401ca.html

CentOS下编译安装lighttpd和PHP(vps)

    http://www.coder4.com/archives/1069

CentOS 6.2编译安装Nginx1.0.12+MySQL5.5.21+PHP5.3.10

    http://www.osyunwei.com/archives/2708.html

CentOS 5.6(X64)下编译安装LNMP平台(Nginx1.0.4+PHP5.3.6+Mysql5.5.12)

    http://www.xker.com/page/e2011/0620/101603.html

CentOS 6.0(X64)下编译安装LNMP平台( Nginx1.0.10 + PHP5.3.8 + Mysql5.5.18 )

    http://www.cnblogs.com/vicowong/archive/2011/12/01/2116212.html

ldconfig命令作用

    http://wangqiaowqo.iteye.com/blog/1283887

*************************************************************************

 

软件列表

*************************************************************************

wget xxxxx -O xxxxx

 

APC-3.1.9.tgz

http://pecl.php.net/get/APC-3.1.9.tgz

 

cmake-2.8.5.tar.gz

http://www.cmake.org/files/v2.8/cmake-2.8.5.tar.gz

 

libiconv-1.13.1.tar.gz

http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.1.tar.gz

 

libmcrypt-2.5.8.tar.gz

http://downloads.sourceforge.net/mcrypt/libmcrypt-2.5.8.tar.gz?modtime=1171868460&big_mirror=0

 

libmemcached-1.0.8.tar.gz

https://launchpad.net/libmemcached/1.0/1.0.8/+download/libmemcached-1.0.8.tar.gz

 

mcrypt-2.6.8.tar.gz

http://downloads.sourceforge.net/mcrypt/mcrypt-2.6.8.tar.gz?modtime=1194463373&big_mirror=0

 

memcached-2.0.1.tgz php-memcached扩展模块

http://pecl.php.net/get/memcached-2.0.1.tgz 

 

mhash-0.9.9.9.tar.gz

http://downloads.sourceforge.net/mhash/mhash-0.9.9.9.tar.gz?modtime=1175740843&big_mirror=0

 

nginx-1.2.0.tar.gz

http://nginx.org/download/nginx-1.2.0.tar.gz

 

php-redis.tar.gz

https://github.com/nicolasff/phpredis/tarball/master

 

pcre-8.12.tar.gz

http://lnamp-web-server.googlecode.com/files/pcre-8.12.tar.gz

 

php-5.3.14.tar.gz

http://www.php.net/get/php-5.3.14.tar.gz/from/a/mirror

*************************************************************************

 

0. mkdir -p /home/atlantis/app_software

   cd /home/atlantis/app_software

 

1.

yum install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel  ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel libtool  libtool-libs libevent-devel libevent openldap openldap-devel nss_ldap openldap-clients openldap-servers libtool-ltdl libtool-ltdl-devel bison cloog-ppl ppl

yum install libmemcached-devel gcc44 gcc44-c++ libstdc++44-devel

 

 libevent-dev cloog-ppl

 

 

2. 安装CMake

tar zxvf cmake-2.8.5.tar.gz

cd cmake-2.8.5

./configure --prefix=/usr

make

make install

cd ..

 

3. 安装libiconv库

tar zxvf libiconv-1.13.1.tar.gz

cd libiconv-1.13.1/

./configure --prefix=/usr/local

make

make install

cd ..

 

4. 安装libmcrypt库

tar zxvf libmcrypt-2.5.8.tar.gz

cd libmcrypt-2.5.8

./configure

make

make install

/sbin/ldconfig

 

cd libltdl/

./configure --enable-ltdl-install

make

make install

cd ../../

 

5. 接下来我们要建立libmcrypt库的软链接:

 

#64位系统使用

 

ln -sf /usr/local/lib/libmcrypt.la /usr/lib64/libmcrypt.la

ln -sf /usr/local/lib/libmcrypt.so /usr/lib64/libmcrypt.so

ln -sf /usr/local/lib/libmcrypt.so.4 /usr/lib64/libmcrypt.so.4

ln -sf /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib64/libmcrypt.so.4.4.8

ln -sf /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config

ln -sf /usr/local/lib/libiconv.so.2 /usr/lib64/libiconv.so.2

ldconfig

 

#32位系统使用

 

ln -sf /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la

ln -sf /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so

ln -sf /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4

ln -sf /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8

ln -sf /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config

ln -sf /usr/local/lib/libiconv.so.2 /usr/lib/libiconv.so.2

ldconfig

 

 

6. 安装mhash

tar zxvf mhash-0.9.9.9.tar.gz

cd mhash-0.9.9.9

./configure

make

make install

cd ..

 

建立libmhash相关的软链接:

 

#64位系统使用

ln -sf /usr/local/lib/libmhash.a /usr/lib64/libmhash.a

ln -sf /usr/local/lib/libmhash.la /usr/lib64/libmhash.la

ln -sf /usr/local/lib/libmhash.so /usr/lib64/libmhash.so

ln -sf /usr/local/lib/libmhash.so.2 /usr/lib64/libmhash.so.2

ln -sf /usr/local/lib/libmhash.so.2.0.1 /usr/lib64/libmhash.so.2.0.1

ldconfig

 

#32位系统使用

ln -sf /usr/local/lib/libmhash.a /usr/lib/libmhash.a

ln -sf /usr/local/lib/libmhash.la /usr/lib/libmhash.la

ln -sf /usr/local/lib/libmhash.so /usr/lib/libmhash.so

ln -sf /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2

ln -sf /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1

ldconfig

 

7. 安装mcrypt

tar zxvf mcrypt-2.6.8.tar.gz

cd mcrypt-2.6.8/

/sbin/ldconfig

./configure

make

make install

cd ..

 

8. 安装pcre

tar zxvf pcre-8.12.tar.gz

cd pcre-8.12/

./configure

make

make install

 

 

===========================

9. 编译PHP

   PHP 5.3.x         [已安装]

   php-fpm           [已安装]

   php-memcached     [已安装] 

   php-apc           [已安装]

   php-redis         [已安装]

   Memcached Server  [未安装]

   Redis     Server  [未安装]

 

   PHP      启动脚本 [未完成]

   Nginx    启动脚本 [未完成]

   Memcached启动脚本 [未完成]

   Redis    启动脚本 [未完成]

 

首先我们再做几个软链接,这些软链接只是64位系统需要,32位系统不需要做:

 

ln -s /usr/lib64/libjpeg.so /usr/lib/libjpeg.so

ln -s /usr/lib64/libldap.so /usr/lib/libldap.so

ln -s /usr/lib64/libpng.so /usr/lib/libpng.so

 

#编译 PHP

tar xvf php-5.3.8.tar.gz

cd php-5.3.8

./configure --prefix=/usr/local/bk/php --with-config-file-path=/usr/local/bk/php/etc --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fpm --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl --with-xmlrpc --enable-zip --enable-soap --without-pear

make ZEND_EXTRA_LIBS='-liconv'

make install

 

#创建PHP的配置文件

cp -f php.ini-production /usr/local/bk/php/etc/php.ini

cp /usr/local/bk/php/etc/php-fpm.conf.default /usr/local/bk/php/etc/php-fpm.conf

 

wget http://pear.php.net/go-pear.phar

/usr/local/bk/php/bin/php go-pear.phar

 

yum install libmemcached-devel gcc44 gcc44-c++ libstdc++44-devel

 

 libevent-dev cloog-ppl

 

#编译 libmemcached

tar zxf libmemcached-1.0.8.tar.gz

cd libmemcached-1.0.8

./configure --prefix=/usr/local/bk/libmemcached --with-memcached

make

make install

 

#编译 php-memcached

tar zxf memcached-2.0.1.tgz

cd memcached-2.0.1

/usr/local/bk/php/bin/phpize

./configure --enable-memcached --with-php-config=/usr/local/bk/php/bin/php-config --with-libmemcached-dir=/usr/local/bk/libmemcached

make

make install

 

vi /usr/local/bk/php/lib/php.ini

#加入 extension=memcached.so

 

mkdir -p /usr/local/bk/php/logs

vim /usr/local/bk/php/etc/php-fpm.conf

/*******

pid = /usr/local/bk/php/logs/php-fpm.pid

error_log = /usr/local/bk/php/logs/php-fpm.log

log_level = notice

*******/

 

#编译 APC插件

tar zxvf APC-3.1.9.tgz

cd APC-3.1.9

/usr/local/bk/php/bin/phpize

./configure --enable-apc --enable-apc-mmap --with-php-config=/usr/local/bk/php/bin/php-config

make

make install

 

vi /usr/local/bk/php/lib/php.ini

#加入

[apc]

extension=apc.so

 

===========================

参考

./libmemcached-1.0/memcached.h:46:27: error: tr1/cinttypes: No such file or directory

make[1]: *** [libmemcached/csl/libmemcached_libmemcached_la-context.lo] エラー 1

make[1]: ディレクトリ `/usr/local/src/memcached/libmemcached-1.0.8' から出ます

make: *** [all] エラー 2

</pre>

 

 

=== 対策 ===

1) 1.0.4 までならエラーは出ないので、それを使う。

 

2) gcc44 を入れる。

 

# yum install gcc44 gcc44-c++ libstdc++44-devel

 

 

# export CC=/usr/bin/gcc44 or export CC=/usr/bin/gcc

# export CXX=/usr/bin/g++44

===========================

10. 编译Nginx

mkdir -p /usr/local/bk/www

tar xvf nginx-1.2.0.tar.gz

cd nginx-1.2.0

./configure --prefix=/usr/local/bk/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre

make

make install

 

vi /usr/local/bk/nginx/conf/nginx.conf

# 修改

# user nobody;

# worker_processes 32;

# 检测 /usr/local/bk/nginx/sbin/nginx -t

server {

    listen 80;

    server_name localhost;

    rewrite_log on;

    #rewrite ^/(([0-9]+\.)+[0-9]+)/ /$1/www/index.php last;

    location / {

        root html;

        index index.html index.htm index.php;

        autoindex on;

    }

    location ~ \.php$ {

        root html;

        fastcgi_pass 127.0.0.1:9000;

        fastcgi_index index.php;

        fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;

        include fastcgi_params;

    } 

}

#

 

 

# /usr/local/bk/php/sbin/php-fpm

# /usr/local/bk/nginx/sbin/nginx

# killall nginx

# killall php-fpm

 

#编译 php-redis 扩展

cd phpredis

/usr/local/bk/php/bin/phpize

./configure --with-php-config=/usr/local/bk/php/bin/php-config

make

make install

vi /usr/local/bk/php/etc/php.ini

#加入 extentsion=redis.so

 

# killall nginx

# killall php-fpm

# /usr/local/bk/php/sbin/php-fpm

# /usr/local/bk/nginx/sbin/nginx

 

 

 

 

 

 

分享到:
评论
1 楼 yzhkpli 2012-07-12  
写的很好。就是没有用sohosin安全组件啊。加上就好了。

相关推荐

Global site tag (gtag.js) - Google Analytics