mini_httpd + php 构建SSL MINI WEB

一、简介

目的:构建小型WEB站,具备SSL,解析PHP脚本(适用嵌入式环境)。

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 b修改版:http://www.hochstrasser.org/wiki/files/mini_httpd-1.19bhoc.tar.gz

php:php.4.4.2

二、步骤说明

A、解压 php.4.4.2


  1. #cd php.4.4.2/   
  2. #./configure --prefix=/usr/local/php   
  3. # make install   
安装完成后把/usr/local/src/php-4.4.2/php.ini-dist复制到/usr/local/php/lib/,并重命名为php.ini

B、安装 mini_httpd-1.19

解压 mini_httpd-1.19bhoc.tar.gz 
  1. #cd mini_httpd-1.19bhoc   
  2. #vi Makefile  
修改如下:

  1. # Makefile for mini_httpd   
  2.   
  3. # CONFIGURE: If you are using a SystemV-based operating system, such as  
  4.   
  5. # Solaris, you will need to uncomment this definition.  
  6.   
  7. #SYSV_LIBS = -lnsl -lsocket   
  8.   
  9. # CONFIGURE: Some systems don't need -lcrypt, and indeed they get an  
  10.   
  11. # error if you try to link with it. If you get an error about libcrypt  
  12.   
  13. # not found, try commenting out this definition.  
  14.   
  15. CRYPT_LIB = -lcrypt  
  16.   
  17. # CONFIGURE: If you want to compile in support for https, uncomment these  
  18.   
  19. # definitions. You will need to have already built OpenSSL, available at  
  20.   
  21. # [url]http://www.openssl.org/[/url] Make sure the SSL_TREE definition points to the  
  22.   
  23. # tree with your OpenSSL installation - depending on how you installed it,  
  24.   
  25. # it may be in /usr/local instead of /usr/local/ssl.  
  26.   
  27. SSL_TREE = /usr/share/ssl  
  28.   
  29. SSL_DEFS = -DUSE_SSL  
  30.   
  31. SSL_INC = -I${SSL_TREE}/include  
  32.   
  33. SSL_LIBS = -L${SSL_TREE}/lib -lssl -lcrypto  
  34.   
  35. # CONFIGURE: If you want to compile in support for PHP environment variables  
  36.   
  37. # (namely PHP_AUTH_USER and PHP_AUTH_PW) then uncomment the definition below.  
  38.   
  39. #PHP_ENV = -DPHP_ENV   
  40.   
  41. # CONFIGURE: If you want to omit all IPV6 Support, uncomment the def below.  
  42.   
  43. #IPV6_DEFS = -DNO_IPV6   
  44.   
  45. BINDIR = /usr/local/sbin  
  46.   
  47. MANDIR = /usr/local/man  
  48.   
  49. CC = gcc  
  50.   
  51. CDEFS = ${SSL_DEFS} ${SSL_INC} ${IPV6_DEFS} ${PHP_ENV}  
  52.   
  53. CFLAGS = -O ${CDEFS}  
  54.   
  55. #CFLAGS = -g ${CDEFS}   
  56.   
  57. LDFLAGS = -s -ldl  
  58.   
  59. #LDFLAGS = -g   
  60.   
  61. LDLIBS = ${SSL_LIBS} ${SYSV_LIBS} ${CRYPT_LIB}  
  62.   
  63. all: mini_httpd htpasswd  
  64.   
  65. mini_httpd: mini_httpd.o match.o tdate_parse.o  
  66.   
  67. ${CC} ${CFLAGS} ${LDFLAGS} mini_httpd.o match.o tdate_parse.o ${LDLIBS} -o mini_httpd  
  68.   
  69.   
  70. mini_httpd.o: mini_httpd.c version.h port.h match.h tdate_parse.h mime_encodings.h mime_types.h  
  71.   
  72. ${CC} ${CFLAGS} -c mini_httpd.c  
  73.   
  74. match.o: match.c match.h  
  75.   
  76. ${CC} ${CFLAGS} -c match.c  
  77.   
  78. tdate_parse.o: tdate_parse.c tdate_parse.h  
  79.   
  80. ${CC} ${CFLAGS} -c tdate_parse.c  
  81.   
  82. mime_encodings.h: mime_encodings.txt  
  83.   
  84. rm -f mime_encodings.h  
  85.   
  86. sed mime_encodings.h \  
  87.   
  88. -e 's/#.*//' -e 's/[ ]*$$//' -e '/^$$/d' \  
  89.   
  90. -e 's/[ ][ ]*/", 0, "/' -e 's/^/{ "/' -e 's/$$/", 0 },/'  
  91.   
  92. mime_types.h: mime_types.txt  
  93.   
  94. rm -f mime_types.h  
  95.   
  96. sed mime_types.h \  
  97.   
  98. -e 's/#.*//' -e 's/[ ]*$$//' -e '/^$$/d' \  
  99.   
  100. -e 's/[ ][ ]*/", 0, "/' -e 's/^/{ "/' -e 's/$$/", 0 },/'  
  101.   
  102. htpasswd: htpasswd.o  
  103.   
  104. ${CC} ${CFLAGS} ${LDFLAGS} htpasswd.o ${CRYPT_LIB} -o htpasswd  
  105.   
  106. htpasswd.o: htpasswd.c  
  107.   
  108. ${CC} ${CFLAGS} -c htpasswd.c  
  109.   
  110. cert: mini_httpd.pem  
  111.   
  112. mini_httpd.pem: mini_httpd.cnf  
  113.   
  114. openssl req -new -x509 -days 3650 -nodes -config mini_httpd.cnf -out mini_httpd.pem -keyout mini_httpd.pem  
  115.   
  116. openssl x509 -subject -dates -fingerprint -noout -in mini_httpd.pem  
  117.   
  118. chmod 600 mini_httpd.pem  
  119.   
  120. install: all  
  121.   
  122. rm -f ${BINDIR}/mini_httpd ${BINDIR}/htpasswd  
  123.   
  124. -mkdir -p ${BINDIR}  
  125.   
  126. cp mini_httpd htpasswd ${BINDIR}  
  127.   
  128. rm -f ${MANDIR}/man8/mini_httpd.8 ${MANDIR}/man1/htpasswd.1  
  129. -mkdir -p ${MANDIR}/man8  
  130. cp mini_httpd.8 ${MANDIR}/man8  
  131.   
  132. -mkdir -p ${MANDIR}/man1  
  133.   
  134. cp htpasswd.1 ${MANDIR}/man1  
  135.   
  136.   
  137.   
  138. clean:  
  139.   
  140. rm -f mini_httpd mime_encodings.h mime_types.h htpasswd mini_httpd.rnd *.o core core.* *.core  
  141.   
  142. tar:  
  143.  
  144. @name=`sed -n -e '/SERVER_SOFTWARE/!d' -e 's,.*mini_httpd/,mini_httpd-,' -e 's, .*,,p' version.h` ; \  
  145.   
  146. rm -rf $$name ; \  
  147.   
  148. mkdir $$name ; \  
  149.   
  150. tar cf - `cat FILES` | ( cd $$name ; tar xfBp - ) ; \  
  151.   
  152. chmod 644 $$name/Makefile $$name/mime_encodings.txt $$name/mime_types.txt ; \  
  153.   
  154. chmod 755 $$name/contrib $$name/contrib/redhat-rpm ; \  
  155. tar cf $$name.tar $$name ; \  
  156. rm -rf $$name ; \  
  157. gzip $$name.tar  
