Apache, PHP, MySQL, ASP.NET, JSP and Perl Solutions for your Web Development and Hosting Needs on Windows.
A Complete Web Development and Hosting Platform for Windows.

Building PHP 4.4.4

Building a Web Server, for Linux

Requirements

  • Apache2
  • [Optional] OpenSSL
  • [Optional] MySQL
  • [Optional] zlib

Download

  • Package(Linux source) : php-4.4.4.tar.bz2
  • Unpack with command...
    tar -xjf php-4.4.4.tar.bz2

Our Configuration

  • Install to : /usr/local/php
  • Module type : dynamically loaded modules, *.so
  • Additional support for : SSL(OpenSSL), compression(zlib), MySQL

Configuration Options

Displays a list of configuration options...

php-4.4.4]# ./configure --help

Build Instructions

Configure

Configure the php build with openssl, zlib, and mysql [libs]...

php-4.4.4]# ./configure --prefix=/usr/local/php-4.4.4 --with-apxs2=/usr/local/apache2/bin/apxs --with-openssl=/usr/local/ssl --with-zlib=/usr/local --with-mysql=/usr/local/mysql
  • --prefix=/usr/local/php-4.4.4
    [this is the installation location; default is '/usr/local' -- we will symlink '/usr/local/php-4.4.4' to '/usr/local/php']
  • --with-apxs2=/usr/local/apache2/bin/apxs
    [build a shared PHP Apache2 module; specify the optional pathname to the Apache2 apxs tool]
    [If user has /usr/local/apache2 running, and /usr/local/httpd-2.0.xx to replace the older running version; use path to non-symlinked, newer version]
  • --with-openssl=/usr/local/ssl
    [include OpenSSL support; leave off '=DIR' if openssl was not built with '--prefix=DIR']
  • --with-zlib=/usr/local
    [include zlib support; leave off '=DIR' if zlib was not built with '--prefix=DIR']
  • --with-mysql=/usr/local/mysql
    [include MySQL support, specifing the optional MySQL base directory; leave off '=DIR' if mysql was not built with '--prefix=DIR']
  • Optional
    • --with-config-file-path=DIR
      [leave this option out, unless you know what you are doing]
      [sets the path in which to look for php.ini, defaults to 'prefix/lib']
    • --enable-versioning
      [leave this option out, unless you know what you are doing]
      [provides the ability to run PHP 3 and PHP 4 concurrently]
Build and Install
  • php-4.4.4]# make
  • php-4.4.4]# make install
    [will also copy phplib 'libs/libphp4.so' to the Apache modules directory, and add the phplib LoadModule line to httpd.conf]
[sanity check] Runtime Linker

Verify that Apache module 'libphp4.so' is linking against the correct zlib and ssl libraries...

...]# ldd /usr/local/apache2/modules/libphp4.so
  • libcrypt.so.1 => /lib/libcrypt.so.1 ...
  • libz.so.1 => /usr/local/lib/libz.so.1 ...
  • libssl.so.0.9.8 => /usr/local/ssl/lib/libssl.so.0.9.8 ...
  • libcrypto.so.0.9.8 => /usr/local/ssl/lib/libcrypto.so.0.9.8 ...
Symlink

Form symlink from '/usr/local/php-4.4.4' to '/usr/local/php'...

  • ...]# cd /usr/local
  • /usr/local]# ln -s php-4.4.4 php

Setup

Create php.ini...

php-4.4.4]# cp php.ini-recommended /usr/local/php/lib/php.ini

Note that if PHP was not built with '--prefix=DIR' [php installed to default location], create php.ini under '/usr/local/lib/'

php.ini can also be placed under /etc/ for global settings -- make sure no old php.ini files reside under this directory.

Edit /usr/local/php/lib/php.ini...

  • Edit doc_root = "/usr/local/apache2/htdocs/"
    [the directory your web server will be serving content from]
  • Edit file_uploads = Off
    [turn file uploads off, for security reasons]

Configuration for Apache 2.0

Edit /usr/local/apache2/conf/httpd.conf

PHP as an Apache Module
LoadModule php4_module modules/libphp4.so

DirectoryIndex index.html index.html.var index.php index.php4

<Location />
	AddType text/html .php .phps
	AddHandler application/x-httpd-php .php
	AddHandler application/x-httpd-php-source .phps
</Location>
PHP as CGI

[Recommended] Method #1...

ScriptAlias /cgi-bin/ "/usr/local/apache2/cgi-bin/"

<Directory "/usr/local/apache2/cgi-bin">
	AllowOverride None
	Options None
	Order allow,deny
	Allow from all
</Directory>

Method #2...

AddHandler php-script .php
AddType text/html .php

Method #3...

AddHandler cgi-script .php
AddType text/html .php

Configuration for zlib

Modifications need to be made to php.ini to switch on zlib compression detection and encoding.

Edit php.ini...

  • [Recommended] Method 1 -- Leave the compression to Apache's mod_deflate:
    • output_buffering = On
    • output_handler =
    • zlib.output_compression = Off
  • Method 2 -- Redirect all of the output of your scripts to the 'ob_gzhandler' function:
    • output_buffering = On
    • output_handler = ob_gzhandler
    • zlib.output_compression = Off
  • Method 3 -- Transparent output compression using the zlib library:
    • output_buffering = Off
    • output_handler =
    • zlib.output_compression = On

Testing

Create file 'phpinfo.php', containing the following code...

<?php phpinfo(); ?>

Place 'phpinfo.php' under your document root directory.

Access URL http://localhost/phpinfo.php

In the Spotlight

In the Spotlight

Developing and Hosting PHP+MySQL based websites and applications has never been simpler. The Web.Developer Server Suite provides a Platform & Framework on which to create standards-based CSS, XSLT, and XHTML sites running on PHP and MySQL. Save your time, focusing on core business. Reduce complexity and maximize your productivity.

Developers

Developers++

The Web.Developer Server Suite is more than just a Windows based Apache|PHP|MySQL Platform. Suitable for novices and professionals alike, a complete Hosting Solution is provided that is capable of creating and deploying websites and web applications both locally and on the internet. Create, test, publish and maintain your websites in-house, on your own server, where you are in full control.

Newsletter Signup

Newsletter Signup

Enter your e-mail address: