|
From: http://bbs.51cto.com/topic/thread-34022.html
I. Introduction
Objective: To build a small web site with SSL and parse PHP scripts (applicable to embedded environments ).
Author: sundy 2006-3-6
[Url = mailto: hysundy@163.com] [color = #000000] e_mail: hysundy@163.com [/color] [/url]
II. Environment Resources
RedHat 8
[Url = http://www.hochstrasser.org/wiki/files/mini_httpd-1.19bhoc.tar.gz][color=#000000]mini_httpd_1.19 B modified [/color] [/url]
Php.4.4.2
Iii. Steps
-------------------------------------------------------------
A. install PHP (many articles similar to [img] http://bbs.chinaunix.net/images/smilies/icon_smile.gif#/img])
Decompress php.4.4.2
# Cd php.4.4.2/
#./Configure -- prefix =/usr/local/PHP
# Make install
After the installation is complete, copy/usr/local/src/php-4.4.2/PHP. ini-Dist to/usr/local/PHP/lib/and rename it PHP. ini
--------------------------------------------------------------
--------------------------------------------------------------
B. Install mini_httpd-1.19
Extract mini_httpd-1.19bhoc.tar.gz
# Cd mini_httpd-1.19bhoc
# Vi makefile
The modification is as follows:
Code:
[Url = http://bbs.chinaunix.net/viewthread.php? Tid = 711979 & extra = Page % 3d4 ###] [color = #000000] [copy to clipboard] [/color] [/url]
# Makefile for mini_httpd
# Configure: if you are using a systemv-based operating system, such
# Solaris, you will need to uncomment this definition.
# Sysv_libs =-lnsl-lsocket
# Configure: Some systems don't need-lcrypt, and indeed they get
# Error if you try to link with it. If you get an error about libcrypt
# Not found, Try Commenting out this definition.
Crypt_lib =-lcrypt
# Configure: If you want to compile in support for HTTPS, uncomment these
# Definitions. You will need to have already built OpenSSL, available
# [Url] http://www.openssl.org/#/url] make sure the ssl_tree definition points to
# Tree with your OpenSSL installation-depending on how you installed it,
# It may be in/usr/local instead of/usr/local/SSL.
Ssl_tree =/usr/share/SSL
Ssl_defs =-duse_ssl
Ssl_inc =-I $ {ssl_tree}/include
Ssl_libs =-L $ {ssl_tree}/lib-lssl-lcrypto
# Configure: If you want to compile in support for PHP Environment Variables
# (Namely php_auth_user and php_auth_pw) Then uncomment the definition below.
# Php_env =-dphp_env
# Configure: If you want to omit all IPv6 support, uncomment the def below.
# Ipv6_defs =-dno_ipv6
Bindir =/usr/local/sbin
Mandir =/usr/local/man
Cc = gcc
Cdefs =$ {ssl_defs }$ {ssl_inc }$ {ipv6_defs }$ {php_env}
Cflags =-o $ {cdefs}
# Cflags =-G $ {cdefs}
Ldflags =-S-LDL
# Ldflags =-G
Ldlibs =$ {ssl_libs }$ {sysv_libs }$ {crypt_lib}
ALL: mini_httpd htpasswd
Mini_httpd: mini_httpd.o match. O tdate_parse.o
$ {CC }$ {cflags }$ {ldflags} mini_httpd.o match. O tdate_parse.o $ {ldlibs}-O mini_httpd
Mini_httpd.o: mini_httpd.c version. h port. h match. h tdate_parse.h mime_encodings.h mime_types.h
$ {CC }$ {cflags}-C mini_httpd.c
Match. O: Match. C match. h
$ {CC }$ {cflags}-C match. c
Tdate_parse.o: tdate_parse.c tdate_parse.h
$ {CC }$ {cflags}-C tdate_parse.c
Mime_encodings.h: mime_encodings.txt
Rm-F mime_encodings.h
Sed mime_encodings.h \
-E's/#. * // '-E's/[] * $/'-E'/^ $/d '\
-E's/[] [] */", 0,"/'-E's/^/{"/'-E's/$ /", 0 },/'
Mime_types.h: mime_types.txt
Rm-F mime_types.h
Sed mime_types.h \
-E's/#. * // '-E's/[] * $/'-E'/^ $/d '\
-E's/[] [] */", 0,"/'-E's/^/{"/'-E's/$ /", 0 },/'
Htpasswd: htpasswd. o
$ {CC }$ {cflags }$ {ldflags} htpasswd. o $ {crypt_lib}-O htpasswd
Htpasswd. O: htpasswd. c
$ {CC }$ {cflags}-C htpasswd. c
CERT: mini_httpd.pem
Mini_httpd.pem: mini_httpd.cnf
OpenSSL req-New-X509-days 3650-nodes-config mini_httpd.cnf-out mini_httpd.pem-keyout mini_httpd.pem
OpenSSL X509-subject-dates-fingerprint-noout-In mini_httpd.pem
Chmod 600 mini_httpd.pem
Install: All
Rm-F $ {bindir}/mini_httpd $ {bindir}/htpasswd
-Mkdir-p $ {bindir}
CP mini_httpd htpasswd $ {bindir}
Rm-F ${Mandir}/man8/mini_httpd.8 ${Mandir}/Man1/htpasswd.1
-Mkdir-p ${Mandir}/man8
CP mini_httpd.8 ${Mandir}/man8
-Mkdir-p ${Mandir}/Man1
CP htpasswd.1 ${Mandir}/Man1
Clean:
Rm-F mini_httpd mime_encodings.h mime_types.h htpasswd mini_httpd.rnd *. O core. **. Core
Tar:
@ Name = 'sed-n-E'/server_software /! D '-E's,. * mini_httpd/, mini_httpd-,'-E's,. *, p 'version. H ';\
Rm-RF $ name ;\
Mkdir $ name ;\
Tar CF-'cat files' | (CD $ name; tar xfbp -);\
Chmod 644 $ name/makefile $ name/mime_encodings.txt $ name/mime_types.txt ;\
Chmod 755 $ name/contrib/RedHat-rpm ;\
Tar CF $$name.tar $ name ;\
Rm-RF $ name ;\
Gzip extension name.tar
Description:
Compilation supports SSL and uses redhat8 with 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
Modify SSL certificate validity period to 10 years,-days 3650
CERT: mini_httpd.pem
Mini_httpd.pem: mini_httpd.cnf
OpenSSL req-New-X509-days 3650-nodes
# Make
# Make install
Make clean)
--------------------------------------------------------------
Generate an SSL certificate:
# Make Cert
Enter the certificate information, that is, generate the Certificate file mini_httpd.pem in the current directory to copy the file to/etc.
# Cp./mini_httpd.pem/etc
--------------------------------------------------------------
Modify and create the mini_httpd.conf configuration file
Code:
[Url = http://bbs.chinaunix.net/viewthread.php? Tid = 711979 & extra = Page % 3d4 ###] [color = #000000] [copy to clipboard] [/color] [/url]
# 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
Copy the configuration file to the/etc directory.
# Cp./mini_httpd.conf/etc
--------------------------------------------------------------
Create the PHP test Script test. php as follows:
Code:
[Url = http://bbs.chinaunix.net/viewthread.php? Tid = 711979 & extra = Page % 3d4 ###] [color = #000000] [copy to clipboard] [/color] [/url]
#! /Usr/local/PHP/bin/PHP
Copy the script to the Web data directory.
# Cp./test. php/usr/local/WWW
The file is executable!
# Chmod + x/usr/local/www/test. php
--------------------------------------------------------------
Configure the IP address of the web service Nic
# Ifconfig eth0 192.168.1.1 up
Start mini_httpd
# Mini_httpd-C/etc/mini_httpd.conf
Client test URL
[Url] https: // 192.168.1.1/test. php [/url] |