热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

在服务器搭建Tengine+HHVM环境运行WordPress

系统环境阿里云1核+512M内存Ubuntu12.0464位Wordpress3.9修改系统软件源参考mirrors.aliyun.comhelpubuntudebmirrors.aliyun.comubuntuprecisemainrestricteduniversemultiversedebmirrors.aliyun.comubuntupr

系统环境 阿里云1核+512M内存 Ubuntu 12.04 64位 Wordpress 3.9 修改系统软件源 参考http://mirrors.aliyun.com/help/ubuntu deb http://mirrors.aliyun.com/ubuntu/ precise main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ pr

系统环境

阿里云1核+512M内存 Ubuntu 12.04 64位
Wordpress 3.9

修改系统软件源

参考http://mirrors.aliyun.com/help/ubuntu

  deb http://mirrors.aliyun.com/ubuntu/ precise main restricted universe multiverse
  deb http://mirrors.aliyun.com/ubuntu/ precise-security main restricted universe multiverse
  deb http://mirrors.aliyun.com/ubuntu/ precise-updates main restricted universe multiverse
  deb http://mirrors.aliyun.com/ubuntu/ precise-proposed main restricted universe multiverse
  deb http://mirrors.aliyun.com/ubuntu/ precise-backports main restricted universe multiverse
  deb-src http://mirrors.aliyun.com/ubuntu/ precise main restricted universe multiverse
  deb-src http://mirrors.aliyun.com/ubuntu/ precise-security main restricted universe multiverse
  deb-src http://mirrors.aliyun.com/ubuntu/ precise-updates main restricted universe multiverse
  deb-src http://mirrors.aliyun.com/ubuntu/ precise-proposed main restricted universe multiverse
  deb-src http://mirrors.aliyun.com/ubuntu/ precise-backports main restricted universe multiverse

若使用阿里云服务器,将源的域名从mirrors.aliyun.com改为mirrors.aliyuncs.com,不占用公网流量,而且下载速度更快。

更新系统软件

   sudo apt-get update && sudo apt-get upgrade

安装Tengine

1、安装依赖软件

  apt-get --install-suggests install gcc g++ make 

2、下载相关软件

wget http://jaist.dl.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.gz
wget http://zlib.net/zlib-1.2.8.tar.gz
wget http://www.openssl.org/source/openssl-1.0.1g.tar.gz
wget http://www.canonware.com/download/jemalloc/jemalloc-3.6.0.tar.bz2
wget http://tengine.taobao.org/download/tengine-2.0.2.tar.gz

3、安装Pcre

  tar zxvf pcre-8.35.tar.gz
  cd pcre-8.35
 ./configure --prefix=/usr/local/pcre-8.35
  make && make install

4、安装Zlib

  cd ..
  tar zxvf zlib-1.2.8.tar.gz
  cd zlib-1.2.8
  ./configure --prefix=/usr/local/zlib-1.2.8
  make && make install

5、安装OpenSSl

  cd ..
  tar zxvf openssl-1.0.1g.tar.gz
  cd openssl-1.0.1g
  ./config --prefix=/usr/local/openssl-1.0.1g
  make && make install

6、解压jemalloc不需要安装

  cd .. && tar jxvf jemalloc-3.6.0.tar.bz2

7、安装Tengine

  ./configure --prefix=/usr/local/nginx \
--user=www-data \
--group=www-data \
--with-pcre=/usr/local/src/pcre-8.35 \
--with-zlib=/usr/local/src/zlib-1.2.8 \
--with-openssl=/usr/local/src/openssl-1.0.1g \
--with-jemalloc=/usr/local/src/jemalloc-3.6.0 \
--with-http_gzip_static_module \
--with-http_realip_module \
--with-http_stub_status_module \
--with-http_concat_module 
make && make install

安装HHVM

其他系统参考https://github.com/facebook/hhvm/wiki

echo '140.211.166.134  dl.hhvm.com' >> /etc/hosts
sudo apt-get install software-properties-common python-software-properties
sudo add-apt-repository ppa:mapnik/boost
wget -O - http://dl.hhvm.com/conf/hhvm.gpg.key | sudo apt-key add - 
echo deb http://dl.hhvm.com/ubuntu precise main | sudo tee /etc/apt/sources.list.d/hhvm.list
sudo apt-get update
sudo apt-get install hhvm
  server hhvm start  # 启动HHVM

