一、安装启动停止及热加载
1、安装
tar xf TongHttpServer_6.0.0.2_x86_64.tar.gz -C /usr/local/TongHttpServer #绿色版解压即可使用
#此程序的运行需要license.dat文件,将此文件放入THS目录中或者与THS平级目录即可
2、启动
[root@localhost THS]# /usr/local/TongHttpServer/THS/bin/start.sh #启动主程序
[root@localhost bin]# ./startConsole.sh #启动web管理界面
[root@localhost bin]# cat /usr/local/TongHttpServer/THS/conf/user.json #用户密码存放文件地址
[root@localhost bin]# ./startHA.sh #启动高可用服务
3、停止
[root@localhost THS]# ./bin/start.sh stop #停止主程序
httpserver stop success
[root@localhost bin]# ./startConsole.sh stop #停止管理界面
2024-04-14 22:35:55.974 INFO 12903 --- [ionShutdownHook] o.s.beans.factory.DisposableBean : console exit!
thsconsole-6.0.0.2.jar stop success
[root@localhost bin]# ./startHA.sh stop #停止高可用
httpserverHA stop success!
4、查看信息
[root@localhost THS]# /usr/local/TongHttpServer/THS/bin/start.sh -l #查看主要信息
------------------------------------------------
------------------License Info------------------
consumerName:DFT
projectName:测试
productName:TongHttpServer
type:trial
versionNumber:6.0
expires:2024-07-12
------------------License Info------------------
------------------------------------------------
[root@localhost THS]# /usr/local/TongHttpServer/THS/bin/start.sh -L #查看详细信息
------------------------------------------------
------------------License Info------------------
consumer_name=DFT
project_name=²㋔
license_id=85245
license_type=trial
create_date=2024-04-12
end_date=2024-07-12
THS_Product_Name=TongHttpServer
THS_Version_Number=6.0
bindip=
TW_Hardware_Id=
TW_Max_Number=-1
THS_Admin_Console=1
THS_Edition=Standard
------------------License Info------------------
------------------------------------------------
5、热加载和重启
[root@localhost THS]# ./bin/start.sh restart #重启
httpserver is running
[root@localhost THS]# ./bin/start.sh reload #热加载
httpserver reload success
二、配置文件
1、主配置文件
[root@localhost THS]# vim conf/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;
server {
listen 8080;
server_name localhost;
#charset koi8-r;
access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
}
#server status
location /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.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;
#}
# 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;
#}
#}
}
2、作用域
主程序配置文件根据逻辑意义不同,分成不同的作用域,不同作用域含有不同的配置项,main 作用域无大括号,其他作用域都由作用域名加大括号标识,配置可以在多个作用域中有效,如 access_log 在 http、server、location 作用域都有效。
main:与具体业务无关的配置,如进程数、运行用户,错误日志等,为配置文件中块外配置。
http:HTTP 服务相关的配置参数,如 gzip、keepalive、access_log 等。
stream:TCP、UDP 相关配置参数。
server:http、stream、mail 支持多个虚拟主机,每个虚拟主机对应一个 server 配置项。
upstream:http、stream 负载均衡集群相关配置。
location:http 服务中,特定的 URL 对应的配置项。
mail:email 相关配置项
3、基本使用
使用include将nginx配置平移过来即可