欢迎来到电脑知识学习网,专业的电脑知识大全学习平台!

手机版

在CentOS系统中编译安装Hiawatha服务器的教程

操作系统 发布时间:2019-03-14 16:53:40

Hiawatha 是一个Linux/UNIX下安全的Web服务器,其设计的最主要的目的就是安全,当然它也是快速的而且易于配置。在安装之后,确实发现他真的是轻量级的,安装部署相当的快。以下是安装的过程:

第一步:下载编译安装cmake因为Hiawatha要求是cmake才能编译,我的系统里没有安装,但是注意,这里的cmake是有版本要求的,至少是2.8.4以上的版本,索性我就安装了最新的版本cmake 2.8.10.

   

复制代码
代码如下:
#wgethttp://www.cmake.org/files/v2.8/cmake-2.8.10.2.tar.gz</p> <p> #tar xvf cmake-2.8.10.2.tar.gz</p> <p> #cd cmake-2.8.10.2

 

本机上不存在cmake。则

   

复制代码
代码如下:
#./bootstrap</p> <p> #make</p> <p> #make install

 

    如果系统中已经装了低版本的cmake,输入如下命令:

   

复制代码
代码如下:
#cmake</p> <p> #make</p> <p> #make install

 

第二步:下载Hiawatha(libxml2 and libxslt是hiavatha必须要求的,没有的自行安装,我已经有了)

 

复制代码
代码如下:
#wget --no-check-certificate https://www.hiawatha-webserver.org/files/hiawatha-9.0.tar.gz //wget

 

可以下载http,https,ftp的链接,这里是https,所以我们设置为不检查证书,直接下载,参考wget下载https链接(转)

 

复制代码
代码如下:
#tar -xzf hiawatha-9.0.tar.gz</p> <p>#cd hiawatha-9.0</p> <p>#mkdir build</p> <p>#cd build</p> <p>#cmake .. -DENABLE_CACHE=ON -DENABLE_DEBUG=off -DENABLE_IPV6=off -DENABLE_MONITOR=off -DENABLE_RPROXY=ON -DENABLE_SSL=ON -DENABLE_TOMAHAWK=off -DENABLE_TOOLKIT=ON -DENABLE_XSLT=off</p> <p>#make</p> <p>#make install</p> <p>#hiawatha -k //检测安装是否成功,如果输出以下提示,则表示安装成功</p> <p>Using
Reading hiawatha.conf
Configuration OK

 

注意:运行cmake时候如果出现

 

复制代码
代码如下:
CMake Error: Could not find CMAKE_ROOT !!!
CMake has most likely not been installed correctly.
Modules directory not found in
/usr/bin
CMake Error: Error executing cmake::LoadCache(). Aborting.

 

的错误提示,很大的可能不是你的cmake的设置有问题,输入“echo $CMAKE_ROOT”,看返回时什么,如果没有返回,或返回的不是你的cmake安装的目录,那么就肯定会出现这个错误,因为找不到 CMAKE_ROOT 这个变量值, 那我们就可以输入以下命令,告诉系统,cmake的安装目录是哪里,

 

复制代码
代码如下:
#export CMAKE_ROOT=/usr/local/bin/cmake

 

这个根据自身的安装路径设定,就可以解决这个错误了

有的可能在编译的时候还出现下面的错误:

 

复制代码
代码如下:
bash: /usr/bin/cmake: No such file or directory</p> <p>方法:这也是系统找不到cmake在哪,所以我们一样要告诉系统


复制代码
代码如下:
#ln -s /usr/local/bin/cmake /usr/bin //做一个软连接

如果上面都没生效,你又记者用cmake编译,最快的方法是用find命令,查看cmake的可执行文件在哪里,然后直接用cmake可执行文件的绝对路径来编译
如:
复制代码
代码如下:
find / -name "cmake"

显示结果:
复制代码
代码如下:
/usr/local/bin/cmake

那么,你可以这样编译:

复制代码
代码如下:
/usr/local/bin/cmake
  后面加上你要编译和源代码路径和编译的参数
第三步:修改配置文件hiawatha.conf

 

 

