东方通 TongHttpServer V6 配置与启动实战指南
文章目录
- 东方通 TongHttpServer V6 配置与启动实战指南
- 一 简述
- 二 THS 配置
- 1)配置负载均衡请求
- 2)配置前端网页请求
- 3)配置后端反向代理
- 4)完整的 httpserver.conf
- 三 配置开机启动
- 1)修改 rc.local 权限
- 2)编辑 rc.local 文件
- 四 启动服务
- 五 停止服务
本文详细介绍了如何在国产信创环境中,配置和启动东方通 TongHttpServer V6(THS)。THS 是一款高性能、轻量级的 HTTP 服务器,专为高并发请求设计,并兼容 Nginx。本文首先概述了 THS 的配置文件
httpserver.conf
的设置,包括负载均衡、前端页面请求和后端反向代理等。接着,展示了如何通过编辑
rc.local
实现 THS 的开机自动启动。最后,文章介绍了服务的启动与停止命令,确保 THS 在服务器上高效运行,适用于需要部署高性能 Web 服务器的开发人员与运维人员参考。
预备课:
Docker 安装与配置:从入门到部署
Docker 环境下安装和配置 Nginx 实践
一 简述
TongHttpServer V6 是一款高性能、轻量级的 HTTP 服务器,专为处理大规模并发请求设计,支持多线程和异步处理。它与 Nginx 等服务器兼容,提供易于配置和扩展的功能,适用于各种 Web 应用程序。V6 版本在性能和稳定性上进行了进一步优化,适合高流量环境下的高效部署。当前测试环境:
操作系统 | CPU 架构 |
---|---|
麒麟 V10 | c86 |
二 THS 配置
THS 的配置参数与 Nginx 兼容,可直接复用。只需修改 httpserver.conf
文件,示例如下:
1)配置负载均衡请求
upstream yourbackend {server localhost:8080;
}
2)配置前端网页请求
# 前端页面location /html-your {alias /home/yourpath/THS/html-your;index index.html index.htm;try_files $uri /html-your/index.html;}
3)配置后端反向代理
# 后端服务location /yourproj/ {proxy_set_header Host $http_host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header REMOTE-HOST $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_pass http://yourbackend/yourproj/;}
4)完整的 httpserver.conf
#user nobody;
worker_processes 4;#error_log logs/error.log;
#error_log logs/error.log notice;
error_log logs/error.log error;pid logs/httpserver.pid;events {worker_connections 1024;use epoll;
}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;status_zone;sendfile on;#tcp_nopush on;#keepalive_timeout 0;keepalive_timeout 60;#gzip on;client_max_body_size 15m;upstream yourbackend {server localhost:8080;} server {listen 8080;server_name localhost;proxy_buffering off;proxy_cache off;#charset koi8-r;access_log logs/host.access.log main;# location / {# root html;# index index.html index.htm;# }# 前端页面location /html-your {alias /home/yourpath/THS/html-your;index index.html index.htm;try_files $uri /html-your/index.html;}# 后端服务location /yourproj/ {proxy_set_header Host $http_host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header REMOTE-HOST $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_pass http://yourbackend/yourproj/;}#server statuslocation /api {access_log off;api write=off;status_bypass on;allow 127.0.0.1;deny all;}#error_page 404 /404.html;# redirect server error pages to the static page /50x.htmlerror_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;#}# deny access to .htaccess files, if Apache's document root# concurs with httpserver's one##location ~ /\.ht {# deny all;#}}# HTTPS server#server {#listen 443 ssl;#server_name localhost;#ssl_protocols TLSv1.2 TLSv1.3 GMTLSv1.1;#GMTLS key#ssl_certificate crt/SS.pem;#ssl_certificate_key crt/SS.key.pem;#ssl_certificate crt/SE.pem;#ssl_certificate_key crt/SE.key.pem;#https key#ssl_certificate crt/common_cert/server.crt;#ssl_certificate_key crt/common_cert/server.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;#}#}}
三 配置开机启动
设置 THS 开机自动启动,可以通过配置系统服务或任务计划来实现,确保服务器在系统启动时自动运行。
1)修改 rc.local 权限
# 查看文档信息$ cat /etc/rc.d/rc.local # 修改文件为执行权限$ chmod +x /etc/rc.d/rc.local
2)编辑 rc.local 文件
# 编辑 rc.local$ sudo vim /etc/rc.d/rc.local
增加
nohup /home/yourpath/THS/bin/start.sh > /home/yourpath/logs/THS.log 2>&1 &
也可以简单编辑为
/home/yourpath/THS/bin/start.sh
四 启动服务
# 启动服务
$ ./start.sh start
五 停止服务
# 停止服务
$ ./start.sh stop
注:执行启停服务的目录为 /home/yourpath/THS
。