网址导航 在线音乐 免费电影 美女图片 笑话漫画 免费代理 电视影视 小说阅读

 找回密码
 注册
搜索
查看: 1858|回复: 0

Linux/Centos安装Litespeed+PHP+MYSQL教程

[复制链接]
admin 发表于 2010-12-23 14:33:46 | 显示全部楼层 |阅读模式
最近一直在折腾litespeed,感觉这是一个超级节省资源的webserver,HOSTLOC的版主cat也在推荐使用。据说,只要IP/PV不过万,使用150限制的免费版,完全可以操得动。

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


首先要卸载apache,升级,以及安装一些支持库:
  1. yum -y install yum-fastestmirror
  2. yum -y update
  3. yum -y remove httpd
  4. yum -y install patch make gcc gcc-c++ gcc-g77 flex bison tar
  5. yum -y install libtool libtool-libs kernel-devel autoconf213
  6. yum -y install libjpeg libjpeg-devel libpng libpng-devel
  7. yum -y install freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel
  8. yum -y install file glib2 glib2-devel bzip2 diff* openldap-devel
  9. yum -y install bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs
  10. yum -y install e2fsprogs-devel krb5 krb5-devel libidn libidn-devel
  11. yum -y install openssl openssl-devel vim-minimal unzip vixie-cron
  12. yum -y install fonts-chinese scim-chewing scim-pinyin scim-tables-chinese
  13. export PHP_AUTOCONF=/usr/bin/autoconf-2.13
  14. export PHP_AUTOHEADER=/usr/bin/autoheader-2.13
  15. wget -c http://catlnmp.googlecode.com/files/libiconv-1.13.1.tar.gz
  16. tar zxvf libiconv-1.13.1.tar.gz
  17. cd libiconv-1.13.1/
  18. ./configure --prefix=/usr/local
  19. make
  20. make install
  21. cd ../
  22. wget -c http://catlnmp.googlecode.com/files/libevent-1.4.14b-stable.tar.gz
  23. tar zxvf libevent-1.4.14b-stable.tar.gz
  24. cd libevent-1.4.14b-stable/
  25. ./configure --prefix=/usr
  26. make
  27. make install
  28. cd ../
  29. wget -c http://catlnmp.googlecode.com/files/libmcrypt-2.5.8.tar.gz
  30. tar zxvf libmcrypt-2.5.8.tar.gz
  31. cd libmcrypt-2.5.8/
  32. ./configure
  33. make
  34. make install
  35. /sbin/ldconfig
  36. cd libltdl/
  37. ./configure --enable-ltdl-install
  38. make
  39. make install
  40. cd ../../
  41. wget -c http://catlnmp.googlecode.com/files/mhash-0.9.9.9.tar.gz
  42. tar zxvf mhash-0.9.9.9.tar.gz
  43. cd mhash-0.9.9.9/
  44. ./configure
  45. make
  46. make install
  47. cd ../ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la
  48. ln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so
  49. ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4
  50. ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8
  51. ln -s /usr/local/lib/libmhash.a /usr/lib/libmhash.a
  52. ln -s /usr/local/lib/libmhash.la /usr/lib/libmhash.la
  53. ln -s /usr/local/lib/libmhash.so /usr/lib/libmhash.so
  54. ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2
  55. ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1
  56. ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-configwget -c http://catlnmp.googlecode.com/files/mcrypt-2.6.8.tar.gz
  57. tar zxvf mcrypt-2.6.8.tar.gz
  58. cd mcrypt-2.6.8/
  59. ./configure
  60. make
  61. make install
  62. cd ../
  63. wget -c http://catlnmp.googlecode.com/files/google-perftools-1.6.tar.gz
  64. tar zxvf  google-perftools-1.6.tar.gz
  65. cd google-perftools-1.6/
  66. ./configure
  67. make && make install
  68. echo "/usr/local/lib" > /etc/ld.so.conf.d/usr_local_lib.conf
  69. /sbin/ldconfig
  70. cd ../
