Lighttpd与HHVM快速搭建方法-让小内存VPS主机体验极致PHP性能
hhvm强大的PHP性能大家已经在HHVM安装使用教程中看到,同等条件下HHVM可以处理的Web请求吞吐量增加了9倍,而内存消耗减少5倍,如此高效率的PHP性能可以给一些大型的网站带来在速度优化方面的质的飞跃。
目前hhvm官方并没有标明HHVM适合多大内存的VPS主机来运行,但是为了能够充分发挥好hhvm在PHP性能提升的优势,VPS主机的服务器自然是配置高一点为好。hhvm与Nginx搭建是一个不错的选择,hhvm与apache结合不是很推荐。
这篇文章就是要说的是lighttpd与hhvm快速搭建方法,Lighttpd出自德国人,具有非常低的内存消耗、CPU占用率低、性能好以及丰富的模块等特点,支持FastCGI,CGI,Auth,输出压缩(output compress),URL重写,Alias等重要功能。
更多有关于VPS主机性能优化及加速的方法还有:
- 1、HHvm WP:HHvm Apache 2.4 Nginx建站环境搭建方法安装运行WordPress博客
- 2、均衡:免费空间+便宜VPS和OpenResty,Ngx_lua,Redis搭建系统负载均衡环境
- 3、缓存加速:用Redis缓存来给WordPress站点加速-适用于Apache和Nginx
lighttpd与hhvm快速搭建方法-让小内存VPS主机体验极致PHP性能
一、 Apache、Nginx、Lighttpd三款软件性能比较
1、Apache 、Nginx 、Lighttpd这三个是现在比较流行的Web服务器软件,Lighttpd开发的初衷就是极低的内存消耗和CPU占用,因此它比较适合低内存的VPS主机使用。
2、而Apache和Nginx 等各有各的特点,关于这两者之间谁强谁弱尚存在不少的争议,下面是一个Apache Nginx Lighttpd三款软件性能比较图,大家能够观察各自的优缺点了。(点击放大)
二、hhvm、Lighttpd、Fastcgi安装方法
1、这里以Debian VPS例,先是HHVM的apt源。
wget https://dl.hhvm.com/conf/hhvm.gpg.key
sudo apt-key add hhvm.gpg.key
echo "deb https://dl.hhvm.com/debian wheezy main">> /etc/apt/sources.list
sudo apt-get update
2、 当我们添加好HHVM源以后,可以直接使用一条代码就安装完Lighttp 、HHVM 、Mysql和Fastcgi 。
sudo apt-get update
sudo apt-get remove apache2 apache2-*
sudo apt-get install lighttpd mysql-server hhvm #中间需要输入一次mysql密码
sudo /usr/share/hhvm/install_fastcgi.sh #安装Fastcgi
sudo update-rc.d hhvm defaults #添加到开机启动
sudo service hhvm restart #重启HHVM
1、进入到/etc/lighttpd/conf-available,编辑10-fastcgi-hhvm.conf文件,输入下面保存。
server.modules += ("mod_fastcgi")
fastcgi.server = ( ".php" =>
((
"host" => "127.0.0.1",
"port" => "9000"
))
)
2、 接着我们开启Fastcgi 。
lighty-disable-mod fastcgi
lighty-enable-mod fastcgi-hhvm
lighty-enable-mod fastcgi-php
/etc/init.d/lighttpd force-reload
1、Lighttpd添加虚拟主机。找到Lighttpd安装目录下的etc/lighttpd.conf文件,在最后添加(注意:如果是配置多个虚拟主机,只要重复添加代码即可):
$HTTP["host"] == "www.a.com" {
server.document-root = "网站的路径"
}
2、如果是多个域名指向同一个目录,代码是:
$HTTP["host"] =~ "^(www.a.com|a.com)$"{
server.document-root = "网站路径"
}
3、开启lighttpd的rewrite功能,方法是去掉lighttpd.conf里的mod_rewrite前面的#号,然后添加伪静态规则,例如Wordpress:
url.rewrite = (
"^/(wp-.+).*/?" => "$0",
"^/(sitemap.xml)" => "$0",
"^/(xmlrpc.php)" => "$0",
"^/(.+)/?$" => "/index.php/$1"
)
1、lighttpd与hhvm结合的稳定性还需要观察,lighttpd是一个与Apache、Nginx不同的引擎,相关的配置、伪静态规则等都会不同,不熟悉的朋友建议使用Nginx,遇到问题网上的参考文档比较多。
2、lighttpd与hhvm结合主要是利用好各自的优点:省内存与高PHP性能,至于lighttpd与hhvm和Nginx与hhvm搭配两者孰优孰劣有兴趣的朋友可以自己测试一下,最好采用网站服务器压力Web性能测试。
文章出自:Deamwork 由部落编辑整理,版权归原作者所有。本站文章除注明出处外,皆为作者原创文章,可自由引用,但请注明来源。
您或许对下面这些文章有兴趣: 本月吐槽辛苦排行榜
- Ubuntu中如何安装Lighttpd Web服务器
- CentOS 6安裝VNC、Xfce桌面、Firefox、Flashplayer教程Vagex挂机网赚
- Varnish高性能开源HTTP加速器:Varnish Nginx和Varnish Apache搭建配置
- VPS主机多人合租使用或多用户共享服务器使用方案-权限分配管理
- OneinStack一键PHP/JAVA/HHVM安装和超详细的VPS手动安装LNMP
- Debian 6用Qemu安装Windows XP、98和Wine运行Windows软件
- YZPanel免费主机管理面板安装和文件管理器eAccelerator安装使用教程
- HHVM安装使用教程-高效的PHP运行环境提升PHP性能9倍以上
-
这个。。。
[回复] -
看起来还行。
[回复] -
太深了
[回复] -
前排一下吧
[回复] -
前排哦~~~
[回复] -
后排。
[回复] -
打酱油
[回复] -
php作为fastcgi运行的?
[回复] -
打酱油 暂时用不到
[回复] -
我在搬瓦工买的64m内存也能玩的么。。。。
[回复] -
现在用不到
[回复] -
root@goodbye:~# sudo apt-get install lighttpd mysql-server hhvm
Reading package lists… Done
Building dependency tree
Reading state information… Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:The following packages have unmet dependencies:
hhvm : Depends: libboost-filesystem1.49.0 but it is not installable
Depends: libboost-program-options1.49.0 but it is not installable
Depends: libboost-system1.49.0 but it is not installable
Depends: libboost-regex1.49.0 but it is not installable
Depends: libicu48 but it is not installable
Depends: libmemcached10 but it is not installable
Depends: libmysqlclient18 but it is not installable
Depends: libp11-kit0 but it is not installable
Depends: libssl1.0.0 but it is not installable
Depends: libtinfo5 but it is not installable
Depends: libjemalloc1 (>= 3.0.0) but it is not installable
Depends: libcurl3 (>= 7.26.0) but it is not going to be installed
Depends: libboost-thread1.49.0 but it is not installable
Depends: libmagickwand5 but it is not installable
Depends: libevent-2.0-5 but it is not installable
E: Broken packagesdebian 7 安装出错,请高手帮忙看看
[回复] -
我有个搬瓦工的64M小jj,本来是作为shadowso@cks使用的,但是闲得无事,加上我想看看64m的极限在哪里,就用网上介绍的lighttpd+php+sqlite搭建了个服务器,顺便用个cf域名解析过去了,重启后看了一下内存,占用十几M,把我惊呆了,不知道是不是显示不准确,qi帮我测测能承受多少人访问呗?我测试那个网站本来是搭建在sae的,但是光是自己改代码发布文章都开始扣云豆了(我云豆只有1000来颗),还是typecho的,太受不了了,如果负载比sae强的话,我就搬了。域名是www.gongk.cf
[回复]