検索
ホームページphp教程php手册在服务器搭建Tengine+HHVM环境运行WordPress

系统环境 阿里云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错误。不知道是不是因为上面的配置问题。

?

声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。
如何在 RHEL 9 上配置 DHCP 服务器如何在 RHEL 9 上配置 DHCP 服务器Jun 08, 2023 pm 07:02 PM

DHCP是“动态主机配置协议DynamicHostConfigurationProtocol”的首字母缩写词,它是一种网络协议,可自动为计算机网络中的客户端系统分配IP地址。它从DHCP池或在其配置中指定的IP地址范围分配客户端。虽然你可以手动为客户端系统分配静态IP,但DHCP服务器简化了这一过程,并为网络上的客户端系统动态分配IP地址。在本文中,我们将演示如何在RHEL9/RockyLinux9上安装和配置DHCP服务器。先决条件预装RHEL9或RockyLinux9具有sudo管理权限的普

在容器中怎么使用nginx搭建上传下载的文件服务器在容器中怎么使用nginx搭建上传下载的文件服务器May 15, 2023 pm 11:49 PM

一、安装nginx容器为了让nginx支持文件上传,需要下载并运行带有nginx-upload-module模块的容器:sudopodmanpulldocker.io/dimka2014/nginx-upload-with-progress-modules:latestsudopodman-d--namenginx-p83:80docker.io/dimka2014/nginx-upload-with-progress-modules该容器同时带有nginx-upload-module模块和ng

vue3项目打包发布到服务器后访问页面显示空白怎么解决vue3项目打包发布到服务器后访问页面显示空白怎么解决May 17, 2023 am 08:19 AM

vue3项目打包发布到服务器后访问页面显示空白1、处理vue.config.js文件中的publicPath处理如下:const{defineConfig}=require('@vue/cli-service')module.exports=defineConfig({publicPath:process.env.NODE_ENV==='production'?'./':'/&

服务器怎么使用Nginx部署Springboot项目服务器怎么使用Nginx部署Springboot项目May 14, 2023 pm 01:55 PM

1,将java项目打成jar包这里我用到的是maven工具这里有两个项目,打包完成后一个为demo.jar,另一个为jst.jar2.准备工具1.服务器2.域名(注:经过备案)3.xshell用于连接服务器4.winscp(注:视图工具,用于传输jar)3.将jar包传入服务器直接拖动即可3.使用xshell运行jar包注:(服务器的java环境以及maven环境,各位请自行配置,这里不做描述。)cd到jar包路径下执行:nohupjava-jardemo.jar>temp.txt&

python中怎么使用TCP实现对话客户端和服务器python中怎么使用TCP实现对话客户端和服务器May 17, 2023 pm 03:40 PM

TCP客户端一个使用TCP协议实现可连续对话的客户端示例代码:importsocket#客户端配置HOST='localhost'PORT=12345#创建TCP套接字并连接服务器client_socket=socket.socket(socket.AF_INET,socket.SOCK_STREAM)client_socket.connect((HOST,PORT))whileTrue:#获取用户输入message=input("请输入要发送的消息:&

Linux怎么在两个服务器直接传文件Linux怎么在两个服务器直接传文件May 14, 2023 am 09:46 AM

scp是securecopy的简写,是linux系统下基于ssh登陆进行安全的远程文件拷贝命令。scp是加密的,rcp是不加密的,scp是rcp的加强版。因为scp传输是加密的,可能会稍微影响一下速度。另外,scp还非常不占资源,不会提高多少系统负荷,在这一点上,rsync就远远不及它了。虽然rsync比scp会快一点,但当小文件众多的情况下,rsync会导致硬盘I/O非常高,而scp基本不影响系统正常使用。场景:假设我现在有两台服务器(这里的公网ip和内网ip相互传都可以,当然用内网ip相互传

如何使用psutil模块获取服务器的CPU、内存和磁盘使用率?如何使用psutil模块获取服务器的CPU、内存和磁盘使用率?May 07, 2023 pm 10:28 PM

psutil是一个跨平台的Python库,它允许你获取有关系统进程和系统资源使用情况的信息。它支持Windows、Linux、OSX、FreeBSD、OpenBSD和NetBSD等操作系统,并提供了一些非常有用的功能,如:获取系统CPU使用率、内存使用率、磁盘使用率等信息。获取进程列表、进程状态、进程CPU使用率、进程内存使用率、进程IO信息等。杀死进程、发送信号给进程、挂起进程、恢复进程等操作。使用psutil,可以很方便地监控系统的运行状况,诊断问题和优化性能。以下是一个简单的示例,演示如何

怎么在同一台服务器上安装多个MySQL怎么在同一台服务器上安装多个MySQLMay 29, 2023 pm 12:10 PM

一、安装前的准备工作在进行MySQL多实例的安装前,需要进行以下准备工作:准备多个MySQL的安装包,可以从MySQL官网下载适合自己环境的版本进行下载:https://dev.mysql.com/downloads/准备多个MySQL数据目录,可以通过创建不同的目录来支持不同的MySQL实例,例如:/data/mysql1、/data/mysql2等。针对每个MySQL实例,配置一个独立的MySQL用户,该用户拥有对应的MySQL安装路径和数据目录的权限。二、基于二进制包安装多个MySQL实例

See all articles

ホットAIツール

Undresser.AI Undress

Undresser.AI Undress

リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover

AI Clothes Remover

写真から衣服を削除するオンライン AI ツール。

Undress AI Tool

Undress AI Tool

脱衣画像を無料で

Clothoff.io

Clothoff.io

AI衣類リムーバー

AI Hentai Generator

AI Hentai Generator

AIヘンタイを無料で生成します。

ホットツール

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

強力な PHP 統合開発環境

EditPlus 中国語クラック版

EditPlus 中国語クラック版

サイズが小さく、構文の強調表示、コード プロンプト機能はサポートされていません

MantisBT

MantisBT

Mantis は、製品の欠陥追跡を支援するために設計された、導入が簡単な Web ベースの欠陥追跡ツールです。 PHP、MySQL、Web サーバーが必要です。デモおよびホスティング サービスをチェックしてください。

SublimeText3 Linux 新バージョン

SublimeText3 Linux 新バージョン

SublimeText3 Linux 最新バージョン

mPDF

mPDF

mPDF は、UTF-8 でエンコードされた HTML から PDF ファイルを生成できる PHP ライブラリです。オリジナルの作者である Ian Back は、Web サイトから「オンザフライ」で PDF ファイルを出力し、さまざまな言語を処理するために mPDF を作成しました。 HTML2FPDF などのオリジナルのスクリプトよりも遅く、Unicode フォントを使用すると生成されるファイルが大きくなりますが、CSS スタイルなどをサポートし、多くの機能強化が施されています。 RTL (アラビア語とヘブライ語) や CJK (中国語、日本語、韓国語) を含むほぼすべての言語をサポートします。ネストされたブロックレベル要素 (P、DIV など) をサポートします。