<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Apache 1.3.x on Microsoft Windows</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="install.windows.iis7.html">Microsoft IIS 7.0 and later</a></div> <div class="next" style="text-align: right; float: right;"><a href="install.windows.apache2.html">Apache 2.x on Microsoft Windows</a></div> <div class="up"><a href="install.windows.html">Installation on Windows systems</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="install.windows.apache1" class="sect1"> <h2 class="title">Apache 1.3.x on Microsoft Windows</h2> <p class="para"> This section contains notes and hints specific to Apache 1.3.x installs of PHP on Microsoft Windows systems. There are also <a href="install.windows.apache2.html" class="link">instructions and notes for Apache 2</a> on a separate page. </p> <blockquote class="note"><p><strong class="note">Note</strong>: <p class="para"> Please read the <a href="install.windows.manual.html" class="link">manual installation steps</a> first! </p> </p></blockquote> <p class="simpara"> There are two ways to set up PHP to work with Apache 1.3.x on Windows. One is to use the CGI binary (<var class="filename">php.exe</var> for PHP 4 and <var class="filename">php-cgi.exe</var> for PHP 5), the other is to use the Apache Module DLL. In either case you need to edit your <var class="filename">httpd.conf</var> to configure Apache to work with PHP, and then restart the server. </p> <p class="simpara"> It is worth noting here that now the SAPI module has been made more stable under Windows, we recommend it's use above the CGI binary, since it is more transparent and secure. </p> <p class="simpara"> Although there can be a few variations of configuring PHP under Apache, these are simple enough to be used by the newcomer. Please consult the Apache Documentation for further configuration directives. </p> <p class="simpara"> After changing the configuration file, remember to restart the server, for example, <strong class="command">NET STOP APACHE</strong> followed by <strong class="command">NET START APACHE</strong>, if you run Apache as a Windows Service, or use your regular shortcuts. </p> <blockquote class="note"><p><strong class="note">Note</strong>: <span class="simpara">Remember that when adding path values in the Apache configuration files on Windows, all backslashes such as <var class="filename">c:\directory\file.ext</var> should be converted to forward slashes: <var class="filename">c:/directory/file.ext</var>. A trailing slash may also be necessary for directories.</span></p></blockquote> <div class="sect2" id="install.windows.apache1.module"> <h3 class="title">Installing as an Apache module</h3> <p class="para"> You should add the following lines to your Apache <var class="filename">httpd.conf</var> file: </p> <p class="para"> <div class="example" id="example-51"> <p><strong>Example #1 PHP as an Apache 1.3.x module</strong></p> <div class="example-contents"><p> This assumes PHP is installed to <var class="filename">c:\php</var>. Adjust the path if this is not the case. </p></div> <div class="example-contents"><p> For PHP 4: </p></div> <div class="example-contents"> <div class="apache-confcode"><pre class="apache-confcode"># Add to the end of the LoadModule section # Don't forget to copy this file from the sapi directory! LoadModule php4_module "C:/php/php4apache.dll" # Add to the end of the AddModule section AddModule mod_php4.c</pre> </div> </div> <div class="example-contents"><p> For PHP 5: </p></div> <div class="example-contents"> <div class="apache-confcode"><pre class="apache-confcode"># Add to the end of the LoadModule section LoadModule php5_module "C:/php/php5apache.dll" # Add to the end of the AddModule section AddModule mod_php5.c</pre> </div> </div> <div class="example-contents"><p> For both: </p></div> <div class="example-contents"> <div class="apache-confcode"><pre class="apache-confcode"># Add this line inside the <IfModule mod_mime.c> conditional brace AddType application/x-httpd-php .php # For syntax highlighted .phps files, also add AddType application/x-httpd-php-source .phps</pre> </div> </div> </div> </p> </div> <div class="sect2" id="install.windows.apache1.cgi"> <h3 class="title">Installing as a CGI binary</h3> <p class="para"> If you unzipped the PHP package to <var class="filename">C:\php\</var> as described in the <a href="install.windows.manual.html" class="link">Manual Installation Steps</a> section, you need to insert these lines to your Apache configuration file to set up the CGI binary: <div class="example" id="example-52"> <p><strong>Example #2 PHP and Apache 1.3.x as CGI</strong></p> <div class="example-contents"> <div class="apache-confcode"><pre class="apache-confcode">ScriptAlias /php/ "c:/php/" AddType application/x-httpd-php .php # For PHP 4 Action application/x-httpd-php "/php/php.exe" # For PHP 5 Action application/x-httpd-php "/php/php-cgi.exe" # specify the directory where php.ini is SetEnv PHPRC C:/php</pre> </div> </div> </div> Note that the second line in the list above can be found in the actual versions of <var class="filename">httpd.conf</var>, but it is commented out. Remember also to substitute the <var class="filename">c:/php/</var> for your actual path to PHP. </p> <div class="warning"><strong class="warning">Warning</strong><p class="para">A server deployed in CGI mode is open to several possible vulnerabilities. Please read our <a href="security.cgi-bin.html" class="link">CGI security section</a> to learn how to defend yourself from such attacks.</p></div> <p class="simpara"> If you would like to present PHP source files syntax highlighted, there is no such convenient option as with the module version of PHP. If you chose to configure Apache to use PHP as a CGI binary, you will need to use the <span class="function"><a href="function.highlight-file.html" class="function">highlight_file()</a></span> function. To do this simply create a PHP script file and add this code: <em><?php highlight_file('some_php_script.php'); ?></em>. </p> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="install.windows.iis7.html">Microsoft IIS 7.0 and later</a></div> <div class="next" style="text-align: right; float: right;"><a href="install.windows.apache2.html">Apache 2.x on Microsoft Windows</a></div> <div class="up"><a href="install.windows.html">Installation on Windows systems</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>