MINI_httpd移植,構建小型WEB服務器

 

1、簡介php

 

目的:構建小型WEB站,具有SSL。html

 

mini_httpd is a small HTTP server. Its performance is not great, but for low or medium traffic sites it's quite adequate. It implements all the basic features of an HTTP server, including:python

 

GET, HEAD, and POST methods.linux

CGI.服務器

Basic authentication.oop

Security against ".." filename snooping.ui

The common MIME types.spa

Trailing-slash redirection..net

index.html, index.htm, index.cgiorm

Directory listings.

Multihoming / virtual hosting.

Standard logging.

Custom error pages.

It can also be configured to do SSL/HTTPS and IPv6.

 

官網:http://acme.com/software/mini_httpd/

 

2、步驟說明

1、安裝 mini_httpd-1.19

 

解壓 mini_httpd-1.19bhoc.tar.gz

[python] view plaincopy

 

#cd mini_httpd-1.19bhoc 

1 修改Makfile文件   

修改以下:

 1) 編譯支持SSL,採用fedroa20, 自帶SSL /usr/share/ssl。下面幾行註釋取消

 

SSL_TREE = /usr/share/ssl

SSL_DEFS = -DUSE_SSL

SSL_INC = -I${SSL_TREE}/include

SSL_LIBS = -L${SSL_TREE}/lib -lssl -lcrypto

SSL_LIBS Make sure the SSL_TREE definition points to the tree with your OpenSSL installation - depending on how you installed it,這個也被我改了一點

2 )修改ssl證書有效期爲10年, -days 3650。網上這麼說。 可是fedroa20不用修改,已是了。

 

 

2 執行#make,不報錯誤error: openssl/ssl.h: No such file or directory。解決辦法

安裝openssl

# sudo apt-get install openssl(ubunto)

 yum install openssl(fedora ,redhat)

再安裝如下:

# sudo apt-get install libssl-dev build-essential zlibc zlib-bin libidn11-dev libidn11(ubunto)

yum install pcre-devel openssl-devel libidn-devel libidn2-devel(fedora,redhat)

 

3 #make install

感謝http://blog.wp08.com/article/computer/linux/756.html

http://blog.csdn.net/lwx2615/article/details/8542143

每次從新編譯前須要運行(make clean)

我在編譯前拷貝了openssl-libs-1.0.1e-4.fc19.i686和openssl-devel-1.0.1e-4.fc19.i686到本機,不知對結果有沒有影響,反正是沒報錯。

 

--------------------------------------------------------------

4 生成SSL證書:

#make cert

  生成證書請求(CSR)文件  

openssl req -new -key server.key -out certreq.csr  

Country Name:                           //您所在國家的ISO標準代號,中國爲CN  

State or Province Name:                 //您單位所在地省/自治區/直轄市  

Locality Name:                          //您單位所在地的市/縣/區  

Organization Name:                      //您單位/機構/企業合法的名稱  

Organizational Unit Name:               //部門名稱  

Common Name:                            //通用名,例如:www.itrus.com.cn。此項必須與您訪問提供SSL服務的服務器時所應用的域名徹底匹配。  

Email Address:                          //您的郵件地址,沒必要輸入,直接回車跳過  

"extra"attributes                        //如下信息沒必要輸入,回車跳過直到命令執行完畢。

安提示輸入證書信息,即在當前目錄下生成證書文件mini_httpd.pem 拷貝該文件到 /etc

5 #cp ./mini_httpd.pem /etc

 修改創建mini_httpd.conf 配置文件

 [python] view plaincopy

 

# mini_httpd configuration file 

 

data_dir=/usr/local/www/   #最後必須加斜槓

 

#user=httpd 

 

port=443 

 

host=0.0.0.0 

 

cgipat=**.php 

 

logfile=/var/log/mini_httpd 

 

pidfile=/var/run/mini_httpd.pid 

 

charset=GB2312 

 

ssl 

 

certfile=/etc/mini_httpd.pem  

 6 注意防火牆和selinux對網頁的過濾,可如今本機localhost:8080查看一下,再在局域網中查看一下。

Fedora 17及之前的版本關閉防火牆用systemctl stop iptables.service便可,其餘linux版本用service stop iptables

 Fedora 18以上用一個名叫firewalld的玩意,因此須要:

 systemctl stop firewalld.service有必要的話就

 systemctl disable firewalld.service

7 mini_http的密碼修改可經過htpasswd修改,源碼在htpasswd.c中

相關文章
相關標籤/搜索