Techyou labs
真正的爱应该超越生命的长度、心灵的宽度、 灵魂的深度
常用标签

安装编译所需要的库:

apt-get install libxml2-dev libmcrypt-dev libssl-dev libldap2-dev libmhash-dev libmysqlclient-dev libcurl4-openssl-dev libpng-dev libjpeg-dev libsasl2-dev

安装libevent

cd ~/src
wget http://monkey.org/~provos/libevent-1.4.13-stable.tar.gz
tar xf libevent-1.4.13-stable.tar.gz
cd libevent-1.4.13-stable
./configure --enable-shared
make
make install

ulimit -SHn 65535

安装pcre

wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.00.tar.gz
tar zxvf pcre-8.00.tar.gz
cd pcre-8.00/
./configure
make && make install

安装libunwind#否则无法安装Google-perftools

cd /libunwind-0.99
./configure --enableshared
make
make install

安装google-perftools#mysql和nginx需要(64位必须加--enable-frame-pointers)

wget http://google-perftools.googlecode.com/files/google-perftools-1.5.tar.gz
./configure --enableshared --enable-frame-pointers
make
make install

下载purge #清除缓存用的

wget http://labs.frickle.com/files/ngx_cache_purge-1.0.tar.gz
tar zxvf ngx_cache_purge-1.0.tar.gz

wget http://nginx.org/download/nginx-0.8.32.tar.gz
tar zxvf nginx-0.8.32.tar.gz
cd nginx-0.8.32/
cd ../
./configure --prefix=/zh/nginx --user=www-data --group=www-data --with-rtsig_module --with-select_module --with-poll_module --with-ipv6 --with-http_ssl_module --with-http_realip_module --with-http_sub_module --with-http_flv_module --with-http_gzip_static_module --with-http_stub_status_module --http-client-body-temp-path=/tmp/nginx/client --http-proxy-temp-path=/tmp/nginx/proxy --http-fastcgi-temp-path=/tmp/nginx/fastcgi --with-google_perftools_module --add-module=/home/web_package/ngx_cache_purge-1.0

启动nginx错误解决办法
1:error while loading shared libraries: libpcre.so.0: cannot open shared object file: No such file or directory
解决方法,在/lib中创建一个symbol link到/usr/local/pcre/lib/libpcre.so.0
sudo ln -s /usr/local/pcre/lib/libpcre.so.0 /lib
2:error while loading shared libraries: libprofiler.so.0: cannot open shared object file: No such file or directory

安装ImageMagick

cd ~/src
apt-get build-dep imagemagick
wget ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick.tar.gz
tar xf ImageMagick.tar.gz
cd ImageMagick-6.5.8-6/
./configure
make
aptitude install libperl-dev
make install

apt-get build-dep php
wget http://cn2.php.net/get/php-5.3.1.tar.bz2/from/this/mirror
tar xf php-5.3.1.tar.bz2

#下载imagick

cd ~/src
wget http://pecl.php.net/get/imagick-2.3.0.tgz
tar xf imagick-2.3.0.tgz
cp -R imagick-2.3.0 php-5.3.1/ext/imagick
cd php-5.3.1
./buildconf --force

#下载php-fpm

apt-get install batch
wget http://launchpad.net/php-fpm/master/0.6/+download/php-fpm-0.6~5.3.1.tar.gz
$ tar -xzf php-fpm-0.6~5.3.1.tar.gz
$ php-fpm-0.6-5.3.1/generate-fpm-patch
$ patch -d php-5.3.1 -p1 $ cd php-5.3.1
$ ./buildconf --force

