本站环境Litespeed+php+mysql+ZendGuardLoader配置教程
一直想好好做个博客记录一下东西,毕竟很多东西一段时间后会忘记,记得研究Litespeed是前年(2010年)的事情了,而一直没有用于生产,于是本博客也经常夭折,因为WP实在是太耗服务器资源,nginx,apache,kloxo等环境跑起来有点吃力,内存也占用过多!
今天我用一台128M内存的闲置VPS安装环境,放此博客,系统:centos5;内存:128M;CPU:Intel(R) Xeon(R) CPU E5620(限制单核).
可能大家会对Litespeed比较陌生,而且Litespeed也是一款商业软件,不过有免费版的,免费版限制就是只有150个连接数,一般站点150个连接数是足够的,如果不够可以考虑采用nginx前端Litespeed后端的模式,静态内容全部走nginx并发,Litespeed走动态并发!每天IP不超过1W的使用免费版问题不大.
这里我选择的软件版本为:
Litespeed:lsws-4.1.10-std,php:5.3.8,mysql:mysql-5.1.60
首先,安装一些所需的程序:
yum -y install yum-fastestmirror
yum -y remove httpd
yum -y update
yum -y install patch make gcc gcc-c++ gcc-g77 flex bison file
yum -y install libtool libtool-libs autoconf kernel-devel
yum -y install libjpeg libjpeg-devel libpng libpng-devel libpng10 libpng10-devel gd gd-devel
yum -y install freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel
yum -y install glib2 glib2-devel bzip2 bzip2-devel libevent libevent-devel
yum -y install ncurses ncurses-devel curl curl-devel e2fsprogs
yum -y install e2fsprogs-devel krb5 krb5-devel libidn libidn-devel
yum -y install openssl openssl-devel vim-minimal nano sendmail
yum -y install fonts-chinese gettext gettext-devel
yum -y install ncurses-devel
yum -y install gmp-devel pspell-devel
yum -y install unzip
export PHP_AUTOCONF=/usr/bin/autoconf-2.13
export PHP_AUTOHEADER=/usr/bin/autoheader-2.13
安装PHP 5.3.8所需的支持库:
wget -c http://whhack.googlecode.com/files/libiconv-1.13.1.tar.gz
tar zxvf libiconv-1.13.1.tar.gz
cd libiconv-1.13.1/
./configure --prefix=/usr/local
make
make install
cd ../
wget -c http://whhack.googlecode.com/files/libevent-1.4.14b-stable.tar.gz
tar zxvf libevent-1.4.14b-stable.tar.gz
cd libevent-1.4.14b-stable/
./configure --prefix=/usr
make
make install
cd ../
wget -c http://whhack.googlecode.com/files/libmcrypt-2.5.8.tar.gz
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 ../../
wget -c http://whhack.googlecode.com/files/mhash-0.9.9.9.tar.gz
tar zxvf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9/
./configure
make
make install
cd ../
ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la
ln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so
ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4
ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8
ln -s /usr/local/lib/libmhash.a /usr/lib/libmhash.a
ln -s /usr/local/lib/libmhash.la /usr/lib/libmhash.la
ln -s /usr/local/lib/libmhash.so /usr/lib/libmhash.so
ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2
ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1
ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config
wget -c http://whhack.googlecode.com/files/mcrypt-2.6.8.tar.gz
tar zxvf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8/
./configure
make
make install
cd ../
(可选)安装Google的开源TCMalloc库google-perftools-1.9.1,提高MySQL在高并发情况下的性能:
wget -c http://whhack.googlecode.com/files/google-perftools-1.9.1.tar.gz
tar zxvf google-perftools-1.9.1.tar.gz
cd google-perftools-1.9.1/
./configure
make && make install
echo "/usr/local/lib" > /etc/ld.so.conf.d/usr_local_lib.conf
/sbin/ldconfig
cd ../
安装mysql:
wget -c http://whhack.googlecode.com/files/mysql-5.1.60.tar.gz
tar -zxvf mysql-5.1.60.tar.gz
cd mysql-5.1.60
./configure --prefix=/usr/local/mysql --with-extra-charsets=all --enable-thread-safe-client --enable-assembler --with-charset=utf8 --enable-thread-safe-client --with-extra-charsets=all --with-big-tables --with-readline --with-ssl --with-embedded-server --enable-local-infile --without-debug --with-mysqld-ldflags=-ltcmalloc_minimal
make && make install
cd ../
groupadd mysql
useradd -g mysql mysql
cp /usr/local/mysql/share/mysql/my-medium.cnf /etc/my.cnf
/usr/local/mysql/bin/mysql_install_db --user=mysql
chown -R mysql /usr/local/mysql/var
chgrp -R mysql /usr/local/mysql/.
cp /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysql
chmod 755 /etc/init.d/mysql
chkconfig --level 345 mysql on
echo "/usr/local/mysql/lib/mysql" >> /etc/ld.so.conf
echo "/usr/local/lib" >>/etc/ld.so.conf
ldconfig
ln -s /usr/local/mysql/lib/mysql /usr/lib/mysql
ln -s /usr/local/mysql/include/mysql /usr/include/mysql
service mysql start
/usr/local/mysql/bin/mysqladmin -u root password root //密码自己修改
service mysql restart
再来安装LiteSpeed:
wget http://www.litespeedtech.com/packages/4.0/lsws-4.1.10-std-i386-linux.tar.gz
tar zxvf lsws-4.1.10-std-i386-linux.tar.gz
cd lsws-4.1.10
./install.sh
出现--More--(27%)的许可协议,可以直接按空格键或者回车跳到最后.
Do you agree with above license? #这里需要输入Yes (Y要大写)
下面的基本一直回车和选Y,Email之类的看着写,很简单...
安装完成就可以访问http://IP:7080来管理LiteSpeed;
安装php:
在litespeed控制面板选择Compile PHP
然后选择要安装的php版本,我这里选择php5.3.8,可以选择eAccelerator/XCache,因为我们这里需要安装ZendGuardLoader,不要选择APC.
然后用以下参数编译:
--with-mysql=mysqlnd --with-mysqli=mysqlnd --with-iconv=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --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 --enable-ftp --disable-debug --with-gettext --with-openssl
然后就是下一步,到最后一步的时候出现要求你执行:
/usr/local/lsws/phpbuild/buildphp_manual_run.sh
然后就是等待了,可以在安装界面里面看到详细的进度,一般需要几分钟到十几分钟(或更久)!
如果安装后/usr/local/lsws/lsphp5/lib/php.ini不存在,那么把 /usr/local/lsws/php/php.ini 复制到/usr/local/lsws/lsphp5/lib/目录下。
在php.ini末尾添加eAccelerator:
[eaccelerator]
zend_extension="/usr/local/lsws/lsphp5/lib/php/extensions/no-debug-non-zts-20090626/eaccelerator.so"
eaccelerator.shm_size="1"
eaccelerator.cache_dir="/usr/local/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"
eaccelerator.keys = "disk_only"
eaccelerator.sessions = "disk_only"
eaccelerator.content = "disk_only"
最后安装ZendGuardLoader:
wget -c http://whhack.googlecode.com/files/ZendGuardLoader-php-5.3-linux-glibc23-i386.tar.gz
tar zxvf ZendGuardLoader-php-5.3-linux-glibc23-i386.tar.gz
mkdir -p /usr/local/zend/
cp ZendGuardLoader-php-5.3-linux-glibc23-i386/php-5.3.x/ZendGuardLoader.so /usr/local/zend/
在php.ini末尾添加Zend:
[Zend.loader]
zend_loader.enable=1
zend_loader.disable_licensing=1
zend_loader.obfuscation_level_support=3
zend_loader.license_path=
zend_extension="/usr/local/zend/ZendGuardLoader.so"
来看看php有没错误:/usr/local/lsws/lsphp5/bin/php -v
最后重启一下,面板中点击Graceful Restart,或者执行:
/etc/init.d/lsws restart
好了,大工告成了,至此环境安装完毕!有什么问题可以在下面留言!