如果想使用UNIX socket的方式启动HHVM,需要修改/etc/hhvm/server.ini

  ; php options
  pid = /var/run/hhvm/pid
  ; hhvm specific 
  ;hhvm.server.port = 9000
  hhvm.server.type = fastcgi
  hhvm.server.file_socket = /var/run/hhvm/hhvm.sock
  hhvm.server.default_document = index.php
  hhvm.log.level = Error
  hhvm.log.always_log_unhandled_exceptiOns= true
  hhvm.log.runtime_error_reporting_level = 8191
  hhvm.log.use_log_file = true
  hhvm.log.file = /var/log/hhvm/error.log
  hhvm.repo.central.path = /var/run/hhvm/hhvm.hhbc
  hhvm.mysql.typed_results = false

配置nginx.conf,

  #user  nobody;
worker_processes  auto;
worker_rlimit_nofile 100000; 
#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;
#pid        logs/nginx.pid;
events {
    worker_connections  65535;
    use epoll; 
    multi_accept on; 
}
# load modules compiled as Dynamic Shared Object (DSO)
#
#dso {
#    load ngx_http_fastcgi_module.so;
#    load ngx_http_rewrite_module.so;
#}
http {
    include       mime.types;
    default_type  application/octet-stream;
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';
    #access_log  logs/access.log  main;
    access_log off;
    upstream hhvm {
        server unix:/var/run/hhvm/hhvm.sock;
        #server 127.0.0.1:9000;
    }
    server_tokens off; 
    sendfile        on;
    tcp_nopush     on;
    keepalive_timeout  65;
    server_names_hash_bucket_size 128;
    client_header_buffer_size 32k;
    large_client_header_buffers 4 32k;
    client_max_body_size 20m;
    open_file_cache          max=10000 inactive=5m;
    open_file_cache_valid    2m;
    open_file_cache_min_uses 1;
    open_file_cache_errors   on;
    #gzip  on;
    include gzip.conf;
    #vhost
    include vhost_liuzhichao.com;
}

vim /etc/nginx/conf/gzip.conf

    gzip  on;
    gzip_proxied any;
    gzip_types text/css;
    gzip_types text/csv;
    gzip_types text/plain;
    gzip_types text/Javascript;
    gzip_types application/Javascript;
    gzip_types application/json;
    gzip_types application/x-Javascript;
    gzip_types application/ecmascript;
    gzip_types application/xml;
    gzip_types application/xml+rss;
    gzip_types application/rss+xml;
    gzip_types application/atom_xml;
    gzip_types application/xhtml+xml;
    gzip_types application/x-font-ttf;
    gzip_types application/x-font-opentype;
    gzip_types application/vnd.ms-fontobject;
    gzip_types image/svg+xml;
    gzip_types image/x-icon;
    gzip_types text/xml;
    gzip_comp_level 3;
    gzip_http_version 1.1;
    gzip_vary on;
    gzip_disable "MSIE [1-6]\.(?!.*SV1)";
    gzip_buffers 16 8k;
    gzip_min_length 20;

