LNMH:高性能VPS主机环境

LNMH是基于Nginx并与HHVM相结合的架构,特点是高效率。下面是搭建过程。

HHVM官网(已被墙):http://www.hhvm.com
HHVM Github:https://github.com/facebook/hhvm

一、安装HHVM
1、centos下
rpm -ivh http://mirrors.ustc.edu.cn/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm
cd /etc/yum.repos.d
wget http://www.hop5.in/yum/el6/hop5.repo
yum clean all
yum -y remove libevent-devel libevent
yum -y install hhvm –setopt=protected_multilib=false
2、debianxia
sudo apt-get update
wget http://dl.hhvm.com/conf/hhvm.gpg.key
sudo apt-key add hhvm.gpg.key
echo “deb http://dl.hhvm.com/debian wheezy main”>> /etc/apt/sources.list
sudo apt-get update
sudo apt-get install -y hhvm

二、安装Fastcgi
sudo /usr/share/hhvm/install_fastcgi.sh #安装Fastcgi
sudo update-rc.d hhvm defaults #添加到开机启动
sudo service hhvm restart #重启HHVM

三、安装LNMP(可自由选择)
wget http://blog.linuxeye.com/lnmp.tar.gz

wget http://blog.linuxeye.com/lnmp-full.tar.gz # 包含源码(官方下载太慢)

tar xzf lnmp.tar.gz
cd lnmp

如果需要修改目录(安装、数据存储、Nginx日志),请修改options.conf文件

./install.sh
只安装Nginx和memcached。

四、修改vhost.sh文件,以让nginx添加虚拟机时自带Fastcgi。
找到(大约在314行)
[ ! -d $web_install_dir/conf/vhost ] && mkdir $web_install_dir/conf/vhost
cat > $web_install_dir/conf/vhost/$domain.conf << EOF server { listen 80; server_name $domain$moredomainame; $N_log index index.html index.htm index.jsp index.php; include $rewrite.conf; root $vhostdir; #error_page 404 /404.html; if ( $query_string ~ “.[;’&lt;&gt;].*” ){

   return 404;
   }

$anti_hotlinking
echo -e $ngx_pagespeed
location ~ .*.(php|php5)?$ {

   #fastcgi_pass remote_php_ip:9000;
   fastcgi_pass unix:/dev/shm/php-cgi.sock;
   fastcgi_index index.php;
   include fastcgi.conf;
   }

……
改为
[ ! -d $web_install_dir/conf/vhost ] &amp;&amp; mkdir $web_install_dir/conf/vhost
cat > $web_install_dir/conf/vhost/$domain.conf << EOF server { listen 80; server_name $domain$moredomainame; $N_log index index.html index.htm index.jsp index.php; include $rewrite.conf; root $vhostdir; #error_page 404 /404.html; if ( $query_string ~ “.[;’&lt;&gt;].*” ){

   return 404;
   }

$anti_hotlinking
echo -e $ngx_pagespeed
location ~ .*.(php|php5)?$ {

   fastcgi_pass 127.0.0.1:9000;
   #fastcgi_pass unix:/var/run/hhvm/hhvm.sock;
   fastcgi_index index.php;
   include fastcgi.conf;
   }

……

五、修改nginx.conf文件
找到

pureftpd AND phpmyadmin

……

   location ~ .*.(php|php5)?$ {
           #fastcgi_pass remote_php_ip:9000;
           fastcgi_pass unix:/dev/shm/php-cgi.sock;
           fastcgi_index index.php;
           include fastcgi.conf;
           }

……
改为

pureftpd AND phpmyadmin

……

   location ~ .*.(php|php5)?$ {
          fastcgi_pass 127.0.0.1:9000;
           #fastcgi_pass unix:/dev/shm/php-cgi.sock;
           fastcgi_index index.php;
           include fastcgi.conf;
           }

……

重启Nginx:
service nginx restart

六、安装mysql数据库
apt-get install mysql-server

via:deamwork

赞 (0)