复制代码
然后安装MYSQL,注意倒数第2行为root密码:
  1. wget -c http://catlnmp.googlecode.com/files/mysql-5.1.50.tar.gz
  2. tar -zxvf mysql-5.1.50.tar.gz
  3. cd mysql-5.1.50
  4. ./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
  5. make && make install
  6. cd ../
  7. groupadd mysql
  8. useradd -g mysql mysql
  9. cp /usr/local/mysql/share/mysql/my-medium.cnf /etc/my.cnf
  10. /usr/local/mysql/bin/mysql_install_db --user=mysql
  11. chown -R mysql /usr/local/mysql/var
  12. chgrp -R mysql /usr/local/mysql/.
  13. cp /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysql
  14. chmod 755 /etc/init.d/mysql
  15. chkconfig --level 345 mysql on
  16. echo "/usr/local/mysql/lib/mysql" >> /etc/ld.so.conf
  17. echo "/usr/local/lib" >>/etc/ld.so.conf
  18. ldconfig
  19. ln -s /usr/local/mysql/lib/mysql /usr/lib/mysql
  20. ln -s /usr/local/mysql/include/mysql /usr/include/mysql
  21. service mysql start
  22. /usr/local/mysql/bin/mysqladmin -u root password 123456
  23. service mysql restart
复制代码
接下来,安装Litespeed。(详细安装步骤点此查看)
  1. wget http://www.litespeedtech.com/packages/4.0/lsws-4.0.17-std-i386-linux.tar.gz
  2. tar zxvf lsws-4.0.17-std-i386-linux.tar.gz
  3. cd lsws-4.0.17
  4. ./install.sh
复制代码
完成后,请先别关SSH,稍后需要使用。进入后台配置支持PHP:

1.登陆后台 Actions 菜单 Compile PHP

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

3.在 Configure Parameters 项里输入下面代码,其它默认即可。建议使用ea缓存组件,可以勾选eAccelerator,小夜测试这个是最给力的。
  1. --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里面运行:
  1. /usr/local/lsws/phpbuild/buildphp_manual_run.sh
复制代码
6.其间运行2-5分钟,会出现提示 **COMPLETE** 则表示安装完成,如果中间有错误提示,可以参考一下log文件。看日志部分,最下面有一个ea组件地址的。请记下来,下面有用。例如:
  1. 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,最下面加入:
  1. extension_dir = "/usr/local/lsws/lsphp5/lib/php/extensions/no-debug-non-zts-20090626/"
  2. extension="eaccelerator.so"
  3. eaccelerator.shm_size="16"
  4. eaccelerator.cache_dir="/tmp/eaccelerator"
  5. eaccelerator.enable="1"
  6. eaccelerator.optimizer="1"
  7. eaccelerator.check_mtime="1"
  8. eaccelerator.debug="0"
  9. eaccelerator.filter=""
  10. eaccelerator.shm_max="0"
  11. eaccelerator.shm_ttl="0"
  12. eaccelerator.shm_prune_period="0"
  13. eaccelerator.shm_only="0"
  14. eaccelerator.compress="1"
  15. eaccelerator.compress_level="9"
复制代码
注意,如果你修改过php安装目录,自行按6.中修正。然后,在ssh里执行以下命令,设定ea组件缓存目录,并设置777权限:
  1. mkdir /tmp/eaccelerator
  2. chmod -R 777 /tmp/eaccelerator
复制代码
最后,这个时候你用探针:http://1.2.3.4/phpinfo.php会提示一个data的错误。找到Module Settings加入data.timezone=PRC就可以了,演示如下:
  1. ;;;;;;;;;;;;;;;;;;;
  2. ; Module Settings ;
  3. ;;;;;;;;;;;;;;;;;;;
  4. [Date]
  5. ; Defines the default timezone used by the date functions
  6. date.timezone = PRC
复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表