站点刚更新,有问题请联系QQ 2535458415

CentOS7.3 64位安装 Tengine

编程 王苗森 2990℃ 0评论

CentOS7.3 64位安装 Tengine

  1. 安装yum 源(依赖的)
    yum install gcc gcc-c++ autoconf automake unzip bzip2 -y
  2. 安装pcre
    cd /usr/src
    地址:https://ftp.pcre.org/pub/pcre/
    不要下载pcre2,下载pcre最新版本
wget https://ftp.pcre.org/pub/pcre/pcre-8.44.zip
unzip pcre-8.44.zip
cd pcre-8.44
./configure --prefix=/usr
make && make install
  1. 安装openssl
    cd /usr/src
    地址:http://www.openssl.org/source/
wget https://www.openssl.org/source/openssl-1.1.1d.tar.gz
tar zxvf openssl-1.1.1d.tar.gz
cd openssl-1.1.1d
./config --prefix=/usr
make && make install
  1. 安装zlib
    cd /usr/src
    地址:http://www.zlib.net/
wget http://www.zlib.net/zlib-1.2.11.tar.gz
tar zxvf zlib-1.2.11.tar.gz
cd zlib-1.2.11
./configure --prefix=/usr
make && make install
  1. 安装jemalloc
    地址:https://github.com/jemalloc/jemalloc/releases
cd /usr/src
wget https://github.com/jemalloc/jemalloc/releases/download/5.2.1/jemalloc-5.2.1.tar.bz2
tar jxvf jemalloc-5.2.1.tar.bz2
cd jemalloc-5.2.1
./configure --prefix=/usr
make && make install
  1. 安装Tengine
    地址:http://tengine.taobao.org/download.html
cd /usr/src
wget http://tengine.taobao.org/download/tengine-2.3.2.tar.gz
tar zxvf tengine-2.3.2.tar.gz
cd tengine-2.3.2
./configure --prefix=/usr/nginx \
--user=www \
--group=www \
--with-pcre=/usr/src/pcre-8.44 \
--with-openssl=/usr/src/openssl-1.1.1d \
--with-jemalloc=/usr/src/jemalloc-5.2.1 \
--with-zlib=/usr/src/zlib-1.2.11 \
--with-http_gzip_static_module \
--with-http_realip_module \
--with-http_stub_status_module \
--with-http_v2_module \
--with-http_ssl_module \
--with-http_realip_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-pcre-jit \
--add-module=/usr/src/tengine-2.3.2/modules/ngx_http_trim_filter_module \
--add-module=/usr/src/tengine-2.3.2/modules/ngx_http_concat_module
make && make install
  1. 配置Tengine
    • 添加为服务,并开机启动
      vi /lib/systemd/system/nginx.service
[Unit]
Description=The nginx HTTP and reverse proxy server
After=syslog.target network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
PIDFile=/usr/nginx/logs/nginx.pid
ExecStartPre=/usr/nginx/sbin/nginx -t
ExecStart=/usr/nginx/sbin/nginx -c /usr/nginx/conf/nginx.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target
`chmod 745 nginx.service`
开机启动 `systemctl enable nginx.service`
启动命令:systemctl start nginx.service
停止命令:systemctl stop nginx.service
重启命令:systemctl restart nginx.service
- 配置文件
`mkdir /usr/nginx/conf/vhosts`

vi /usr/nginx/conf/nginx.conf

user  tengine tengine;
worker_processes  auto;

error_log  logs/error.log  error;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;
#error_log  "pipe:rollback logs/error_log interval=1d baknum=7 maxsize=2G";

pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;
    trim on;
    trim_js on;
    trim_css on;
    gzip on;
    gzip_min_length  1k;
    gzip_buffers     4 16k;
    gzip_http_version 1.1;
    gzip_comp_level 9;
    gzip_types       text/plain application/x-javascript text/css application/xml text/javascript application/x-httpd-php application/javascript application/json;
    gzip_disable  "MSIE [1-6]\.";
    gzip_vary  on;


    #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  "pipe:rollback logs/access_log interval=1d baknum=7 maxsize=2G"  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  600;
    fastcgi_connect_timeout  600;
    fastcgi_send_timeout 600;
    fastcgi_read_timeout 600;
    #gzip  on;

    server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;
        #access_log  "pipe:rollback logs/host.access_log interval=1d baknum=7 maxsize=2G"  main;

        location / {
            root   html;
            index  index.html index.htm;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

        # pass the Dubbo rpc to Dubbo provider server listening on 127.0.0.1:20880
        #
        #location /dubbo {
        #    dubbo_pass_all_headers on;
        #    dubbo_pass_set args $args;
        #    dubbo_pass_set uri $uri;
        #    dubbo_pass_set method $request_method;
        #
        #    dubbo_pass org.apache.dubbo.samples.tengine.DemoService 0.0.0 tengineDubbo dubbo_backend;
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }

    # upstream for Dubbo rpc to Dubbo provider server listening on 127.0.0.1:20880
    #
    #upstream dubbo_backend {
    #    multi 1;
    #    server 127.0.0.1:20880;
    #}

    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    #server {
    #    listen       443 ssl;
    #    server_name  localhost;

    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;

    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}
    include vhosts/*.conf;
}

以配置wordpress为例
vi /usr/nginx/conf/vhosts/medblog.conf

server {
  listen 80;
  server_name www.medblog.cn;
  error_page   500 502 503 504  /50x.html;
  location = /50x.html {
        root   /usr/local/nginx/html;
    }
  location ~ \.php$ {
    root  /data/tengine/medblog;
    try_files $uri $uri/ 404;
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
  }
  location / {
    root  /data/tengine/medblog;
    index  index.php;
    try_files $uri $uri/ /index.php?$args;
  }
}

重启Tengine service nginx restart

转载请注明:医学园地 » CentOS7.3 64位安装 Tengine

喜欢 (0)

您必须 登录 才能发表评论!