MINI_httpd移植,构建小型WEB服务器
一、简介
目的:构建小型WEB站,具备SSL。
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:
GET, HEAD, and POST methods.
CGI.
Basic authentication.
Security against ".." filename snooping.
The common MIME types.
Trailing-slash redirection.
index.html, index.htm, index.cgi
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/
二、步骤说明
一、安装 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中
MINI_httpd移植,构建小型WEB服务器的更多相关文章
- C语言构建小型Web服务器
#include <stdio.h> #include <sys/socket.h> #include <stdlib.h> #include <string ...
- HttpListener 实现小型web服务器
HttpListener 实现web服务器 用于小型服务器,简单.方便.不需要部署. 总共代码量不超过50行. static void Main(string[] args) { //创建HTTP监听 ...
- 构建Apache Web服务器
Apache 是世界使用排名第一的 Web 服务器软件.它可以运行在几乎所有广泛使用的计算机平台上,由于其跨平台和安全性被广泛使用,是最流行的 Web 服务器端软件之一.Apache工作模式有多种,其 ...
- Tiny server:小型Web服务器
一.背景 csapp的网络编程粗略的介绍了关于网络编程的一些知识,在最后的一节主要就实现了一个小型的Webserver.这个server名叫Tiny,它是一个小型的可是功能齐全的Webserver.在 ...
- 小型web服务器thttpd的学习总结(上)
1.软件的主要架构 软件的文件布局比较清晰,主要分为6个模块,主模块是thttpd.c文件,这个文件中包含了web server的主要逻辑,并调用了其他模块的函数.其他的5个模块都是单一的功能模块,之 ...
- 构建apache web 服务器
一.Apache服务器工作模式 1.Prefork模式:Prefork MPM使用多个子进程,每个子进程只有一个线程,每个进程在某个确定的时间只能维护一个连接 2.Worker模式: Worker M ...
- 小型web服务器thttpd的学习总结(下)
1.主函数模块分析 对于主函数而言,概括来说主要做了三点内容,也就是初始化系统,进行系统大循环,退出系统.下面主要简单阐述下在这三个部分,又做了哪些工作呢. 初始化系统 拿出程序的名字(argv[0] ...
- Shell 简单构建 Node web服务器
.git bash 执行代码生成: ./makeJs.sh 生成文件如下: 访问:http://127.0.0.1:3030/index.html makeJs.sh 代码如下: #create m ...
- 第五章、web服务器
一.web服务器 Web服务器就是整个万维网的骨干,广义上来说Web服务器既可以用来表示Web服务器的软件,也可以用来表示提供Web页面的特定设备和计算机.我们在网络上获取的所以资源,都需要有服务器来 ...
随机推荐
- ssh后台执行
1 执行scp命令,开始传输2 scp传输开始后,用ctrl+z,再以bg命令将其转入后台运行. 3以exit命令安全退出即可令scp继续执行,不受关闭shell的影响.
- Python3 字典 clear()方法
Python3 字典 描述 Python 字典 clear() 函数用于删除字典内所有元素. 语法 clear()方法语法: dict.clear() 参数 NA. 返回值 该函数没有任何返回值. ...
- 中南多校对抗赛 第三场 B
B:Arithmetic Progressions 题意: 给你一个长度为n的序列,问你这个序列中长度最长的等差数列长度为多少 题解: 方法一:将数组从小到大排序,n方扫,枚举出公差d,然后二分找有多 ...
- tp价格除以100
{$vo['money_num']/100} //正确 {$vo.money_num/100} //错误
- jinja2 中的 Template 批量替换json字符串中的内容
项目中用到elasticsearch,使用Json格式查询方式,一个查询语句中有好几个地方需要替换,且替换的值都相同.最开始把json转为字符串发方式,利用format函数处理,发现再转回json时无 ...
- hadoop 安装教程
本教程由厦门大学数据库实验室 / 给力星出品,转载请注明.本教程适合于原生 Hadoop 2,包括 Hadoop 2.6.0, Hadoop 2.7.1 等版本,主要参考了官方安装教程,步骤详细,辅以 ...
- spring整合hibernate时报错:org.hibernte.engine.transaction.spi.transactioncontext
错误提示:Caused by:java.lang.ClassNotFoundException: org.hibernte.engine.transaction.spi.transactioncont ...
- unZip/Zip的安装
1.apt-get安装: apt-get install zip 2.yum安装: yum install -y unzip zip
- each()和eq()
今天工作的时候要遍历一个表格,于是我就想到了each(),也没看文档就开始写,大概是这么写的 $(".class").each(function(){ this.click(fun ...
- .net core 中 identity server 4 之Topic --定义Client
客户端指能够从id4获取Token的角色. 客户端的共性: a unique client ID a secret if needed the allowed interactions with th ...