"Conclusion" mini_httpd + PhP build SSL mini web

Source: Internet
Author: User

From: http://bbs.chinaunix.net/thread-711979-1-1.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
E_mail: hysundy@163.com
II. Environment Resources
RedHat 8
Mini_httpd_1.19 B modified version
Php.4.4.2
Iii. Steps
-------------------------------------------------------------
A. install PHP (many articles are introduced below)

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:

  1. # Makefile for mini_httpd
  2. # Configure: if you are using a systemv-based operating system, such
  3. # Solaris, you will need to uncomment this definition.
  4. # Sysv_libs =-lnsl-lsocket
  5. # Configure: Some systems don't need-lcrypt, and indeed they get
  6. # Error if you try to link with it. If you get an error about libcrypt
  7. # Not found, Try Commenting out this definition.
  8. Crypt_lib =-lcrypt
  9. # Configure: If you want to compile in support for HTTPS, uncomment these
  10. # Definitions. You will need to have already built OpenSSL, available
  11. # Http://www.openssl.org/make sure the ssl_tree definition points to
  12. # Tree with your OpenSSL installation-depending on how you installed it,
  13. # It may be in/usr/local instead of/usr/local/SSL.
  14. Ssl_tree =/usr/share/SSL
  15. Ssl_defs =-duse_ssl
  16. Ssl_inc =-I $ {ssl_tree}/include
  17. Ssl_libs =-L $ {ssl_tree}/lib-lssl-lcrypto
  18. # Configure: If you want to compile in support for PHP Environment Variables
  19. # (Namely php_auth_user and php_auth_pw) Then uncomment the definition below.
  20. # Php_env =-dphp_env
  21. # Configure: If you want to omit all IPv6 support, uncomment the def below.
  22. # Ipv6_defs =-dno_ipv6
  23. Bindir =/usr/local/sbin
  24. Mandir =/usr/local/man
  25. Cc = gcc
  26. Cdefs =$ {ssl_defs }$ {ssl_inc }$ {ipv6_defs }$ {php_env}
  27. Cflags =-o $ {cdefs}
  28. # Cflags =-G $ {cdefs}
  29. Ldflags =-S
  30. # Ldflags =-G
  31. Ldlibs =$ {ssl_libs }$ {sysv_libs }$ {crypt_lib}
  32. ALL: mini_httpd htpasswd
  33. Mini_httpd: mini_httpd.o match. O tdate_parse.o
  34. $ {CC }$ {cflags }$ {ldflags} mini_httpd.o match. O tdate_parse.o $ {ldlibs}-O mini_httpd
  35. Mini_httpd.o: mini_httpd.c version. h port. h match. h tdate_parse.h mime_encodings.h mime_types.h
  36. $ {CC }$ {cflags}-C mini_httpd.c
  37. Match. O: Match. C match. h
  38. $ {CC }$ {cflags}-C match. c
  39. Tdate_parse.o: tdate_parse.c tdate_parse.h
  40. $ {CC }$ {cflags}-C tdate_parse.c
  41. Mime_encodings.h: mime_encodings.txt
  42. Rm-F mime_encodings.h
  43. Sed <mime_encodings.txt> mime_encodings.h \
  44. -E's/#. * // '-E's/[] * $/'-E'/^ $/d '\
  45. -E's/[] [] */", 0,"/'-E's/^/{"/'-E's/$ /", 0 },/'
  46. Mime_types.h: mime_types.txt
  47. Rm-F mime_types.h
  48. Sed <mime_types.txt> mime_types.h \
  49. -E's/#. * // '-E's/[] * $/'-E'/^ $/d '\
  50. -E's/[] [] */", 0,"/'-E's/^/{"/'-E's/$ /", 0 },/'
  51. Htpasswd: htpasswd. o
  52. $ {CC }$ {cflags }$ {ldflags} htpasswd. o $ {crypt_lib}-O htpasswd
  53. Htpasswd. O: htpasswd. c
  54. $ {CC }$ {cflags}-C htpasswd. c
  55. CERT: mini_httpd.pem
  56. Mini_httpd.pem: mini_httpd.cnf
  57. OpenSSL req-New-X509-days 3650-nodes-config mini_httpd.cnf-out mini_httpd.pem-keyout mini_httpd.pem
  58. OpenSSL X509-subject-dates-fingerprint-noout-In mini_httpd.pem
  59. Chmod 600 mini_httpd.pem
  60. Install: All
  61. Rm-F $ {bindir}/mini_httpd $ {bindir}/htpasswd
  62. -Mkdir-p $ {bindir}
  63. CP mini_httpd htpasswd $ {bindir}
  64. Rm-F ${Mandir}/man8/mini_httpd.8 ${Mandir}/Man1/htpasswd.1
  65. -Mkdir-p ${Mandir}/man8
  66. CP mini_httpd.8 ${Mandir}/man8
  67. -Mkdir-p ${Mandir}/Man1
  68. CP htpasswd.1 ${Mandir}/Man1
  69. Clean:
  70. Rm-F mini_httpd mime_encodings.h mime_types.h htpasswd mini_httpd.rnd *. O core. **. Core
  71. Tar:
  72. @ Name = 'sed-n-E'/server_software /! D '-E's,. * mini_httpd/, mini_httpd-,'-E's,. *, p 'version. H ';\
  73. Rm-RF $ name ;\
  74. Mkdir $ name ;\
  75. Tar CF-'cat files' | (CD $ name; tar xfbp -);\
  76. Chmod 644 $ name/makefile $ name/mime_encodings.txt $ name/mime_types.txt ;\
  77. Chmod 755 $ name/contrib/RedHat-rpm ;\
  78. Tar CF $$name.tar $ name ;\
  79. Rm-RF $ name ;\
  80. Gzip extension name.tar

Copy code

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

  1. # Mini_httpd configuration file
  2. Data_dir =/usr/local/WWW
  3. # User = httpd
  4. Port = 443
  5. Host = 0.0.0.0
  6. Cgipat = **. php
  7. Logfile =/var/log/mini_httpd
  8. Pidfile =/var/run/mini_httpd.pid
  9. Charset = gb2312
  10. SSL
  11. Certfile =/etc/mini_httpd.pem

Copy code

Copy the configuration file to the/etc directory.
# Cp./mini_httpd.conf/etc

--------------------------------------------------------------
Create the PHP test Script test. php as follows:

  1. #! /Usr/local/PHP/bin/PHP
  2. <? PHP
  3. Phpinfo ();
  4. ?>

Copy code

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
Https: // 192.168.1.1/test. php

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.