安裝Litespeed+PHP+MYSQL教程

     Litespeed是一個超級節省資源的webserver。據說,只要IP/PV不過萬,使用150限制的免費版,完全可以操得動。

    安裝測試環境,用的是VPS.GL(詳細介紹)的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 -chttp://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://yourip/phpinfo.php會提示一個data的錯誤。找到Module Settings加入data.timezone=PRC就可以了,演示如下:

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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章