./configure --prefix=/zh/php5 --with-fpm --with-libxml-dir=/usr --with-fpm-bin=/zh/php5/fpm --with-fpm-conf=/zh/php5/etc --with-fpm-user=www-data --with-fpm-group=www-data --with-layout=GUN --with-config-file-path=/zh/php5/etc --with-config-file-scan-dir=/zh/php5/etc --with-openssl --with-zlib --enable-bcmath --enable-calendar --with-curl --with-curlwrappers --enable-exif --enable-ftp --disable-rpath --with-gd --with-jpeg-dir --with-png-dir --enable-gd-native-ttf --with-gettext --with-mhash --with-imagick --with-imap --with-imap-ssl --with-ldap --enable-mbstring --with-mcrypt --with-mysql=mysqlnd --enable-mbregex --with-mysql-sock --with-mysqli --with-pdo-mysql --with-pdo-sqlite --enable-soap --enable-sockets --enable-sqlite-utf8 --enable-sysvsem --with-xmlrpc --enable-zip --without-pear --enable-shmop --enable-pcntl --with-libevent=shared --with-kerberos

make
make install

安装记录

molyx:/home/web_package/php-5.3.1# make install
Installing PHP SAPI module: fpm
Installing PHP CLI binary: /zh/php5/bin/
Installing PHP CLI man page: /zh/php5/man/man1/
Installing build environment: /zh/php5/lib/php/build/
Installing header files: /zh/php5/include/php/
Installing helper programs: /zh/php5/bin/
program: phpize
program: php-config
Installing man pages: /zh/php5/man/man1/
page: phpize.1
page: php-config.1
/home/web_package/php-5.3.1/build/shtool install -c ext/phar/phar.phar /zh/php5/bin
ln -s -f /zh/php5/bin/phar.phar /zh/php5/bin/phar

update-rc.d php-fpm defaults
sed -i "s/nobody/www-data/g" /etc/php-fpm.conf
/etc/init.d/php-fpm start

make install
cp php.ini-dist /zh/php5/etc/php.ini
ln -s /zh/php5/sbin/php-fpm /etc/init.d/php-fpm
update-rc.d -f php-fpm defaults

编译后的php安装在/opt/php下面,php的配置文件是/opt/php/lib/php.ini

和其他Linux下不同,在Debian下这时候启动php-fpm会失败,原因是在Debian下php-fpm的配置文件中必须指定运行时的用户才行。
优化php-fpm

编辑php-fpm的配置文件/etc/php-fpm.conf,

* 去掉display_errors参数的注释,修改参数值为1
* 去掉sendmail_path参数的注释
* 去掉user,group参数的注释
* 修改max_children参数的值为10

安装php加速器eAccelerator

tar jxf eaccelerator-0.9.5.3.tar.bz2
cd eaccelerator-0.9.5.3
apt-get install -y autoconf
/zh/php5/bin/phpize
./configure --with-php-config=/zh/php5/bin/php-config --enable-eaccelerator --enable-shared
make
make install
mkdir /tmp/php/eaccelerator_cache

然后重启php-fpm,在phpinfo()页面中应该能看到eaccelerator的信息了。

附录:
memcache模块安装:

/zh/php5/bin/phpize
./configure --enable-memcache --enable-shared --with-php-config=/zh/php5/bin/php-config
make
make install
Suhosin模块安装:
/zh/php5/bin/phpize
./configure --with-php-config=/zh/php5/bin/php-config --enable-shared --enable-suhosin
make
make install
extension_dir = "/zh/php5/lib/php/extensions/no-debug-non-zts-20090626"
;suhosin module
[suhosin]
extension=suhosin.so
;memcache module
[memcache]
extension=memcache.so
;eaccelerator module
[eaccelerator]
;zend_extension="/zh/php5/lib/php/extensions/no-debug-non-zts-20090626/eaccelerator.so"
eaccelerator.shm_size="16"
eaccelerator.cache_dir="/tmp/php/eaccelerator_cache"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="3600"
eaccelerator.shm_prune_period="3600"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"

错误解决
1:utf8_mime2text() has new signature, but U8T_CANONICAL is missing
安装c-client
apt-get install libc-client-dev
2:configure: error: libevent.a could not be found. Stop.
使用参数--with-libevent=shared
3:This c-client library is built with Kerberos support.
添加 --with-kerberos to your configure line. Check config.log for details

仅有一条评论
    yzhkpli
    2012-08-04 22:43

    error while loading shared libraries: libprofiler.so.0。这个错误也可以通过在ld.so.conf文件中加入/lib64来解决。

添加新评论