复制代码
代码如下:
#vi /usr/local/etc/hiawatha/hiawatha.conf

 

我没多大修改配置:

 

复制代码
代码如下:
# Hiawatha main configuration file
#</p> <p># GENERAL SETTINGS
#
ServerId = www:www
ConnectionsTotal = 250
ConnectionsPerIP = 25
SystemLogfile = /usr/local/var/log/hiawatha/system.log
GarbageLogfile = /usr/local/var/log/hiawatha/garbage.log</p> <p># BINDING SETTINGS
# A binding is where a client can connect to.
#
Binding {
Port = 80
# Interface = 127.0.0.1
# MaxKeepAlive = 30
# TimeForRequest = 3,20
}
#
#Binding {
# Port = 443
# Interface = ::1
# MaxKeepAlive = 30
# TimeForRequest = 3,20
# SSLcertFile = hiawatha.pem
#}</p> <p># BANNING SETTINGS
# Deny service to clients who misbehave.
#
BanOnGarbage = 300
BanOnMaxPerIP = 60
BanOnMaxReqSize = 300
KickOnBan = yes
RebanDuringBan = yes</p> <p># COMMON GATEWAY INTERFACE (CGI) SETTINGS
# These settings can be used to run CGI applications.
#
#CGIhandler = /usr/bin/perl:pl
#CGIhandler = /usr/local/php/bin/php-cgi:php
#CGIhandler = /usr/bin/python:py
#CGIhandler = /usr/bin/ruby:rb
#CGIhandler = /usr/bin/ssi-cgi:shtml
#CGIextension = cgi</p> <p>FastCGIserver {
FastCGIid = PHP5
ConnectTo = /var/lib/hiawatha/php-fcgi.sock //根据自己所在的位置填写
Extension = php
}</p> <p># URL TOOLKIT
# This URL toolkit rule was made for the Banshee PHP framework, which
# can be downloaded from http://www.hiawatha-webserver.org/banshee
#
#UrlToolkit {
# ToolkitID = banshee
# RequestURI isfile Return
# Match ^/(css|files|images|js|slimstat)($|/) Return
# Match ^/(favicon.ico|robots.txt|sitemap.xml)$ Return
# Match .*\?(.*) Rewrite /index.php?$1
# Match .* Rewrite /index.php
#}</p> <p># DEFAULT WEBSITE
# It is wise to use your IP address as the hostname of the default website
# and give it a blank webpage. By doing so, automated webscanners won't find
# your possible vulnerable website.
#
Hostname = 127.0.0.1
WebsiteRoot = /home/wwwroot
StartFile = index.html
AccessLogfile = /usr/local/var/log/hiawatha/access.log
ErrorLogfile = /usr/local/var/log/hiawatha/error.log
ErrorHandler = 404:/error.cgi</p> <p># VIRTUAL HOSTS
# Use a VirtualHost section to declare the websites you want to host.
#
#VirtualHost {
# Hostname = 127.0.0.1
# WebsiteRoot = /home/wwwroot
# StartFile = index.php
# AccessLogfile = /var/www/my-domain/log/access.log
# ErrorLogfile = /var/www/my-domain/log/error.log
# TimeForCGI = 5
# UseFastCGI = PHP5
# UseToolkit = banshee
#}</p> <p># DIRECTORY SETTINGS
# You can specify some settings per directory.
#
#Directory {
# Path = /home/baduser
# ExecuteCGI = no
# UploadSpeed = 10,2
#}

 

启动命令:

 

复制代码
代码如下:
#/usr/local/sbin/hiawatha //根据自己的安装目录决定

 

关闭停止命令:

 

复制代码
代码如下:
#pgrep hiawatha //查看hiawatha的pid</p> <p>#kill -15 pidnumber //pidnumber就是hiawatha的pid

 

 

以下是php-fpm.confg

 

复制代码
代码如下:
[www]</p> <p> user = www</p> <p> group = www</p> <p> listen = /var/lib/hiawatha/php-fcgi.sock</p> <p> pm = static</p> <p> pm.max_children = 3</p> <p> chdir = /

 


责任编辑:电脑知识学习网

操作系统