vim vhost_liuzhichao.com

  server{
        listen 80;
        server_name liuzhichao.com www.liuzhichao.com;
        root /var/www/liuzhichao.com;
        index index.html index.htm index.php;
        charset utf-8;
        #access_log /var/log/nginx/liuzhichao.com-access.log main;
        access_log /dev/null;
        error_log  /var/log/nginx/liuzhichao.com/error.log error;
        location / { 
           try_files $uri $uri/ /index.php$is_args$args;
        } 
        location ~ /wp-content/uploads/.*\.(php|php5)?$ {
                deny all;
        }
        location = /favicon.ico {
                log_not_found off;
                access_log off;
                expires max;
        }
        location = /robots.txt {
                allow all;
                log_not_found off;
                access_log off;
        }
        #Browser Cache Control Directives
        #Prevent (deny) Access to Hidden Files with Nginx
        location ~ /\. {
                access_log off;
                log_not_found off;
        }
        # Cache static files for as long as possible
        location ~* .(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|css|rss|atom|js|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
                expires max; log_not_found off; access_log off;
        }
        #The HHVM Magic Here       
        location ~ \.(hh|php)$ {
                fastcgi_keep_conn on;
                try_files $uri = 404;
                fastcgi_index index.php;
                fastcgi_split_path_info ^(.+.php)(/.+)$;
                include fastcgi_params;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_pass hhvm;
        }

从目前的试用情况来看,查看阿里云监控,CPU占用率相对之前nginx+php-fpm架构低了不只是一点点,内存使用率也比较平稳.只是在上传文件或是更新插件时,经常会导致HHVM进程终止,然后网站出现502错误。不知道是不是因为上面的配置问题。

?

推荐阅读
  • Java验证码——kaptcha的使用配置及样式
    本文介绍了如何使用kaptcha库来实现Java验证码的配置和样式设置,包括pom.xml的依赖配置和web.xml中servlet的配置。 ... [详细]
  • iOS超签签名服务器搭建及其优劣势
    本文介绍了搭建iOS超签签名服务器的原因和优势,包括不掉签、用户可以直接安装不需要信任、体验好等。同时也提到了超签的劣势,即一个证书只能安装100个,成本较高。文章还详细介绍了超签的实现原理,包括用户请求服务器安装mobileconfig文件、服务器调用苹果接口添加udid等步骤。最后,还提到了生成mobileconfig文件和导出AppleWorldwideDeveloperRelationsCertificationAuthority证书的方法。 ... [详细]
  • React 小白初入门
    推荐学习:React官方文档:https:react.docschina.orgReact菜鸟教程:https:www.runoob.c ... [详细]
  • 都说Python处理速度慢,为何月活7亿的 Instagram依然在使用Python?
    点击“Python编程与实战”,选择“置顶公众号”第一时间获取Python技术干货!来自|简书作者|我爱学python链接|https:www.jian ... [详细]
  • 如何实现织梦DedeCms全站伪静态
    本文介绍了如何通过修改织梦DedeCms源代码来实现全站伪静态,以提高管理和SEO效果。全站伪静态可以避免重复URL的问题,同时通过使用mod_rewrite伪静态模块和.htaccess正则表达式,可以更好地适应搜索引擎的需求。文章还提到了一些相关的技术和工具,如Ubuntu、qt编程、tomcat端口、爬虫、php request根目录等。 ... [详细]
  • 阿里Treebased Deep Match(TDM) 学习笔记及技术发展回顾
    本文介绍了阿里Treebased Deep Match(TDM)的学习笔记,同时回顾了工业界技术发展的几代演进。从基于统计的启发式规则方法到基于内积模型的向量检索方法,再到引入复杂深度学习模型的下一代匹配技术。文章详细解释了基于统计的启发式规则方法和基于内积模型的向量检索方法的原理和应用,并介绍了TDM的背景和优势。最后,文章提到了向量距离和基于向量聚类的索引结构对于加速匹配效率的作用。本文对于理解TDM的学习过程和了解匹配技术的发展具有重要意义。 ... [详细]
  • 本文介绍了在开发Android新闻App时,搭建本地服务器的步骤。通过使用XAMPP软件,可以一键式搭建起开发环境,包括Apache、MySQL、PHP、PERL。在本地服务器上新建数据库和表,并设置相应的属性。最后,给出了创建new表的SQL语句。这个教程适合初学者参考。 ... [详细]
  • 这是原文链接:sendingformdata许多情况下,我们使用表单发送数据到服务器。服务器处理数据并返回响应给用户。这看起来很简单,但是 ... [详细]
  • 本文介绍了使用AJAX的POST请求实现数据修改功能的方法。通过ajax-post技术,可以实现在输入某个id后,通过ajax技术调用post.jsp修改具有该id记录的姓名的值。文章还提到了AJAX的概念和作用,以及使用async参数和open()方法的注意事项。同时强调了不推荐使用async=false的情况,并解释了JavaScript等待服务器响应的机制。 ... [详细]
  • 目录实现效果:实现环境实现方法一:基本思路主要代码JavaScript代码总结方法二主要代码总结方法三基本思路主要代码JavaScriptHTML总结实 ... [详细]
  • Centos7.6安装Gitlab教程及注意事项
    本文介绍了在Centos7.6系统下安装Gitlab的详细教程,并提供了一些注意事项。教程包括查看系统版本、安装必要的软件包、配置防火墙等步骤。同时,还强调了使用阿里云服务器时的特殊配置需求,以及建议至少4GB的可用RAM来运行GitLab。 ... [详细]
  • 禁止程序接收鼠标事件的工具_VNC Viewer for Mac(远程桌面工具)免费版
    VNCViewerforMac是一款运行在Mac平台上的远程桌面工具,vncviewermac版可以帮助您使用Mac的键盘和鼠标来控制远程计算机,操作简 ... [详细]
  • Imdevelopinganappwhichneedstogetmusicfilebystreamingforplayinglive.我正在开发一个应用程序,需要通过流 ... [详细]
  • JavaScript和Python是用于构建各种应用程序的两种有影响力的编程语言。尽管JavaScript多年来一直是占主导地位的编程语言,但Python的迅猛发展有 ... [详细]
  • Word2vec,Fasttext,Glove,Elmo,Bert,Flairpre-trainWordEmbedding源码数据Github网址:词向量预训练实现Githubf ... [详细]
author-avatar
绿香源酥脆冬枣
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有