Debian安装LiteSpeed+PHP+MySQL

由于笔者之前在HawkHost和StableHost的虚拟主机使用的是LiteSpeed服务器,使用感觉性能确实比Apache的虚拟主机要快不少,而且据说也比较节省资源,因而在VPS上也选择使用LiteSpeed。下面介绍一下Debian下安装LiteSpeed的方法:

  1. 清理Debian,去除不必要的软件包
  2. 安装MySQL及相关的库文件
  3. 安装LiteSpeed
  4. 编译指定版本PHP

清理包

apt-get -y purge apache2-* bind9-* xinetd samba-* nscd-* portmap sendmail-* sasl2-bin  apache2-* bind9-* xinetd samba-* nscd-* portmap sendmail-* sasl2-bin && apt-get autoremove && apt-get clean

安装MySQL及其他库文件

apt-get install autoconf gcc g++ libjpeg62-dev libpng12-dev libxml2-dev curl libcurl4-openssl-dev libmcrypt-dev libmhash-dev libfreetype6-dev patch make mcrypt mysql-server libmysql++-dev zlib-bin zlib1g-dev && apt-get update && apt-get upgrade

请注意在中途输入MySQL密码

安装LiteSpeed

在LiteSpeed的下载页面找到对应版本,http://litespeedtech.com/litespeed-web-server-downloads.html,请注意使用“LiteSpeed Web Server Standard Edition: Free”,别的是要收费的,此处比这下载的是:http://litespeedtech.com/packages/4.0/lsws-4.1.13-std-i386-linux.tar.gz。

wget http://litespeedtech.com/packages/4.0/lsws-4.1.13-std-i386-linux.tar.gz
tar zxvf lsws*
sh lsws*/install.sh

一直输入回车,只到出现 Do you agree the license? 时输入Yes,然后按照如下内容进行输入。

Destination [/usr/local/lsws]: 回车
User name [admin]:管理员账号(默认admin)
Password:管理员密码
Retype password:密码确认
Email addresses [root@localhost]:你的邮箱
User [nobody]:默认,直接回车
Group [nogroup]:默认,直接回车
HTTP port [8088]:写80
Admin HTTP port [7080]:Litespeed面板端口,可默认,直接Enter
Setup up PHP [Y/n]:默认,直接回车
Suffix for PHP script(comma separated list) [php]:默认,直接回车
Would you like to install AWStats Add-on module [y/N]?默认,直接回车
Would you like to have LiteSpeed Web Server started automatically when the server restarts [Y/n]?默认,直接回车
Would you like to start it right now [Y/n]?默认,直接回车

编译自定义的PHP版本

访问litespeed管理后台:http://ip:7080

点击Actions->Compile PHP

选择PHP版本,点击Next(我选择的是5.3.23)

在编译参数中填写为如下段,

--with-pdo-mysql --with-mysql --with-mysqli --with-zlib --with-gd --enable-shmop --enable-track-vars --enable-sockets --enable-sysvsem --enable-sysvshm --enable-magic-quotes --enable-mbstring --with-iconv --with-litespeed --enable-inline-optimization --with-curl --with-curlwrappers --with-mcrypt --with-mhash --with-mime-magic --with-openssl --with-freetype-dir=/usr/lib --with-jpeg-dir=/usr/lib --disable-fileinfo

点击Build PHP 5.x.x

等待LiteSpeed完成包下载后,点击Next,然后使用SSH输入(切勿刷新页面!):

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

然后等待显示“*Complete*”完成编译