修改说明:

编译支持SSL,采用redhat8 自带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证书有效期为10年, -days 3650

cert: mini_httpd.pem

mini_httpd.pem: mini_httpd.cnf

openssl req -new -x509 -days 3650 -nodes
#make

#make install

每次重新编译前需要运行(make clean)

--------------------------------------------------------------
生成SSL证书:
#make cert
安提示输入证书信息,即在当前目录下生成证书文件mini_httpd.pem 拷贝该文件到 /etc
#cp ./mini_httpd.pem /etc

修改建立mini_httpd.conf 配置文件

  1. # mini_httpd configuration file   
  2.   
  3. data_dir=/usr/local/www  
  4.   
  5. #user=httpd   
  6.   
  7. port=443  
  8.   
  9. host=0.0.0.0  
  10.   
  11. cgipat=**.php  
  12.   
  13. logfile=/var/log/mini_httpd  
  14.   
  15. pidfile=/var/run/mini_httpd.pid  
  16.   
  17. charset=GB2312  
  18.   
  19. ssl  
  20.   
  21. certfile=/etc/mini_httpd.pem  
拷贝该脚本到,web 数据目录
      #cp ./test.php /usr/local/www
      更改文件为可执行!
      #chmod +x /usr/local/www/test.php
     --------------------------------------------------------------
     配置WEB服务网卡IP
     #ifconfig eth0 192.168.1.1 up
     启动mini_httpd
     #mini_httpd -C /etc/mini_httpd.conf


     客户端测试URL
     https://192.168.1.1/test.php
原文地址: http://bbs.chinaunix.net/forum.php?mod=viewthread&tid=711979
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
MiniServer是一款绿色、精简、迷你的WANMP(Windows+Apache+Nginx+MySQL+PHP)服务端程序,使用本工具可以非常方便的搭建网站服务器。 重要说明: 由于MiniServer包含组件比较复杂,所以每次更新都会或多或少对其组件进行修改,直接用新版本覆盖老版本则会产生许多不必要的问题。 更新时请注意备份数据库目录(MySQL\data)和网站文件目录(www\htdocs)到其他文件夹 删除原MiniServer文件夹,再将新版本解压,将上述两个目录复制回相应路径即可。 2013年6月6日 v2.0 1.新增:PHP更换为5.3.22和5.4.12,并更换原APACHE2HANDLER运行方式为CGI-FCGI 2.新增:全面支持Zend Guard加密 3.新增:添加一个快速便捷的文件分享服务器(基于第三方软件) 4.改进:调整虚拟目录和虚拟主机的设置功能(不再支持中文路径) 5.改进:程序细节优化,如程序未开启时,默认选中Apache等 6.改进:增加部分PHP模块,如SQLite3支持等 7.改进:调整默认主页文字说明、增加Zend Guard 5.01~6.0加密的三个测试文件 使用帮助 1.数据库管理地址为 //127.0.0.1/phpmyadmin 默认用户名 root 密码为 miniserver,菜单中有MySQL root用户密码重置功能 2.一般情况下,我个人不推荐新手更改组件配置文件或对组件进行升级操作,否则可能会导致MiniServer无法正常开启 3.网站根目录为 www/htdocs 文件夹,可以通过MiniServer菜单快速进入,也可以使用Apache的虚拟目录功能单独设置目录(Nginx暂时不支持虚拟目录) 4.菜单中有修改端口的功能,修改前请确保其他软件没有占用所修改的端口,如果遇到MiniServer中某组件无法正常启动,请使用菜单中的调试模式检查错误信息,或者检查端口占用情况 5.请勿在在含有中文路径或目录下使用MiniServer,否则会造成组件无法启动等问题 6.MiniServer支持IPv6,查看本机IPv6地址可以用 ipconfig 命令或者直接登陆 ipv6-test.com 7.内置一款探针程序,可以让您更好的浏览本机服务器信息。//127.0.0.1/tz.php

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值