Litespeed安装教程:配置PHP+MYSQL教程

http://www.itjxue.com  2015-07-19 16:36  来源:未知  点击次数: 

最近一直在折腾litespeed,感觉这是一个超级节省资源的webserver,HOSTLOC的版主cat也在推荐使用。据说,只要IP/PV不过万,使用150限制的免费版,完全可以操得动。

 安装测试环境,仍旧是DS2刀(详细介绍)的VPS。真的很耐操,系统采用的是centos 32bit版本,稍后我会上关于添加虚拟主机的教程。

首先要卸载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=/usr/bin/autoconf-2.13
export PHP_AUTOHEADER=/usr/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=/usr/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 /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-configwget -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 "/usr/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=/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 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=/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

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

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

/usr/local/lsws/phpbuild/buildphp_manual_run.sh

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

extension_dir = "/usr/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文件。把/usr/local/lsws/php/php.ini(安装后默认生成文件)复制到/usr/local/lsws/lsphp5/lib/里(php.ini文件运行目录)。

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

extension_dir = "/usr/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

(责任编辑:IT教学网)

更多