home *** CD-ROM | disk | FTP | other *** search
/ Freelog Special Edition 1: Linux / CD1.iso / doc / HOWTO / mini / Apache+SSL+PHP+fp < prev    next >
Text File  |  1998-10-14  |  15KB  |  529 lines

  1.   Linux Apache SSL PHP/FI frontpage mini-HOWTO
  2.   Marcus Faure, marcus@faure.de
  3.   v1.1, July 1998
  4.  
  5.   This document is about building a multipurpose webserver that will
  6.   support dynamic web content via the PHP/FI scripting language, secure
  7.   transmission of data based on Netscape's SSL, secure execution of
  8.   CGI's and M$ Frontpage Server Extensions
  9.   ______________________________________________________________________
  10.  
  11.   Table of Contents
  12.  
  13.  
  14.   1. Introduction
  15.  
  16.      1.1 Description of the components
  17.      1.2 Working configurations
  18.      1.3 History
  19.  
  20.   2. Component installation
  21.  
  22.      2.1 Preparations
  23.      2.2 Adding PHP
  24.      2.3 Adding SSL
  25.      2.4 Adding frontpage
  26.  
  27.   3. Putting it all together
  28.  
  29.      3.1 Apache modules to try
  30.      3.2 Giving CGI's more security
  31.      3.3 Compiling and installing the server daemon
  32.      3.4 Adding frontpage support to a web
  33.      3.5 Starting the daemon
  34.      3.6 Some considerations left
  35.      3.7 Known bugs
  36.      3.8 The final word
  37.  
  38.  
  39.   ______________________________________________________________________
  40.  
  41.   1.  Introduction
  42.  
  43.   Before you start reading: I am not a native speaker, so there are
  44.   probably spelling/grammatical errors in this document. Feel encouraged
  45.   to inform me of mistakes.
  46.  
  47.  
  48.   1.1.  Description of the components
  49.  
  50.   The webserver you hopefully will get after having read this howto is
  51.   composed of several parts, the original apache sources with some
  52.   (well, many) patches and some external executables. I recommend using
  53.   the software versions I tried, they will probably compile without
  54.   greater problems and result in a fairly stable daemon. If you are
  55.   courageous, you can try to compile all the latest-stuff-with-tons-of-
  56.   new-features, but  don't blame me if something fails ;-). However, you
  57.   may report other working configurations to be included in future
  58.   versions of this document. All of the steps were tested on a linux
  59.   2.0.35 box, so the howto is somewhat linux-specific, but you should be
  60.   able to use it for other unixes as well.
  61.  
  62.   You do not necesserily have to compile in all components. I tried to
  63.   structure this howto so that you can skip the parts you are not
  64.   interested in.
  65.  
  66.  
  67.   The document is neither a user manual to Apache, SSL, PHP/FI nor
  68.   frontpage.  Its prime intention is to save webservice providers some
  69.   headaches when installing their server and to do my little
  70.   contribution to the linux community.
  71.  
  72.   PHP is a scripting language that supports dynamic HTML pages. It is a
  73.   bit like Apache's SSI, but by far more complex and has database
  74.   modules for many popular dbs. The GD libraries are needed by PHP.
  75.  
  76.   SSL is an implementation of Netscape's Secure Socket Layer that allow
  77.   secure connections over insecure networks, e.g. to transmit credit
  78.   card numbers to web based forms.
  79.  
  80.   frontpage is a wysiwyg web authoring tool that makes use of some
  81.   server-specific extensions called webbots. Some people think frontpage
  82.   is cool because you can create feedback forms and discussion webs
  83.   without having to know a bit about html or cgi. It even protects the
  84.   designer from uploading his/her site via ftp by using a builtin
  85.   publisher. If you wish to support frontpage but do not like to setup a
  86.   windows server, the apache server extensions are your choice.
  87.  
  88.  
  89.   1.2.  Working configurations
  90.  
  91.   Though this document has been downloaded some 100 times since I
  92.   published it, I received only little feedback. In particular, noone
  93.   told me of other working combinations. Combinations that work for me
  94.   are:
  95.  
  96.   ╖  Linux 2.0.31, Apache 1.2.4, PHP 2.0.0, SSL 0.8.0, fp 98 3.0.3 (*)
  97.  
  98.   ╖  Linux 2.0.33, Apache 1.2.5, PHP 2.0.1, SSL 0.8.0, fp 98 3.0.3 (*)
  99.  
  100.   ╖  Linux 2.0.35, Apache 1.2.6, PHP 3, SSL 0.8.0, fp 98 3.0.4
  101.  
  102.      (*) version 3.0.3 is ``not recommended''
  103.  
  104.  
  105.   1.3.  History
  106.  
  107.  
  108.   v0.0/Apr 98:    Preview version
  109.  
  110.   v1.0/Jun 98:    Now using Apache 1.2.6, updated fp section, minor
  111.   corrections
  112.  
  113.   v1.1/Jul 98:    Sgmlized and restructered version
  114.  
  115.   You can find the latest version of this document at
  116.   <http://www.faure.de>
  117.  
  118.  
  119.   2.  Component installation
  120.  
  121.   2.1.  Preparations
  122.  
  123.   You will need:
  124.  
  125.   ╖  Apache 1.2.6  <http://www.apache.org/dist/apache_1_2_6.tar.gz>
  126.  
  127.   ╖  PHP/FI Extensions
  128.      <http://php.iquest.net/files/download.phtml?/files/php-2.01.tar.gz>
  129.  
  130.   ╖  GD Library  <http://siva.cshl.org/gd/gd.html>
  131.  
  132.  
  133.   ╖  SSL 0.8.0 <ftp://ftp.ox.ac.uk/pub/crypto/SSL/SSLeay-0.8.0.tar.gz>
  134.  
  135.   ╖  SSL patch for Apache 1.2.6
  136.      <ftp://ftp.ox.ac.uk/pub/crypto/SSL/apache_1.2.6+ssl_1.17.tar.gz>
  137.  
  138.   ╖  frontpage 98 server extensions and install script
  139.      <http://www.rtr.com/fpsupport/download.htm>
  140.  
  141.   Get the sources you want. Untar apche, php, gd and ssl to /usr/src.
  142.   Untar the SSL patch to /usr/src/apache_1.2.6.
  143.  
  144.  
  145.   2.2.  Adding PHP
  146.  
  147.   cd to /usr/src/gd1.2 and type make. This will build the GD library
  148.   libgd.a, that should be copied to /usr/lib.  Now cd to php-2.0.1 and
  149.   run ./install.
  150.  
  151.   The relevant questions are:
  152.  
  153.   Would you like to compile PHP/FI as an Apache module? [yN] y
  154.   Are you compiling for an Apache 1.1 or later server? [Yn] y
  155.   Are you using Apache-Stronghold? [yN] y
  156.   Does your Apache server support ELF dynamic loading? [yN] y
  157.   Apache include directory (which has httpd.h)? [/usr/local/include/apache] /usr/src/apache_1.2.6/src
  158.   Would you like to build an ELF shared library? [yN] y
  159.   Additional directories to search for .h files []: /usr/src/gd1.2
  160.   Would you like the bundled regex library? [yN] n
  161.  
  162.  
  163.  
  164.   Like the frontpage extensions, phtml includes a security problem
  165.   because it is run under the uid of the webserver. Be sure to turn on
  166.   safe mode in src/php.h and restrict the search path to a save value.
  167.   There are some other options in php.h you may want to edit. If you are
  168.   very concerned about security, compile php as a cgi. However, this
  169.   will be a performance loss and not as smart as the module version.
  170.  
  171.   Type make to build all files. When the compilation is done, copy
  172.   mod_php.* and libphp.a to /usr/src/apache_1.2.6/src Add a line
  173.  
  174.   Module php_module mod_php.o
  175.  
  176.  
  177.   to the end of /usr/src/apache_1.2.6/src/Configuration, add
  178.  
  179.   -lphp -lm -lgdbm -lgd
  180.  
  181.  
  182.   to the EXTRA_LIBS in the same file,
  183.  
  184.   application/x-httpd-php phtml
  185.  
  186.  
  187.   to Apache's mime.types and
  188.  
  189.   AddType  application/x-httpd-php .phtml
  190.  
  191.  
  192.   to Apache's srm.conf.
  193.  
  194.   You may also want to add index.phtml to DirectoryIndex in that file so
  195.   that a file index.phtml is automatically loaded when its directory is
  196.   requested.
  197.  
  198.  
  199.   2.3.  Adding SSL
  200.  
  201.   cd /usr/src/SSL-0.8.0; ./Configure linux-elf; make; make rehash This
  202.   will create libraries needed by apache. You may issue make test to
  203.   verify the compilation.  You have to apply a patch to apache. It is
  204.   important that you apply it before the frontpage patch, otherwise
  205.   frontpage will not work.  cd to /usr/src/apache_1.2.6/src and issue
  206.   patch < /usr/src/apache_1.2.6/SSLpatch.  Set
  207.   SSL_BASE=/usr/src/SSLeay-0.8.0 in Configuration. Make sure that Module
  208.   proxy_module is disabled otherwise Apache won't compile. If you are in
  209.   need of a proxy, go for Squid <squid.nlanr.net>
  210.  
  211.   Now make certificate to generate SSLconf/conf/httpsd.pem.
  212.  
  213.  
  214.   2.4.  Adding frontpage
  215.  
  216.   Rename the fp30.linux.tar.Z file to fp30.linux.tar.gz, otherwise the
  217.   install script will not find it. Run ./fp_install to copy the
  218.   extension files to /usr/local/frontpage. zcat can usually be invoked
  219.   as /usr/bin/zcat.
  220.  
  221.   You now have to apply the FP patch. cd to /usr/src/apache_1.2.6/src
  222.   and type patch < /usr/src/frontpage/version3.0/apache-fp/fp-patch-
  223.   apache_1.2.5 This will create the mod_frontpage.* files and do some
  224.   modifications to Configuration etc. The 1.2.5 patch will work with
  225.   both apache 1.2.5 and 1.2.6. Skip the part about installing webs, you
  226.   can do that later
  227.  
  228.  
  229.   3.  Putting it all together
  230.  
  231.   3.1.  Apache modules to try
  232.  
  233.   The modules I use besides SSL, PHP and frontpage are:
  234.  
  235.   Module env_module          mod_env.o
  236.   Module config_log_module   mod_log_config.o
  237.   Module mime_module         mod_mime.o
  238.   Module negotiation_module  mod_negotiation.o
  239.   Module dir_module          mod_dir.o
  240.   Module cgi_module          mod_cgi.o
  241.   Module asis_module         mod_asis.o
  242.   Module imap_module         mod_imap.o
  243.   Module action_module       mod_actions.o
  244.   Module alias_module        mod_alias.o
  245.   Module rewrite_module      mod_rewrite.o
  246.   Module access_module       mod_access.o
  247.   Module auth_module         mod_auth.o
  248.   Module anon_auth_module    mod_auth_anon.o
  249.   Module digest_module       mod_digest.o
  250.   Module expires_module      mod_expires.o
  251.   Module headers_module      mod_headers.o
  252.   Module browser_module      mod_browser.o
  253.  
  254.  
  255.  
  256.  
  257.   3.2.  Giving CGI's more security
  258.  
  259.   If you are an ISP (you probably are when you read this) you will want
  260.   to improve security. The suexec utility allows you to do so; it will
  261.   execute cgi's under the UID of the webowner instead of executing it
  262.   under the webservers UID.  Go to /usr/src/apache_1.2.6/support and
  263.   make suexec.  chmod 4711 suxec and copy it to the location specified
  264.   in ../src/httpd.h which is /usr/local/etc/httpd/sbin/suexec by
  265.   default. If the path seems a little cryptic to you - it did to me -
  266.   edit httpd.h and set the path to a more comfortable value.
  267.  
  268.  
  269.   3.3.  Compiling and installing the server daemon
  270.  
  271.   Enter /usr/src/apache_1.2.6/src and edit Configuration to set all the
  272.   Modules you want to include in your Apache daemon. When done, run
  273.   ./Configure and make. This is the last (and most complicated)
  274.   compilation step, so cross your fingers. If it succeeds, cp httpsd to
  275.   /usr/sbin. The daemon is somewhat big, consider this when assembling
  276.   your webserver. Create the directory /var/httpd with subdirectories
  277.   cgi-bin, conf, htdocs, icons, virt1, virt2 and logs. In
  278.   /usr/src/apache_1.2.6/conf edit access.conf-dist, mime.types and
  279.   srm.conf-dist to suit your needs and copy them to
  280.   var/httpd/conf/access.conf, srm.conf and mime.types. Copy the
  281.   httpsd.pem you created with make certificate to /var/httpd/conf. Use
  282.   the following httpd.conf:
  283.  
  284.  
  285.  
  286.  
  287.  
  288.  
  289.  
  290.  
  291.  
  292.  
  293.  
  294.  
  295.  
  296.  
  297.  
  298.  
  299.  
  300.  
  301.  
  302.  
  303.  
  304.  
  305.  
  306.  
  307.  
  308.  
  309.  
  310.  
  311.  
  312.  
  313.  
  314.  
  315.  
  316.  
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331.   ServerType standalone
  332.   Port 80
  333.   Listen 80
  334.   Listen 443
  335.   User wwwrun
  336.   Group wwwrun
  337.   ServerAdmin webmaster@yourhost.com
  338.   ServerRoot /var/httpd
  339.   ErrorLog logs/error_log
  340.   TransferLog logs/access_log
  341.   PidFile logs/httpd.pid
  342.   ServerName www.yourhost.com
  343.   MinSpareServers 3
  344.   MaxSpareServers 20
  345.   StartServers 3
  346.  
  347.   SSLCACertificatePath /var/httpd/conf
  348.   SSLCACertificateFile /var/httpd/conf/httpsd.pem
  349.   SSLCertificateFile /var/httpd/conf/httpsd.pem
  350.   SSLLogFile /var/httpd/logs/ssl.log
  351.  
  352.   <VirtualHost www.virt1.com>
  353.   SSLDisable
  354.   ServerAdmin webmaster@virt1.com
  355.   DocumentRoot /var/httpd/virt1
  356.   ScriptAlias /cgi-bin/ /var/httpd/virt1/cgi-bin/
  357.   ServerName www.virt1.com
  358.   ErrorLog logs/virt1-error.log
  359.   TransferLog logs/virt1-access.log
  360.   User virt1admin
  361.   Group users
  362.   </VirtualHost>
  363.  
  364.   <VirtualHost www.virt1.com:443>
  365.   ServerAdmin webmaster@virt1.com
  366.   DocumentRoot /var/httpd/virt1
  367.   ScriptAlias /cgi-bin/ /var/httpd/virt1/cgi-bin/
  368.   ServerName www.virt1.com
  369.   ErrorLog logs/virt1-ssl-error.log
  370.   TransferLog logs/virt1-ssl-access.log
  371.   User virt1admin
  372.   Group users
  373.   SSLCACertificatePath /var/httpd/conf
  374.   SSLCACertificateFile /var/httpd/conf/httpsd.pem
  375.   SSLCertificateFile /var/httpd/conf/httpsd.pem
  376.   SSLLogFile /var/httpd/logs/virt1-ssl.log
  377.   SSLVerifyClient 0
  378.   SSLFakeBasicAuth
  379.   </VirtualHost>
  380.  
  381.   <VirtualHost www.virt2.com>
  382.   SSLDisable
  383.   ServerAdmin webmaster@virt2.com
  384.   DocumentRoot /var/httpd/virt2
  385.   ScriptAlias /cgi-bin/ /var/httpd/virt2/cgi-bin/
  386.   ServerName www.virt2.com
  387.   ErrorLog logs/virt2-error.log
  388.   TransferLog logs/virt2-access.log
  389.   </VirtualHost>
  390.  
  391.  
  392.  
  393.   Depending on the modules compiled in, not all directives may be
  394.   available.  You can retrieve a list of available directives with
  395.   httpsd -h.
  396.  
  397.   3.4.  Adding frontpage support to a web
  398.  
  399.   Enter /usr/local/frontpage/version3.0/bin and load ./fpsrvadm. Choose
  400.   install and apache-fp. The next questions should be answered the
  401.   following way:
  402.  
  403.   Enter server config filename: /var/httpd/conf/httpd.conf
  404.   Enter host name for multi-hosting []: www.virt2.com
  405.   Starting install, port: www.virt2.com:80, web: ""
  406.   Enter user's name []: virt2admin
  407.   Enter user's password:
  408.   Confirm password:
  409.   Creating root web
  410.   Recalculate links for root web
  411.   Install completed.
  412.  
  413.  
  414.  
  415.   The user name must be the unix login of the webowner. The password
  416.   does not necessarily have to match the system password.  You have to
  417.   manually add sendmailcommand:/usr/sbin/sendmail %r to
  418.   /usr/local/frontpage/www.virt2.com:80.conf, otherwise your users will
  419.   not be able to send web-generated eMails.  kill -HUP your httpsd to
  420.   make fp reread its config. You can now access www.virt2.com with your
  421.   frontpage client.
  422.  
  423.   Under some circumstances fpsrvadm complaints that a root web has to be
  424.   installed first. This is pretty useless, but you should do so to
  425.   silence fpsrvadm.
  426.  
  427.  
  428.   3.5.  Starting the daemon
  429.  
  430.   Start Apache with httpsd -f /var/httpd/conf/httpd.conf. You can now
  431.   access www.virt1.com both through http and https which is pretty cool.
  432.   Of course you have to pay for a real certificate if you want to offer
  433.   webwide SSL or users might laugh at you.
  434.  
  435.   Copy one of the demo files from the php examples directory to virt1 to
  436.   test phtml.
  437.  
  438.  
  439.   3.6.  Some considerations left
  440.  
  441.   Do not use frontpage 97 extensions. They do not work, at least under
  442.   Linux. When installing specific versions of the c++ libraries, they
  443.   appear to work but your logs will soon fill with premature end of
  444.   script headers and your mailbox will fill with complaints.  Do not use
  445.   frontpage 98 extensions before version 3.0.2.1330. Do not be confused,
  446.   version numbers are somewhat inheterogenous. When telnetting to port
  447.   80, typing "get / http/1.0" and hitting return twice, you get a
  448.   version number 3.0.4 for frontpage.
  449.  
  450.   You can find out the more specific version number by executing
  451.   /usr/local/frontpage/currentversion/exes/_vti_bin/shtml.exe -version.
  452.   Older versions have a nasty bug that requires httpd.conf to be
  453.   writable by the gid of the webserver. This should make you scream if
  454.   you are at all concerned about security.  Versions since 3.0.2.1330
  455.   are more usable.
  456.  
  457.  
  458.   3.7.  Known bugs
  459.  
  460.   When touching Recalculate Links in the frontpage client, the server
  461.   starts a process that consumes 99% cpu cycles and some 10 mb of
  462.   memory. But even for medium-sized webs and fast machines, the client
  463.   sometimes recieves a timeout message, though the calculation will be
  464.   finished correctly. Inform frontpage users to be patient and not to
  465.   hit Recalculate Links several times. Inform yourself to equip the
  466.   server with at least 64MB.
  467.  
  468.   Please note that at the time of writing both SSL and frontpage work,
  469.   but not at the same time, that means you can neither publish your web
  470.   using ssl nor make use of the webbots through https. You can publish
  471.   your web on port 80 and access it encrypted on port 443, but your
  472.   counters etc. will be broken. I consider this a bug. This problem
  473.   shall be fixed in SSL 0.9.0.
  474.  
  475.  
  476.   3.8.  The final word
  477.  
  478.   For those who think the title of this howto is nearly as long as the
  479.   document: Did you ever listened to Meat Loaf?
  480.  
  481.   O.K. readers, you're done for today. Feel free to send me your
  482.   feedback, eternal gratitude, flowers, ecash, cars, oil sources etc.
  483.  
  484.  
  485.  
  486.  
  487.  
  488.  
  489.  
  490.  
  491.  
  492.  
  493.  
  494.  
  495.  
  496.  
  497.  
  498.  
  499.  
  500.  
  501.  
  502.  
  503.  
  504.  
  505.  
  506.  
  507.  
  508.  
  509.  
  510.  
  511.  
  512.  
  513.  
  514.  
  515.  
  516.  
  517.  
  518.  
  519.  
  520.  
  521.  
  522.  
  523.  
  524.  
  525.  
  526.  
  527.  
  528.  
  529.