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 = /