使用HTTP::Server::Encryp模块快速搭建http server

1. 闲言少述,先上代码,搭建Http server

#!/usr/bin perl
#############################################################################
# \File
#    HTTPServer.pl
# \Brief
#    Setting the http server
# \Author
#    Hank
#############################################################################


use HTTP::Server::Encrypt qw(http_server_start);

my %http_conf;
$http_conf{'port'} = 80;
#$http_conf{'username'} = 'username';
#$http_conf{'passwd'} = 'passwd';
$http_conf{'min_spare'} = 2;
$http_conf{'max_spare'} = 6;
$http_conf{'static_expires_secs'} = 0;
$http_conf{'docroot'}   = 'plugins/';
$http_conf{'log_dir'}   = '/opt/httpserverlog';

http_server_start(\%http_conf);


2. 具体的参数详解可见CPAN上的解释
https://metacpan.org/module/HTTP::Server::Encrypt


3. 后台方式启动和停止
代码如下:
File: start_httpserver.sh
perl HTTPServerDaemon.pl

File: stop_httserver.sh
cat HTTPServerDaemon.pl.pid | xargs kill


启动与停止:
$ ./ start_httpserver.sh
$ ./ stop_httpserver.sh

你可能感兴趣的:(使用HTTP::Server::Encryp模块快速搭建http server)