LiteSpeed is good for Apache alternative, it is faster, more efficient, and also fully interchangeable with Apache. It is GUI based so you don’t have to worried about the setting, just copy paste, click right here and right there from the administration panel. The main shortage of LiteSpeed standard edition is just maximum 150 concurrent connection and 5 virtual hosts, still good for low to middle end websites with little budget. If you need webserver to serve more virtual host, you can switch to Nginx. Now we will begin with LiteSpeed installation.
VPS: CentOS 5.5 64bit with 256MB RAM OpenVZ
note:
– If you want to run the standard version on 64bit Linux, you need to install 32bit compatible libraries (glibc for CentOS) – ref: LiteSpeed
– If you want to run the standard version on 32bit Linux, pay attention for library directory name, change “/usr/lib64” to “/usr/lib”
Install dependencies and update
yum -y install gcc gcc-c++ glibc make automake GeoIP GeoIP-devel GeoIP-data fontconfig fontconfig-devel gd gd-devel pam pam-devel openldap openldap-devel libXpm libXpm-devel libtool libaio libaio-devel libtool-ltdl libtool-ltdl-devel libmcrypt libmcrypt-devel mhash mhash-devel unixODBC unixODBC-devel zip unzip nano perl openssl openssl-devel pcre pcre-devel bzip2 bzip2-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel aspell aspell-devel yum -y update
Remove Old Apps
yum -y remove httpd php mysql
Now i’m going to update a few modules for PHP 5.3.5 dependencies to the latest version, because CentOS has not yet released the latest version of these modules. If you want to use current version from CentOS repository and make it simple by using yum, you can install the following modules and skip the Install / Update the latest modules version section. (go straight to the MySQL installation)
yum -y install gnupg curl curl-devel libidn libidn-devel libc-client libc-client-devel.`uname -i` libxslt tidy libtidy libtidy-devel
Install / Update the latest modules version
yum -y remove gnupg curl curl-devel libidn libidn-devel libc-client libc-client-devel.`uname -i` libxslt tidy libtidy libtidy-devel
wget ftp://ftp.gnupg.org/gcrypt/gnupg/gnupg-1.4.11.tar.gz tar -zxvf gnupg-1.4.11.tar.gz cd gnupg-1.4.11 ./configure make make install cd wget http://ftp.gnu.org/gnu/libidn/libidn-1.9.tar.gz tar -zxvf libidn-1.9.tar.gz cd libidn-1.9 ./configure make make install ln -s /usr/local/lib/libidn* /usr/lib64 cd wget http://curl.haxx.se/download/curl-7.21.4.tar.gz tar -zxvf curl-7.21.4.tar.gz cd curl-7.21.4 ./configure --with-openssl --with-libidn --enable-ipv6 make make install ln -s /usr/local/lib/libcurl* /usr/lib64 cd wget ftp://xmlsoft.org/libxml2/libxml2-2.7.8.tar.gz tar -zxvf libxml2-2.7.8.tar.gz cd libxml2-2.7.8 ./configure make make install rm -rf /usr/lib64/libxml2* ln -s /usr/local/lib/libxml2* /usr/lib64 cd wget ftp://xmlsoft.org/libxml2/libxslt-1.1.26.tar.gz tar -zxvf libxslt-1.1.26.tar.gz cd libxslt-1.1.26 ./configure make make install rm -rf /usr/lib64/libxslt* /usr/lib64/libexslt* ln -s /usr/local/lib/libxslt* /usr/lib64 ln -s /usr/local/lib/libexslt* /usr/lib64 cd rpm -Uvh http://dl.atrpms.net/el5-`uname -i`/atrpms/stable/libc-client2007-2007e-8.el5.`uname -i`.rpm rpm -Uvh http://dl.atrpms.net/el5-`uname -i`/atrpms/stable/uw-imap-devel-2007e-8.el5.`uname -i`.rpm rpm -Uvh http://dl.atrpms.net/el5-`uname -i`/atrpms/stable/uw-imap-static-2007e-8.el5.`uname -i`.rpm rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/`uname -i`/libtidy-0.99.0-14.20070615.el5.`uname -i`.rpm rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/`uname -i`/libtidy-devel-0.99.0-14.20070615.el5.`uname -i`.rpm rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/`uname -i`/tidy-0.99.0-14.20070615.el5.`uname -i`.rpm
Install MySQL
rpm -Uvh http://www.mirrorservice.org/sites/ftp.mysql.com/Downloads/MySQL-5.5/MySQL-shared-compat-5.5.10-1.linux2.6.`uname -i`.rpm rpm -Uvh http://www.mirrorservice.org/sites/ftp.mysql.com/Downloads/MySQL-5.5/MySQL-shared-5.5.10-1.linux2.6.`uname -i`.rpm rpm -Uvh http://www.mirrorservice.org/sites/ftp.mysql.com/Downloads/MySQL-5.5/MySQL-devel-5.5.10-1.linux2.6.`uname -i`.rpm rpm -Uvh http://www.mirrorservice.org/sites/ftp.mysql.com/Downloads/MySQL-5.5/MySQL-embedded-5.5.10-1.linux2.6.`uname -i`.rpm rpm -Uvh http://www.mirrorservice.org/sites/ftp.mysql.com/Downloads/MySQL-5.5/MySQL-server-5.5.10-1.linux2.6.`uname -i`.rpm rpm -Uvh http://www.mirrorservice.org/sites/ftp.mysql.com/Downloads/MySQL-5.5/MySQL-client-5.5.10-1.linux2.6.`uname -i`.rpm
MySQL configuration
There are 5 default MySQL configuration:
my-innodb-heavy-4G.cnf
my-huge.cnf
my-large.cnf
my-medium.cnf
my-small.cnf
choose one of those configurations depending on your needs, move to “/etc/” directory and rename it to “my.cnf”. Here i’m going to use the smallest configuration to because this box has only 256MB memory plus dedicated to serve a small blog with small visitors per day.
cp /usr/share/mysql/my-small.cnf /etc/my.cnf
I’m going to cut more memory usage by using MyISAM engine rather than InnoDB.
nano /etc/my.cnf
add the following lines to “[mysqld]” section
default-storage-engine=MyISAM
skip-innodb
now start MySQL, create system tables, and securing.
/etc/init.d/mysql start /usr/bin/mysql_install_db mysql_secure_installation /etc/init.d/mysql stop chkconfig --add mysql chkconfig mysql on
Install LiteSpeed
wget http://www.litespeedtech.com/packages/4.0/lsws-4.0.20-std-i386-linux.tar.gz tar -zxvf lsws-4.0.20-std-i386-linux.tar.gz cd lsws-4.0.20 chmod +x install.sh ./install.sh
Do you agree with above license: Yes
Destination: /usr/local/lsws (my preferred LiteSpeed directory)
Username: your preferred username for administration panel
Password: your preferred password for administration panel
Email addresses: your email address
User: nobody
Group: nobody
HTTP port: 80
Admin HTTP port: choose any port above 2000
Setup PHP: Y
Suffix for PHP script: php
Install AWStats Add-on modul: N
LiteSpeed restart automatically when server restarts: Y
Would you like to start it now: Y
Compiling PHP 5.3.5 with required modules
Here’s the interesting part of LiteSpeed, half GUI-based for compiling PHP
Login to your LiteSpeed administration panel
– Open: http://yourip:youradminport
– Go to Action – Compile PHP, select PHP 5.3.5 and push next button
Extra PATH environment: Leave this empty
Install Path Prefix: /usr/local/lsws/lsphp5
Configure Parameters:--prefix=/lsphp5 --with-litespeed --enable-cli --with-mcrypt --enable-mbstring --with-openssl --with-mysql=/usr/bin --with-mysqli --with-mysql-sock=/var/lib/mysql/mysql.sock --with-pdo-mysql --with-gd --with-zlib --with-jpeg-dir=/usr/lib64 --with-png-dir=/usr/lib64 --with-png --with-jpeg --with-gmp --with-sqlite --enable-pdo --with-libdir=lib64 --with-xpm-dir=/usr/lib64 --with-freetype-dir=/usr/include/freetype2 --with-ttf=/usr/include/freetype2 --libdir=/usr/lib64 --enable-gd-native-ttf --enable-fileinfo --disable-debug --with-pic --with-bz2 --with-curl --with-curlwrappers --without-gdbm --with-gettext --with-iconv --with-pspell --with-pcre-regex --with-imap --with-imap-ssl=/usr/lib64 --enable-exif --enable-ftp --enable-magic-quotes --enable-sockets --disable-sysvsem --disable-sysvshm --disable-sysvmsg --enable-track-vars --enable-trans-sid --enable-yp --enable-wddx --with-kerberos --enable-ucd-snmp-hack --enable-memory-limit --enable-shmop --enable-calendar --enable-dbx --enable-dio --with-mime-magic --with-system-tzdata --with-odbc --enable-gd-jis-conv --enable-dom --disable-dba --enable-xmlreader --enable-xmlwriter --with-tidy --with-xml --with-xmlrpc --with-xsl --enable-bcmath --enable-soap --enable-zip --enable-inline-optimization --with-mhash --enable-mbregexAdd-on Modules: Check only XCache or eAccelerator for PHP Opcode Cacher module, we will install Suhosin extension later.
– Push build button and wait until configure process has finished or check the status until **PREPARE_DONE**
– After finished, click next button and run the following command from your ssh (root)
/usr/local/lsws/phpbuild/buildphp_manual_run.sh
wait about 5 – 10 minutes until the process finished (it will shown **COMPLETE** status)
– Apply changes and Graceful restart
Check your PHP installation status
/usr/local/lsws/fcgi-bin/lsphp5 -v
PHP 5.3.5 (litespeed) (built: Feb 18 2011 15:32:54)
Copyright (c) 1997-2004 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
Install IonCube Loader
wget http://downloads2.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz tar -zxvf ioncube_loaders_lin_x86-64.tar.gz mv ioncube/ioncube_loader_lin_5.3.so /usr/lib64/extensions/no-debug-non-zts-20090626/
Install Suhosin Extension
wget http://download.suhosin.org/suhosin-0.9.32.1.tar.gz tar -zxvf suhosin-0.9.32.1.tar.gz cd suhosin-0.9.32.1 /usr/local/lsws/lsphp5/bin/phpize ./configure --enable-suhosin --with-php-config=/usr/local/lsws/lsphp5/bin/php-config make make install
Copy php.ini to lib directory
cp /usr/local/lsws/php/php.ini /usr/lib64
declare the installed extensions to php.ini (IonCube, eAccelerator, Suhosin)
nano /usr/lib64/php.ini
zend_extension="/usr/lib64/extensions/no-debug-non-zts-20090626/ioncube_loader_lin_5.3.so"
zend_extension="/usr/lib64/extensions/no-debug-non-zts-20090626/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"
extension="/usr/lib64/extensions/no-debug-non-zts-20090626/suhosin.so"
Create eAccelerator tmp folder
mkdir /tmp/eaccelerator chmod 0777 /tmp/eaccelerator
restart LiteSpeed
/usr/local/lsws/bin/lswsctrl restart
check PHP 5.3.5 plus IonCube and eAccelerator status
/usr/local/lsws/fcgi-bin/lsphp5 -v
PHP 5.3.5 (litespeed) (built: Feb 18 2011 15:32:54)
Copyright (c) 1997-2004 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
with the ionCube PHP Loader v4.0.7, Copyright (c) 2002-2011, by ionCube Ltd.
, and
with eAccelerator v0.9.6.1, Copyright (c) 2004-2010 eAccelerator, by eAccelerator
with Suhosin v0.9.32.1, Copyright (c) 2007-2010, by SektionEins GmbH
LiteSpeed Standard Edition + PHP 5.3.5 with IonCube, eAccelerator, and Suhosin extension + MySQL has been installed, now let’s create and configure Virtual Host.
Install PureFTPD
please take a look on my previous post for installing PureFTPD
Create domain root directory
useradd domain.com passwd domain.com mkdir /home/domain.com/public_html /home/domain.com/cgi-bin /home/domain.com/logs chown -R domain.com:domain.com /home/domain.com
Configure domain virtual host
– Open: http://yourip:youradminport
– Go to Configuration – Virtual Host Templates, choose PHP_SuEXEC (i prefer phpsuexec)
– Go to General tab and edit Template Settings
Virtual Host Root: /home/$VH_NAME/
Config File: $SERVER_ROOT/conf/$VH_NAME.xml
Max Keep-Alive Requests: leave this empty
Smart Keep-Alive: Yes
Document Root: $VH_ROOT/public_html/
Enable GZIP Compression: Yes
Enable IP GeoLocation: Not Set
Administrator Email: your email
– Save and Graceful Restart
Add domain
– Go to Configuration – Virtual Host Templates, choose PHP_SuEXEC
– Go to Template tab and add Member Virtual Hosts
Virtual Host Name: domain.com
Domain: domain.com
Aliases: domain.com
Virtual Host Root: /home/domain.com/
– Save and Graceful Restart
*you might get the following error:
Input error detected. Please resolve the error(s).
*path /home/domain.com/ is not readable
solution:
chmod 755 -R /home/domain.com
Now create phpinfo.php
nano /home/domain/public_html/phpinfo.php
<?php phpinfo(); ?>
Voila!!!
Thanks to
– Uncle G
– RootZone.net
How I can remove this Suhosin version?
Because I used php 5.2.17
Thank you!!
remove the line extension=suhosin.so in php.ini
Thank you very much,
Could you help me how to start purefptd on startup and others service needed in this setup guide?
you can take a look at my previous post for phpmyadmin, pureftpd, and the others.
and how to install phpmyadmin for litespeed ?
Another question
Why I always should execute this command
chown -R domain.com:domain.com /home/domain.com
I don’t know, but I lost this permission after executed it in period of time and I had to run it again (I can delete file or set permission via filezilla)
chown doesn’t have timeout, maybe because you’re accessing your domain directory using root user before you’re manage your files via filezilla.
Hi,
Thank You, I moved from Apache to LiteSpeed Std+PHP+MySQL.
My 256mb VPS is now flying along with 3 domains, using WordPress Blogs with moderate traffic.
Excellent Instructions.
Although XCache is better than eAccelorator with LS+WordPress.
Hi, glad to hear that. Anyway are you using litespeed standard edition or vps edition?
howto i can install zend optimizer???
Zend Optimizer doesn’t support PHP 5.3.x
2298 i use: Look at the URL
but when I open the web page i see meesage Zend Optimizer not installed. I really need help. I could not find help on the google 🙁
told you before, zend optimizer doesn’t support PHP 5.3.x, use 5.2.x if you want to install zend optimizer.
anyway, what url mate?
just click on my name in this forum
spramogos.lt/phpinfo.php ? i’m unable to connect
/usr/local/lsws/phpbuild/buildphp_1304341161.2.prep.sh: line 128: patch: command not found
**ERROR** Could not patch source with Suhosin patch
please help me
thanks a lot
That’s why i told to choose only php opcode cacher module, suhosin patch doesn’t work on php 5.3.5, you can only use suhosin extension and install it manually, see the post.
Hello,
I was wondering if anyone would set this up for me on a 64Bit CentOS OpenVZ VPS? Email at joshua1432 (at) gmail.com I will pay for help 🙂
In litespeed, how can we modify the PHP values locally for a domain using the php.ini method for suPHP + Apache ?? Thanks.
Hi, i don’t get what you mean by PHP values locally for domain.
I got this error when accessing subdirectory of virtualhost.
403 Forbidden
Access to this resource on the server is denied!
could u tell me what wrong ? thank you..
Hello,
Can u make a guide for HotLink protection too..?
thank u very much !