Centos安装LLsMP教程

LLsMP指的是 Linux+ Litespeed + MYSQL + PHP ,测试环境为本机使用VMWARE搭建的CENTOS5.4虚拟机。

Litespeed是一个高效率,省资源的webserver,分收费版和免费版。免费版和收费版最大的区别就是有连接数的限制,好像是限150个。这个限制对大型网站来说是要命的,但小网站还是完全跑得动的。

首先要卸载apache(如果有装的话),升级,以及安装一些支持库:


yum -y install yum-fastestmirror
yum -y update
yum -y remove httpd
yum -y install patch make gcc gcc-c++ gcc-g77 flex bison tar
yum -y install libtool libtool-libs kernel-devel autoconf213
yum -y install libjpeg libjpeg-devel libpng libpng-devel
yum -y install freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel
yum -y install file glib2 glib2-devel bzip2 diff* openldap-devel
yum -y install bzip2-devel 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 unzip vixie-cron
yum -y install fonts-chinese scim-chewing scim-pinyin scim-tables-chinese
export PHP_AUTOCONF=/wp-content/bin/autoconf-2.13
export PHP_AUTOHEADER=/wp-content/bin/autoheader-2.13
wget -c http://catlnmp.googlecode.com/files/libiconv-1.13.1.tar.gz
tar zxvf libiconv-1.13.1.tar.gz
cd libiconv-1.13.1/
./configure --prefix=/wp-content/local
make
make install
cd ../
wget -c http://catlnmp.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://catlnmp.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://catlnmp.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 /wp-content/local/lib/libmcrypt.la /wp-content/lib/libmcrypt.la
ln -s /wp-content/local/lib/libmcrypt.so /wp-content/lib/libmcrypt.so
ln -s /wp-content/local/lib/libmcrypt.so.4 /wp-content/lib/libmcrypt.so.4
ln -s /wp-content/local/lib/libmcrypt.so.4.4.8 /wp-content/lib/libmcrypt.so.4.4.8
ln -s /wp-content/local/lib/libmhash.a /wp-content/lib/libmhash.a
ln -s /wp-content/local/lib/libmhash.la /wp-content/lib/libmhash.la
ln -s /wp-content/local/lib/libmhash.so /wp-content/lib/libmhash.so
ln -s /wp-content/local/lib/libmhash.so.2 /wp-content/lib/libmhash.so.2
ln -s /wp-content/local/lib/libmhash.so.2.0.1 /wp-content/lib/libmhash.so.2.0.1
ln -s /wp-content/local/bin/libmcrypt-config /wp-content/bin/libmcrypt-config
wget -c http://catlnmp.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 ../
wget -c http://catlnmp.googlecode.com/files/google-perftools-1.6.tar.gz
tar zxvf google-perftools-1.6.tar.gz
cd google-perftools-1.6/
./configure
make && make install
echo "/wp-content/local/lib" > /etc/ld.so.conf.d/usr_local_lib.conf
/sbin/ldconfig
cd ../

然后安装MYSQL,注意倒数第2行为root密码:

wget -c http://catlnmp.googlecode.com/files/mysql-5.1.50.tar.gz
tar -zxvf mysql-5.1.50.tar.gz
cd mysql-5.1.50
./configure --prefix=/wp-content/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 /wp-content/local/mysql/share/mysql/my-medium.cnf /etc/my.cnf
/wp-content/local/mysql/bin/mysql_install_db --user=mysql
chown -R mysql /wp-content/local/mysql/var
chgrp -R mysql /wp-content/local/mysql/.
cp /wp-content/local/mysql/share/mysql/mysql.server /etc/init.d/mysql
chmod 755 /etc/init.d/mysql
chkconfig --level 345 mysql on
echo "/wp-content/local/mysql/lib/mysql" >> /etc/ld.so.conf
echo "/wp-content/local/lib" >>/etc/ld.so.conf
ldconfig
ln -s /wp-content/local/mysql/lib/mysql /wp-content/lib/mysql
ln -s /wp-content/local/mysql/include/mysql /wp-content/include/mysql
service mysql start
/wp-content/local/mysql/bin/mysqladmin -u root password 123456
service mysql restart

接下来,安装Litespeed。

wget http://www.litespeedtech.com/packages/4.0/lsws-4.0.17-std-i386-linux.tar.gz
tar zxvf lsws-4.0.17-std-i386-linux.tar.gz
cd lsws-4.0.17
./install.sh

完成后,请先别关SSH,稍后需要使用。进入后台配置支持PHP:

1.登陆后台 Actions 菜单 Compile PHP

2.选择5.3,点击后面的 next

3.在 Configure Parameters 项里输入下面代码,其它默认即可。建议使用ea缓存组件,可以勾选eAccelerator。

--with-mysql=mysqlnd --with-mysqli=mysqlnd --with-iconv=/wp-content/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

4.下一步后,千万不要刷新或其它操作,静等出现提示信息 Next 。

5.给您一行代码,您需要在ssh里面运行:

/wp-content/local/lsws/phpbuild/buildphp_manual_run.sh

6.其间运行2-5分钟,会出现提示 **COMPLETE** 则表示安装完成,如果中间有错误提示,可以参考一下log文件。看日志部分,最下面有一个ea组件地址的。请记下来,下面有用。例如:

extension_dir = "/wp-content/local/lsws/lsphp5/lib/php/extensions/no-debug-non-zts-20090626/"

7.点击菜单 Actions 里面的 Graceful Restart 重启litespeed。您可以访问 http://your.com/phpinfo.php,如果确认显示php信息,则表示安装成功。

8.Litespeed默认是不开启ea缓存组件的,需要自行配置php.ini文件。把/wp-content/local/lsws/php/php.ini(安装后默认生成文件)复制到/wp-content/local/lsws/lsphp5/lib/里(php.ini文件运行目录)。

打开php.ini,最下面加入:

extension_dir = "/wp-content/local/lsws/lsphp5/lib/php/extensions/no-debug-non-zts-20090626/"
extension="eaccelerator.so"
eaccelerator.shm_size="16"
eaccelerator.cache_dir="/tmp/eaccelerator"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="0"
eaccelerator.shm_prune_period="0"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"

注意,如果你修改过php安装目录,自行按6.中修正。然后,在ssh里执行以下命令,设定ea组件缓存目录,并设置777权限:

mkdir /tmp/eaccelerator
chmod -R 777 /tmp/eaccelerator

最后,这个时候你用探针:http://1.2.3.4/phpinfo.php会提示一个data的错误。找到Module Settings加入data.timezone=PRC就可以了,演示如下:

;;;;;;;;;;;;;;;;;;;
; Module Settings ;
;;;;;;;;;;;;;;;;;;;
[Date]
; Defines the default timezone used by the date functions
date.timezone = PRC

本文大部分内容为转载 原文地址 http://www.vpsmm.com/edu/litespeed-web-server-php-mysql-setup.html

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注