Você está na página 1de 163

PHP Manual

Preface
PHP, which stands for "PHP: Hypertext Preprocessor" is a widely-used Open Source general-
purpose scripting language that is especially suited for Web development and can be embedded
into HTML. Its syntax draws upon C, Java, and Perl, and is easy to learn. The main goal of the
language is to allow web developers to write dynamically generated web pages quickly, but you
can do much more with PHP.
This manual consists primarily of a function reference, but also contains a language reference,
explanations of some of PHP's major features, and other supplemental information.
You can download this manual in several formats at http://www.php.net/download-docs.php.
More information about how this manual is developed can be found in the 'About the manual'
appendix. If you are interested in the history of PHP, visit the relevant appendix.
Authors and Contributors
We highlight the currently most active people on front page of the manual, but there are many
more contributors who currently help in our work or have provided a great amount of help to the
project in the past. There are a lot of unnamed people who help out with user notes on manual
pages, which continually get included in the references, the work of whom we are also very
thankful for. All of the lists provided below are in alphabetical order.
Authors and Editors
The following contributors should be recognized for the impact they have made and/or continue
to make by adding content to the manual: Bill Abt, Jouni Ahto, Alexander Aulbach, Daniel
Beckham, Stig Bakken, Nilgn Belma Bugner, Jesus M. Castagnetto, Ron Chmara, Sean
Coates, John Coggeshall, Simone Cortesi, Peter Cowburn, Daniel Egeberg, Markus Fischer, Wez
Furlong, Sara Golemon, Rui Hirokawa, Brad House, Pierre-Alain Joye, Etienne Kneuss,
Moriyoshi Koizumi, Rasmus Lerdorf, Andrew Lindeman, Stanislav Malyshev, Rafael Martinez,
Rick McGuire, Kalle Sommer Nielsen, Yasuo Ohgaki, Richard Quadling, Derick Rethans, Rob
Richards, Sander Roobol, Egon Schmid, Thomas Schoefbeck, Sascha Schumann, Dan Scott,
Masahiro Takagi, Yannick Torres, Michael Wallner, Lars Torben Wilson, Jim Winstead, Jeroen
van Wolffelaar and Andrei Zmievski.
The following contributors have done significant work editing the manual: Stig Bakken, Gabor
Hojtsy, Hartmut Holzgraefe and Egon Schmid.
User Note Maintainers
The currently most active maintainers are: Daniel Brown, Nuno Lopes, Felipe Pena, Thiago
Pojda and Maciek Sokolewicz.
These people have also put a lot of effort into managing user notes: Mehdi Achour, Daniel
Beckham, Friedhelm Betz, Victor Boivie, Jesus M. Castagnetto, Nicolas Chaillan, Ron Chmara,
Sean Coates, James Cox, Vincent Gevers, Sara Golemon, Zak Greant, Szabolcs Heilig, Oliver
Hinckel, Hartmut Holzgraefe, Etienne Kneuss, Rasmus Lerdorf, Matthew Li, Andrew Lindeman,
Aidan Lister, Hannes Magnusson, Maxim Maletsky, Bobby Matthis, James Moore, Philip Olson,
Sebastian Picklum, Derick Rethans, Sander Roobol, Damien Seguy, Jason Sheets, Tom Sommer,
Jani Taskinen, Yasuo Ohgaki, Jakub Vrana, Lars Torben Wilson, Jim Winstead, Jared Wyles and
Jeroen van Wolffelaar.
Getting Started
Introduction
o What is PHP?
o What can PHP do?
A simple tutorial
o What do I need?
o Your first PHP-enabled page
o Something Useful
o Dealing with Forms
o Using old code with new versions of PHP
o What's next?
Introduction
Table of Contents
What is PHP?
What can PHP do?
What is PHP?
PHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely-used open source
general-purpose scripting language that is especially suited for web development and can be
embedded into HTML.
Nice, but what does that mean? An example:
Example #1 An introductory example
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Example</title>
</head>
<body>

<?php
echo "Hi, I'm a PHP script!";
?>

</body>
</html>
Instead of lots of commands to output HTML (as seen in C or Perl), PHP pages contain HTML
with embedded code that does "something" (in this case, output "Hi, I'm a PHP script!"). The
PHP code is enclosed in special start and end processing instructions <?php and ?> that allow
you to jump into and out of "PHP mode."
What distinguishes PHP from something like client-side JavaScript is that the code is executed
on the server, generating HTML which is then sent to the client. The client would receive the
results of running that script, but would not know what the underlying code was. You can even
configure your web server to process all your HTML files with PHP, and then there's really no
way that users can tell what you have up your sleeve.
The best things in using PHP are that it is extremely simple for a newcomer, but offers many
advanced features for a professional programmer. Don't be afraid reading the long list of PHP's
features. You can jump in, in a short time, and start writing simple scripts in a few hours.
Although PHP's development is focused on server-side scripting, you can do much more with it.
Read on, and see more in the What can PHP do? section, or go right to the introductory tutorial if
you are only interested in web programming.
What can PHP do?
Anything. PHP is mainly focused on server-side scripting, so you can do anything any other CGI
program can do, such as collect form data, generate dynamic page content, or send and receive
cookies. But PHP can do much more.
There are three main areas where PHP scripts are used.
Server-side scripting. This is the most traditional and main target field for PHP. You need
three things to make this work. The PHP parser (CGI or server module), a web server and
a web browser. You need to run the web server, with a connected PHP installation. You
can access the PHP program output with a web browser, viewing the PHP page through
the server. All these can run on your home machine if you are just experimenting with
PHP programming. See the installation instructions section for more information.
Command line scripting. You can make a PHP script to run it without any server or
browser. You only need the PHP parser to use it this way. This type of usage is ideal for
scripts regularly executed using cron (on *nix or Linux) or Task Scheduler (on
Windows). These scripts can also be used for simple text processing tasks. See the
section about Command line usage of PHP for more information.
Writing desktop applications. PHP is probably not the very best language to create a
desktop application with a graphical user interface, but if you know PHP very well, and
would like to use some advanced PHP features in your client-side applications you can
also use PHP-GTK to write such programs. You also have the ability to write cross-
platform applications this way. PHP-GTK is an extension to PHP, not available in the
main distribution. If you are interested in PHP-GTK, visit its own website.
PHP can be used on all major operating systems, including Linux, many Unix variants (including
HP-UX, Solaris and OpenBSD), Microsoft Windows, Mac OS X, RISC OS, and probably others.
PHP has also support for most of the web servers today. This includes Apache, Microsoft
Internet Information Server, Personal Web Server, Netscape and iPlanet servers, Oreilly Website
Pro server, Caudium, Xitami, OmniHTTPd, and many others. For the majority of the servers,
PHP has a module, for the others supporting the CGI standard, PHP can work as a CGI
processor.
So with PHP, you have the freedom of choosing an operating system and a web server.
Furthermore, you also have the choice of using procedural programming or object oriented
programming, or a mixture of them. Although not every standard OOP feature is implemented in
PHP 4, many code libraries and large applications (including the PEAR library) are written only
using OOP code. PHP 5 fixes the OOP related weaknesses of PHP 4, and introduces a complete
object model.
With PHP you are not limited to output HTML. PHP's abilities includes outputting images, PDF
files and even Flash movies (using libswf and Ming) generated on the fly. You can also output
easily any text, such as XHTML and any other XML file. PHP can autogenerate these files, and
save them in the file system, instead of printing it out, forming a server-side cache for your
dynamic content.
One of the strongest and most significant features in PHP is its support for a wide range of
databases. Writing a database-enabled web page is incredibly simple. The following databases
are currently supported:
Adabas D
dBase
Empress
FilePro (read-only)
Hyperwave
IBM DB2
Informix
Ingres
InterBase
FrontBase
mSQL
Direct MS-SQL
MySQL
ODBC
Oracle (OCI7 and OCI8)
Ovrimos
PostgreSQL
SQLite
Solid
Sybase
Velocis
Unix dbm
We also have a database abstraction extension (named PDO) allowing you to transparently use
any database supported by that extension. Additionally PHP supports ODBC, the Open Database
Connection standard, so you can connect to any other database supporting this world standard.
PHP also has support for talking to other services using protocols such as LDAP, IMAP, SNMP,
NNTP, POP3, HTTP, COM (on Windows) and countless others. You can also open raw network
sockets and interact using any other protocol. PHP has support for the WDDX complex data
exchange between virtually all Web programming languages. Talking about interconnection,
PHP has support for instantiation of Java objects and using them transparently as PHP objects.
You can also use our CORBA extension to access remote objects.
PHP has extremely useful text processing features, from the POSIX Extended or Perl regular
expressions to parsing XML documents. For parsing and accessing XML documents, PHP 4
supports the SAX and DOM standards, and you can also use the XSLT extension to transform
XML documents. PHP 5 standardizes all the XML extensions on the solid base of libxml2 and
extends the feature set adding SimpleXML and XMLReader support.
At last but not least, we have many other interesting extensions, the mnoGoSearch search engine
functions, the IRC Gateway functions, many compression utilities (gzip, bz2, zip), calendar
conversion, translation...
As you can see this page is not enough to list all the features and benefits PHP can offer. Read on
in the sections about installing PHP, and see the function reference part for explanation of the
extensions mentioned here.
A simple tutorial
Table of Contents
What do I need?
Your first PHP-enabled page
Something Useful
Dealing with Forms
Using old code with new versions of PHP
What's next?
Here we would like to show the very basics of PHP in a short, simple tutorial. This text only
deals with dynamic web page creation with PHP, though PHP is not only capable of creating
web pages. See the section titled What can PHP do for more information.
PHP-enabled web pages are treated just like regular HTML pages and you can create and edit
them the same way you normally create regular HTML pages.
What do I need?
In this tutorial we assume that your server has activated support for PHP and that all files ending
in .php are handled by PHP. On most servers, this is the default extension for PHP files, but ask
your server administrator to be sure. If your server supports PHP, then you do not need to do
anything. Just create your .php files, put them in your web directory and the server will
automatically parse them for you. There is no need to compile anything nor do you need to
install any extra tools. Think of these PHP-enabled files as simple HTML files with a whole new
family of magical tags that let you do all sorts of things. Most web hosts offer PHP support, but
if your host does not, consider reading the PHP Links section for resources on finding PHP
enabled web hosts.
Let us say you want to save precious bandwidth and develop locally. In this case, you will want
to install a web server, such as Apache, and of course PHP. You will most likely want to
install a database as well, such as MySQL.
You can either install these individually or choose a simpler way. Our manual has installation
instructions for PHP (assuming you already have some web server set up). In case you have
problems with installing PHP yourself, we would suggest you ask your questions on our
installation mailing list. If you choose to go on the simpler route, then locate a pre-configured
package for your operating system, which automatically installs all of these with just a few
mouse clicks. It is easy to setup a web server with PHP support on any operating system,
including MacOSX, Linux and Windows. On Linux, you may find rpmfind and PBone
helpful for locating RPMs. You may also want to visit apt-get to find packages for Debian.
Your first PHP-enabled page
Create a file named hello.php and put it in your web server's root directory
(DOCUMENT_ROOT) with the following content:
Example #1 Our first PHP script: hello.php
<html>
<head>
<title>PHP Test</title>
</head>
<body>
<?php echo '<p>Hello World</p>'; ?>
</body>
</html>
Use your browser to access the file with your web server's URL, ending with the /hello.php file
reference. When developing locally this URL will be something like http://localhost/hello.php or
http://127.0.0.1/hello.php but this depends on the web server's configuration. If everything is
configured correctly, this file will be parsed by PHP and the following output will be sent to your
browser:
<html>
<head>
<title>PHP Test</title>
</head>
<body>
<p>Hello World</p>
</body>
</html>
This program is extremely simple and you really did not need to use PHP to create a page like
this. All it does is display: Hello World using the PHP echo() statement. Note that the file does
not need to be executable or special in any way. The server finds out that this file needs to be
interpreted by PHP because you used the ".php" extension, which the server is configured to pass
on to PHP. Think of this as a normal HTML file which happens to have a set of special tags
available to you that do a lot of interesting things.
If you tried this example and it did not output anything, it prompted for download, or you see the
whole file as text, chances are that the server you are on does not have PHP enabled, or is not
configured properly. Ask your administrator to enable it for you using the Installation chapter of
the manual. If you are developing locally, also read the installation chapter to make sure
everything is configured properly. Make sure that you access the file via http with the server
providing you the output. If you just call up the file from your file system, then it will not be
parsed by PHP. If the problems persist anyway, do not hesitate to use one of the many PHP
support options.
The point of the example is to show the special PHP tag format. In this example we used <?php
to indicate the start of a PHP tag. Then we put the PHP statement and left PHP mode by adding
the closing tag, ?>. You may jump in and out of PHP mode in an HTML file like this anywhere
you want. For more details, read the manual section on the basic PHP syntax.
Note: A Note on Line Feeds
Line feeds have little meaning in HTML, however it is still a good idea to make your HTML
look nice and clean by putting line feeds in. A linefeed that follows immediately after a closing
?> will be removed by PHP. This can be extremely useful when you are putting in many blocks
of PHP or include files containing PHP that aren't supposed to output anything. At the same time
it can be a bit confusing. You can put a space after the closing ?> to force a space and a line feed
to be output, or you can put an explicit line feed in the last echo/print from within your PHP
block.
Note: A Note on Text Editors
There are many text editors and Integrated Development Environments (IDEs) that you can use
to create, edit and manage PHP files. A partial list of these tools is maintained at PHP Editors
List. If you wish to recommend an editor, please visit the above page and ask the page
maintainer to add the editor to the list. Having an editor with syntax highlighting can be helpful.
Note: A Note on Word Processors
Word processors such as StarOffice Writer, Microsoft Word and Abiword are not optimal for
editing PHP files. If you wish to use one for this test script, you must ensure that you save the
file as plain text or PHP will not be able to read and execute the script.
Note: A Note on Windows Notepad
If you are writing your PHP scripts using Windows Notepad, you will need to ensure that your
files are saved with the .php extension. (Notepad adds a .txt extension to files automatically
unless you take one of the following steps to prevent it.) When you save the file and are
prompted to provide a name for the file, place the filename in quotes (i.e. "hello.php").
Alternatively, you can click on the 'Text Documents' drop-down menu in the 'Save' dialog box
and change the setting to "All Files". You can then enter your filename without quotes.
Now that you have successfully created a working PHP script, it is time to create the most
famous PHP script! Make a call to the phpinfo() function and you will see a lot of useful
information about your system and setup such as available predefined variables, loaded PHP
modules, and configuration settings. Take some time and review this important information.
Example #2 Get system information from PHP
<?php phpinfo(); ?>
Something Useful
Let us do something more useful now. We are going to check what sort of browser the
visitor is using. For that, we check the user agent string the browser sends as part of the
HTTP request. This information is stored in a variable. Variables always start with a dollar-
sign in PHP. The variable we are interested in right now is $_SERVER['HTTP_USER_AGENT'].
Note: $_SERVER is a special reserved PHP variable that contains all web server information.
It is known as a superglobal. See the related manual page on superglobals for more
information. These special variables were introduced in PHP 4.1.0. Before this time, we
used the older $HTTP_*_VARS arrays instead, such as $HTTP_SERVER_VARS. Although
deprecated, these older variables still exist. (See also the note on old code.)
To display this variable, you can simply do:
Example #1 Printing a variable (Array element)
<?php
echo $_SERVER['HTTP_USER_AGENT'];
?>
A sample output of this script may be:

Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)
There are many types of variables available in PHP. In the above example we printed an
Array element. Arrays can be very useful.
$_SERVER is just one variable that PHP automatically makes available to you. A list can be
seen in the Reserved Variables section of the manual or you can get a complete list of them
by looking at the output of the phpinfo() function used in the example in the previous
section.
You can put multiple PHP statements inside a PHP tag and create little blocks of code that
do more than just a single echo. For example, if you want to check for Internet Explorer you
can do this:
Example #2 Example using control structures and functions
<?php
if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE) {
echo 'You are using Internet Explorer.<br />';
}
?>
A sample output of this script may be:
You are using Internet Explorer.<br />
Here we introduce a couple of new concepts. We have an if statement. If you are familiar
with the basic syntax used by the C language, this should look logical to you. Otherwise,
you should probably pick up an introductory PHP book and read the first couple of chapters,
or read the Language Reference part of the manual.
The second concept we introduced was the strpos() function call. strpos() is a function built
into PHP which searches a string for another string. In this case we are looking for 'MSIE'
(so-called needle) inside $_SERVER['HTTP_USER_AGENT'] (so-called haystack). If the
needle is found inside the haystack, the function returns the position of the needle relative
to the start of the haystack. Otherwise, it returns FALSE. If it does not return FALSE, the if
expression evaluates to TRUE and the code within its {braces} is executed. Otherwise, the
code is not run. Feel free to create similar examples, with if, else, and other functions such
as strtoupper() and strlen(). Each related manual page contains examples too. If you are
unsure how to use functions, you will want to read both the manual page on how to read a
function definition and the section about PHP functions.
We can take this a step further and show how you can jump in and out of PHP mode even in
the middle of a PHP block:
Example #3 Mixing both HTML and PHP modes
<?php
if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE) {
?>
<h3>strpos() must have returned non-false</h3>
<p>You are using Internet Explorer</p>
<?php
} else {
?>
<h3>strpos() must have returned false</h3>
<p>You are not using Internet Explorer</p>
<?php
}
?>
A sample output of this script may be:
<h3>strpos() must have returned non-false</h3>
<p>You are using Internet Explorer</p>
Instead of using a PHP echo statement to output something, we jumped out of PHP mode
and just sent straight HTML. The important and powerful point to note here is that the
logical flow of the script remains intact. Only one of the HTML blocks will end up getting sent
to the viewer depending on the result of strpos(). In other words, it depends on whether the
string MSIE was found or not.

User Contributed Notes
Something Useful
rfantin at coralwood dot com
20-Dec-2006 06:00
While it's easy to get carried away mixing your logic and presentation together since
it's so easy to do, your better off using PHP within HTML only to fill in values, or
include other source files.

Keep your actual processing in separate libraries that are called before you send any
headers to the page. Try to avoid calling a script that retrieves or sets
information, or manipulates it in the middle of your HTML. You'll find it's much
easier to maintain.
Dealing with Forms
One of the most powerful features of PHP is the way it handles HTML forms. The basic
concept that is important to understand is that any form element will automatically be
available to your PHP scripts. Please read the manual section on Variables from external
sources for more information and examples on using forms with PHP. Here is an example
HTML form:
Example #1 A simple HTML form
<form action="action.php" method="post">
<p>Your name: <input type="text" name="name" /></p>
<p>Your age: <input type="text" name="age" /></p>
<p><input type="submit" /></p>
</form>
There is nothing special about this form. It is a straight HTML form with no special tags of
any kind. When the user fills in this form and hits the submit button, the action.php page is
called. In this file you would write something like this:
Example #2 Printing data from our form
Hi <?php echo htmlspecialchars($_POST['name']); ?>.
You are <?php echo (int)$_POST['age']; ?> years old.
A sample output of this script may be:
Hi Joe. You are 22 years old.
Apart from the htmlspecialchars() and (int) parts, it should be obvious what this does.
htmlspecialchars() makes sure any characters that are special in html are properly encoded
so people can't inject HTML tags or Javascript into your page. For the age field, since we
know it is a number, we can just convert it to an integer which will automatically get rid of
any stray characters. You can also have PHP do this for you automatically by using the filter
extension. The $_POST['name'] and $_POST['age'] variables are automatically set for you
by PHP. Earlier we used the $_SERVER superglobal; above we just introduced the $_POST
superglobal which contains all POST data. Notice how the method of our form is POST. If we
used the method GET then our form information would live in the $_GET superglobal
instead. You may also use the $_REQUEST superglobal, if you do not care about the source
of your request data. It contains the merged information of GET, POST and COOKIE data.
Also see the import_request_variables() function.
You can also deal with XForms input in PHP, although you will find yourself comfortable with
the well supported HTML forms for quite some time. While working with XForms is not for
beginners, you might be interested in them. We also have a short introduction to handling
data received from XForms in our features section.



Using old code with new versions of PHP Something Useful

Last updated: Fri, 11 Jun 2010

User Contributed Notes
Dealing with Forms
arnel_milan at hotmail dot com
29-Mar-2008 05:27
I was so shocked that some servers have a problem regarding the Submit Type Name and
gives a "Not Acceptable error" or Error 406.

Consider the example below :

<form action="blah.php" method="POST">
<table>
<tr>
<td>Name:</td>
<td><input type="text" name="name"></td>
</tr>

<tr>
<td colspan="2" align="center">
<input type="submit" name="Submit_btn" id="Submit_btn" value="Send">
</td>
</tr>
</table>
</form>

This very simple code triggers the "Not Acceptable Error" on
PHP Version 5.2.5 and Apache 1.3.41 (Unix) Server.

However to fix this below is the right code:

<form action="blah.php" method="POST">
<table>
<tr>
<td>Name:</td>
<td><input type="text" name="name"></td>
</tr>

<tr>
<td colspan="2" align="center">
<input type="submit" name="Submitbtn" id="Submit_btn" value="Send">
</td>
</tr>
</table>
</form>

The only problem that took me hours to find out is the "_" in the Submit Button.

Hope this help!
SvendK
09-Nov-2006 04:02
As Seth mentions, when a user clicks reload or goes back with the browser button,
data sent to the server, may be sent again (after a click on the ok button).

It might be wise, to let the server handle whatever there is to handle, and then
redirect (a redirect is not visible in the history and thus not reachable via reload
or "back".

It cannot be used in this exact example, but as Seth also mentions, this example
should be using GET instead of POST
yasman at phplatvia dot lv
05-May-2005 07:18
[Editor's Note: Since "." is not legal variable name PHP will translate the dot to
underscore, i.e. "name.x" will become "name_x"]

Be careful, when using and processing forms which contains
<input type="image">
tag. Do not use in your scripts this elements attributes `name` and `value`, because
MSIE and Opera do not send them to server.
Both are sending `name.x` and `name.y` coordiante variables to a server, so better
use them.
sethg at ropine dot com
01-Dec-2003 08:55
According to the HTTP specification, you should use the POST method when you're using
the form to change the state of something on the server end. For example, if a page
has a form to allow users to add their own comments, like this page here, the form
should use POST. If you click "Reload" or "Refresh" on a page that you reached
through a POST, it's almost always an error -- you shouldn't be posting the same
comment twice -- which is why these pages aren't bookmarked or cached.

You should use the GET method when your form is, well, getting something off the
server and not actually changing anything. For example, the form for a search engine
should use GET, since searching a Web site should not be changing anything that the
client might care about, and bookmarking or caching the results of a search-engine
query is just as useful as bookmarking or caching a static HTML page.
Using old code with new versions of PHP
Now that PHP has grown to be a popular scripting language, there are a lot of public
repositories and libraries containing code you can reuse. The PHP developers have largely
tried to preserve backwards compatibility, so a script written for an older version will run
(ideally) without changes in a newer version of PHP. In practice, some changes will usually
be needed.
Two of the most important recent changes that affect old code are:
The deprecation of the old $HTTP_*_VARS arrays (which need to be indicated as
global when used inside a function or method). The following superglobal arrays
were introduced in PHP 4.1.0. They are: $_GET, $_POST, $_COOKIE, $_SERVER,
$_FILES, $_ENV, $_REQUEST, and $_SESSION. The older $HTTP_*_VARS arrays,
such as $HTTP_POST_VARS, also exist. As of PHP 5.0.0, the long PHP predefined
variable arrays may be disabled with the register_long_arrays directive.
External variables are no longer registered in the global scope by default. In other
words, as of PHP 4.2.0 the PHP directive register_globals is off by default in
php.ini. The preferred method of accessing these values is via the superglobal arrays
mentioned above. Older scripts, books, and tutorials may rely on this directive being
on. If it were on, for example, one could use $id from the URL
http://www.example.com/foo.php?id=42. Whether on or off, $_GET['id'] is available.
For more details on these changes, see the section on predefined variables and links
therein.
What's next?
With your new knowledge you should be able to understand most of the manual and also
the various example scripts available in the example archives. You can also find other
examples on the php.net websites in the links section: http://www.php.net/links.php.
To view various slide presentations that show more of what PHP can do, see the PHP
Conference Material Site: http://talks.php.net/


Installation and Configuration
General Installation Considerations
Installation on Unix systems
Apache 1.3.x on Unix systems
Apache 2.x on Unix systems
Lighttpd 1.4 on Unix systems
Sun, iPlanet and Netscape servers on Sun Solaris
CGI and command line setups
HP-UX specific installation notes
OpenBSD installation notes
Solaris specific installation tips
Debian GNU/Linux installation notes
Installation on Mac OS X
Using Packages
Using the bundled PHP
Compiling for OS X Server
Installing for Apache on MacOS X Client
Installation on Windows systems
Windows Installer (PHP 5.1.0 and earlier)
Windows Installer (PHP 5.2 and later)
Manual Installation Steps
ActiveScript
Microsoft IIS
Microsoft IIS 5.1 and IIS 6.0
Microsoft IIS 7.0 and later
Apache 1.3.x on Microsoft Windows
Apache 2.x on Microsoft Windows
Sun, iPlanet and Netscape servers on Microsoft Windows
OmniHTTPd Server
Sambar Server on Microsoft Windows
Xitami on Microsoft Windows
Building from source
Installation of extensions on Windows
Command Line PHP on Microsoft Windows
Installation of PECL extensions
Introduction to PECL Installations
Downloading PECL extensions
Installing a PHP extension on Windows
Compiling shared PECL extensions with the pecl command
Compiling shared PECL extensions with phpize
Compiling PECL extensions statically into PHP
Problems?
Read the FAQ
Other problems
Bug reports
Runtime Configuration
The configuration file
.user.ini files
Where a configuration setting may be set
How to change configuration settings
General Installation Considerations
Before starting the installation, first you need to know what do you want to use PHP for.
There are three main fields you can use PHP, as described in the What can PHP do? section:
Websites and web applications (server-side scripting)
Command line scripting
Desktop (GUI) applications
For the first and most common form, you need three things: PHP itself, a web server and a
web browser. You probably already have a web browser, and depending on your operating
system setup, you may also have a web server (e.g. Apache on Linux and MacOS X; IIS on
Windows). You may also rent webspace at a company. This way, you don't need to set up
anything on your own, only write your PHP scripts, upload it to the server you rent, and see
the results in your browser.
In case of setting up the server and PHP on your own, you have two choices for the method
of connecting PHP to the server. For many servers PHP has a direct module interface (also
called SAPI). These servers include Apache, Microsoft Internet Information Server, Netscape
and iPlanet servers. Many other servers have support for ISAPI, the Microsoft module
interface (OmniHTTPd for example). If PHP has no module support for your web server, you
can always use it as a CGI or FastCGI processor. This means you set up your server to use
the CGI executable of PHP to process all PHP file requests on the server.
If you are also interested to use PHP for command line scripting (e.g. write scripts
autogenerating some images for you offline, or processing text files depending on some
arguments you pass to them), you always need the command line executable. For more
information, read the section about writing command line PHP applications. In this case, you
need no server and no browser.
With PHP you can also write desktop GUI applications using the PHP-GTK extension. This is
a completely different approach than writing web pages, as you do not output any HTML,
but manage windows and objects within them. For more information about PHP-GTK, please
visit the site dedicated to this extension. PHP-GTK is not included in the official PHP
distribution.
From now on, this section deals with setting up PHP for web servers on Unix and Windows
with server module interfaces and CGI executables. You will also find information on the
command line executable in the following sections.
PHP source code and binary distributions for Windows can be found at
http://www.php.net/downloads.php. We recommend you to choose a mirror nearest to
you for downloading the distributions.
Installation on Unix systems
Table of Contents
Apache 1.3.x on Unix systems
Apache 2.x on Unix systems
Lighttpd 1.4 on Unix systems
Sun, iPlanet and Netscape servers on Sun Solaris
CGI and command line setups
HP-UX specific installation notes
OpenBSD installation notes
Solaris specific installation tips
Debian GNU/Linux installation notes
This section will guide you through the general configuration and installation of PHP on Unix
systems. Be sure to investigate any sections specific to your platform or web server before
you begin the process.
As our manual outlines in the General Installation Considerations section, we are mainly
dealing with web centric setups of PHP in this section, although we will cover setting up PHP
for command line usage as well.
There are several ways to install PHP for the Unix platform, either with a compile and
configure process, or through various pre-packaged methods. This documentation is mainly
focused around the process of compiling and configuring PHP. Many Unix like systems have
some sort of package installation system. This can assist in setting up a standard
configuration, but if you need to have a different set of features (such as a secure server, or
a different database driver), you may need to build PHP and/or your web server. If you are
unfamiliar with building and compiling your own software, it is worth checking to see
whether somebody has already built a packaged version of PHP with the features you need.
Prerequisite knowledge and software for compiling:
Basic Unix skills (being able to operate "make" and a C compiler)
An ANSI C compiler
flex: Version 2.5.4
bison: Version 1.28 (preferred), 1.35, or 1.75
A web server
Any module specific components (such as GD, PDF libs, etc.)
The initial PHP setup and configuration process is controlled by the use of the command line
options of the configure script. You could get a list of all available options along with short
explanations running ./configure --help. Our manual documents the different options
separately. You will find the core options in the appendix, while the different extension
specific options are descibed on the reference pages.
When PHP is configured, you are ready to build the module and/or executables. The
command make should take care of this. If it fails and you can't figure out why, see the
Problems section.
Apache 1.3.x on Unix systems
This section contains notes and hints specific to Apache installs of PHP on Unix platforms.
We also have instructions and notes for Apache 2 on a separate page.
You can select arguments to add to the configure on line 10 below from the list of core
configure options and from extension specific options described at the respective places in
the manual. The version numbers have been omitted here, to ensure the instructions are
not incorrect. You will need to replace the 'xxx' here with the correct values from your files.
Example #1 Installation Instructions (Apache Shared Module Version) for PHP
1. gunzip apache_xxx.tar.gz
2. tar -xvf apache_xxx.tar
3. gunzip php-xxx.tar.gz
4. tar -xvf php-xxx.tar
5. cd apache_xxx
6. ./configure --prefix=/www --enable-module=so
7. make
8. make install
9. cd ../php-xxx

10. Now, configure your PHP. This is where you customize your PHP
with various options, like which extensions will be enabled. Do a
./configure --help for a list of available options. In our example
we'll do a simple configure with Apache 1 and MySQL support. Your
path to apxs may differ from our example.

./configure --with-mysql --with-apxs=/www/bin/apxs

11. make
12. make install

If you decide to change your configure options after installation,
you only need to repeat the last three steps. You only need to
restart apache for the new module to take effect. A recompile of
Apache is not needed.

Note that unless told otherwise, 'make install' will also install PEAR,
various PHP tools such as phpize, install the PHP CLI, and more.

13. Setup your php.ini file:

cp php.ini-development /usr/local/lib/php.ini

You may edit your .ini file to set PHP options. If you prefer your
php.ini in another location, use --with-config-file-path=/some/path in
step 10.

If you instead choose php.ini-production, be certain to read the list
of changes within, as they affect how PHP behaves.

14. Edit your httpd.conf to load the PHP module. The path on the right hand
side of the LoadModule statement must point to the path of the PHP
module on your system. The make install from above may have already
added this for you, but be sure to check.

LoadModule php5_module libexec/libphp5.so

15. And in the AddModule section of httpd.conf, somewhere under the
ClearModuleList, add this:

AddModule mod_php5.c

16. Tell Apache to parse certain extensions as PHP. For example,
let's have Apache parse the .php extension as PHP. You could
have any extension(s) parse as PHP by simply adding more, with
each separated by a space. We'll add .phtml to demonstrate.

AddType application/x-httpd-php .php .phtml

It's also common to setup the .phps extension to show highlighted PHP
source, this can be done with:

AddType application/x-httpd-php-source .phps

17. Use your normal procedure for starting the Apache server. (You must
stop and restart the server, not just cause the server to reload by
using a HUP or USR1 signal.)
Alternatively, to install PHP as a static object:
Example #2 Installation Instructions (Static Module Installation for Apache) for
PHP
1. gunzip -c apache_1.3.x.tar.gz | tar xf -
2. cd apache_1.3.x
3. ./configure
4. cd ..

5. gunzip -c php-5.x.y.tar.gz | tar xf -
6. cd php-5.x.y
7. ./configure --with-mysql --with-apache=../apache_1.3.x
8. make
9. make install

10. cd ../apache_1.3.x

11. ./configure --prefix=/www --activate-module=src/modules/php5/libphp5.a
(The above line is correct! Yes, we know libphp5.a does not exist at this
stage. It isn't supposed to. It will be created.)

12. make
(you should now have an httpd binary which you can copy to your Apache
bin dir if
it is your first install then you need to "make install" as well)

13. cd ../php-5.x.y
14. cp php.ini-development /usr/local/lib/php.ini

15. You can edit /usr/local/lib/php.ini file to set PHP options.
Edit your httpd.conf or srm.conf file and add:
AddType application/x-httpd-php .php
Depending on your Apache install and Unix variant, there are many possible ways to stop
and restart the server. Below are some typical lines used in restarting the server, for
different apache/unix installations. You should replace /path/to/ with the path to these
applications on your systems.
Example #3 Example commands for restarting Apache
1. Several Linux and SysV variants:
/etc/rc.d/init.d/httpd restart

2. Using apachectl scripts:
/path/to/apachectl stop
/path/to/apachectl start

3. httpdctl and httpsdctl (Using OpenSSL), similar to apachectl:
/path/to/httpsdctl stop
/path/to/httpsdctl start

4. Using mod_ssl, or another SSL server, you may want to manually
stop and start:
/path/to/apachectl stop
/path/to/apachectl startssl
The locations of the apachectl and http(s)dctl binaries often vary. If your system has locate
or whereis or which commands, these can assist you in finding your server control
programs.
Different examples of compiling PHP for apache are as follows:
./configure --with-apxs --with-pgsql
This will create a libphp5.so shared library that is loaded into Apache using a LoadModule
line in Apache's httpd.conf file. The PostgreSQL support is embedded into this library.
./configure --with-apxs --with-pgsql=shared
This will create a libphp5.so shared library for Apache, but it will also create a pgsql.so
shared library that is loaded into PHP either by using the extension directive in php.ini file or
by loading it explicitly in a script using the dl() function.
./configure --with-apache=/path/to/apache_source --with-pgsql
This will create a libmodphp5.a library, a mod_php5.c and some accompanying files and
copy this into the src/modules/php5 directory in the Apache source tree. Then you compile
Apache using --activate-module=src/modules/php5/libphp5.a and the Apache build system
will create libphp5.a and link it statically into the httpd binary. The PostgreSQL support is
included directly into this httpd binary, so the final result here is a single httpd binary that
includes all of Apache and all of PHP.
./configure --with-apache=/path/to/apache_source --with-pgsql=shared
Same as before, except instead of including PostgreSQL support directly into the final httpd
you will get a pgsql.so shared library that you can load into PHP from either the php.ini file
or directly using dl().
When choosing to build PHP in different ways, you should consider the advantages and
drawbacks of each method. Building as a shared object will mean that you can compile
apache separately, and don't have to recompile everything as you add to, or change, PHP.
Building PHP into apache (static method) means that PHP will load and run faster. For more
information, see the Apache web page on DSO support.
Note: Apache's default httpd.conf currently ships with a section that looks like this:
User nobody
Group "#-1"
Unless you change that to "Group nogroup" or something like that ("Group daemon" is also
very common) PHP will not be able to open files.
Note: Make sure you specify the installed version of apxs when using --with-
apxs=/path/to/apxs. You must NOT use the apxs version that is in the apache sources but
the one that is actually installed on your system.
Apache 2.x on Unix systems
This section contains notes and hints specific to Apache 2.x installs of PHP on Unix systems.
Warning
We do not recommend using a threaded MPM in production with Apache 2. Use the prefork
MPM, which is the default MPM with Apache 2.0 and 2.2. For information on why, read the
related FAQ entry on using Apache2 with a threaded MPM
The Apache Documentation is the most authoritative source of information on the Apache
2.x server. More information about installation options for Apache may be found there.
The most recent version of Apache HTTP Server may be obtained from Apache download
site, and a fitting PHP version from the above mentioned places. This quick guide covers
only the basics to get started with Apache 2.x and PHP. For more information read the
Apache Documentation. The version numbers have been omitted here, to ensure the
instructions are not incorrect. In the examples below, 'NN' should be replaced with the
specific version of Apache being used.
There are currently two versions of Apache 2.x - there's 2.0 and 2.2. While there are
various reasons for choosing each, 2.2 is the current latest version, and the one that is
recommended, if that option is available to you. However, the instructions here will work for
either 2.0 or 2.2.
1. Obtain the Apache HTTP server from the location listed above, and unpack it:
2. gzip -d httpd-2_x_NN.tar.gz
3. tar -xf httpd-2_x_NN.tar
4. Likewise, obtain and unpack the PHP source:
5. gunzip php-NN.tar.gz
6. tar -xf php-NN.tar
7. Build and install Apache. Consult the Apache install documentation for more details
on building Apache.
8. cd httpd-2_x_NN
9. ./configure --enable-so
10. make
11. make install
12. Now you have Apache 2.x.NN available under /usr/local/apache2, configured with
loadable module support and the standard MPM prefork. To test the installation use
your normal procedure for starting the Apache server, e.g.:
13. /usr/local/apache2/bin/apachectl start
and stop the server to go on with the configuration for PHP:
/usr/local/apache2/bin/apachectl stop
14. Now, configure and build PHP. This is where you customize PHP with various options,
like which extensions will be enabled. Run ./configure --help for a list of available
options. In our example we'll do a simple configure with Apache 2 and MySQL
support.
If you built Apache from source, as described above, the below example will match
your path for apxs, but if you installed Apache some other way, you'll need to adjust
the path to apxs accordingly. Note that some distros may rename apxs to apxs2.
cd ../php-NN
./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql
make
make install
If you decide to change your configure options after installation, you'll need to re-run
the configure, make, and make install steps. You only need to restart apache for the
new module to take effect. A recompile of Apache is not needed.
Note that unless told otherwise, 'make install' will also install PEAR, various PHP tools
such as phpize, install the PHP CLI, and more.
15. Setup your php.ini
16. cp php.ini-development /usr/local/lib/php.ini
You may edit your .ini file to set PHP options. If you prefer having php.ini in another
location, use --with-config-file-path=/some/path in step 5.
If you instead choose php.ini-production, be certain to read the list of changes
within, as they affect how PHP behaves.
17. Edit your httpd.conf to load the PHP module. The path on the right hand side of the
LoadModule statement must point to the path of the PHP module on your system.
The make install from above may have already added this for you, but be sure to
check.
LoadModule php5_module modules/libphp5.so
18. Tell Apache to parse certain extensions as PHP. For example, let's have Apache parse
.php files as PHP. Instead of only using the Apache AddType directive, we want to
avoid potentially dangerous uploads and created files such as exploit.php.jpg from
being executed as PHP. Using this example, you could have any extension(s) parse
as PHP by simply adding them. We'll add .php to demonstrate.
19. <FilesMatch \.php$>
20. SetHandler application/x-httpd-php
</FilesMatch>
Or, if we wanted to allow .php, .php2, .php3, .php4, .php5, .php6, and .phtml files to
be executed as PHP, but nothing else, we'd use this:
<FilesMatch "\.ph(p[2-6]?|tml)$">
SetHandler application/x-httpd-php
</FilesMatch>
And to allow .phps files to be handled by the php source filter, and displayed as
syntax-highlighted source code, use this:
<FilesMatch "\.phps$">
SetHandler application/x-httpd-php-source
</FilesMatch>
mod_rewrite may be used To allow any arbitrary .php file to be displayed as syntax-
highlighted source code, without having to rename or copy it to a .phps file:
RewriteEngine On
RewriteRule (.*\.php)s$ $1 [H=application/x-httpd-php-source]
The php source filter should not be enabled on production systems, where it may
expose confidential or otherwise sensitive information embedded in source code.
21. Use your normal procedure for starting the Apache server, e.g.:
22. /usr/local/apache2/bin/apachectl start
OR
service httpd restart
Following the steps above you will have a running Apache2 web server with support for PHP
as a SAPI module. Of course there are many more configuration options available Apache
and PHP. For more information type ./configure --help in the corresponding source tree.
Apache may be built multithreaded by selecting the worker MPM, rather than the standard
prefork MPM, when Apache is built. This is done by adding the following option to the
argument passed to ./configure, in step 3 above:

--with-mpm=worker
This should not be undertaken without being aware of the consequences of this decision,
and having at least a fair understanding of the implications. The Apache documentation
regarding MPM-Modules discusses MPMs in a great deal more detail.
Note: The Apache MultiViews FAQ discusses using multiviews with PHP.
Note: To build a multithreaded version of Apache, the target system must support threads.
In this case, PHP should also be built with experimental Zend Thread Safety (ZTS). Under
this configuration, not all extensions will be available. The recommended setup is to build
Apache with the default prefork MPM-Module.



Lighttpd 1.4 on Unix systems Apache 1.3.x on Unix systems

Last updated: Fri, 11 Jun 2010

User Contributed Notes
Apache 2.x on Unix systems
nmmm at nmmm dot nu
09-Aug-2009 08:13
When I upgrade to apache 2.2, this:

AddType application/x-httpd-php .php5
AddType application/x-httpd-php .php42
AddType application/x-httpd-php .php4
AddType application/x-httpd-php .php3
AddType application/x-httpd-php .php
AddType application/x-httpd-php .phtm
AddType application/x-httpd-php .phtml
AddType application/x-httpd-php .asp

...does not worked for me, so I did this:

<FilesMatch "\.(php*|phtm|phtml|asp|aspx)$">
SetHandler application/x-httpd-php
</FilesMatch>

Another interesting point with Apache 2.2 is following.
Let suppose we installed PHP as module. But for some directory, we need to use PHP as
CGI (probably because of custom configuration). This can be done using:

<FilesMatch "\.(php*|phtm|phtml|asp|aspx)$">
SetHandler none
</FilesMatch>

AddType application/x-httpd-php-custom .php
Action application/x-httpd-php-custom /cgi-bin/php-huge

Note type must be different than "application/x-httpd-php" and also you need to
deactivate the handler on sertain extention. You can do mixed configuration:

<FilesMatch "\.(php)$">
SetHandler none
</FilesMatch>

AddType application/x-httpd-php-custom .php
Action application/x-httpd-php-custom /cgi-bin/php-huge

in such case files like *.php5 and so on will be parsed via module, but *.php will go
to php-huge executable.
Anonymous
17-Jun-2009 05:58
Solution for fedora is yum install mysql-devel. Then set --with-
mysql=/usr/include/mysql/
monguesto
peep at imtarget dot identicloak dot com
24-Apr-2009 05:09
Configuration notes for cent5.2, April 2009.
----------------------------------------------------
Note: I'll walk you through my steps, so you can do it custom yerself. It's possible
that I am an idiot and there are much easier ways to do this. But this worked for me.
Also , you could just use my configure script and yum command line and probably have
it work okay.

Scenario
----------
I'm setting this up for a fairly typical drupal install, with a mysql backend. I set
up the dev server with the php package from the cent yum repo, and the customer ran
Drupal with that for a while, but now wants a more current PHP than the cent package
provides.

my approach for determining required modules
------------------------------------
1. get the list of the modules
$ php -m | grep -v -e Modules] -e ^$ > php-default-modules
2. create the configure script
$ for i in $(cat php-default-modules); do echo -n "--with-$i ">> phpconfigure.sh
;done
3. run the configure script, and iterate through the "Configure script errors"
section below until it completes properly
4. at the end of the output, look for a notice of unknown options

Notice: Following unknown configure options were used:
--with-date
--with-gum-disease

Check './configure --help' for available options

5. as suggested, execute './configure --help' and correct the options. The "for"
command above indiscriminately inserts "--with-" for all modules, but bundled modules
may require "--enable-" instead, so mostly you'll be changing those. For modules that
are enabled by default you'll need to remove the entry.

6. Add anything else you personally want or need. I like to add "--enable-safe-mode".

I configured with the following command line:

php-5.2.9]$ ./configure --with-mcrypt --with-mhash --with-bz2 --enable-calendar --
with-curl --enable-dbase --enable-exif --enable-ftp --with-gd --with-gettext --with-
gmp --with-iconv --enable-mbstring --with-mime_magic --with-mysql --with-mysqli --
with-openssl --enable-pcntl --with-pdo_mysql --with-pdo_sqlite --with-pspell --
enable-shmop --enable-sockets --enable-sysvmsg --enable-sysvsem --enable-sysvshm --
enable-wddx --with-zlib --enable-safe-mode

as such, i needed a number of packages installed. Now I haven't tracked additional
packages over base--there may be required packages that I happened to have installed
for other things. But this is a pretty good list, i reckon:

php-5.2.9]$ sudo yum install mcrypt libmcrypt mhash libmhash libxml2-devel openssl-
devel bzip2-devel curl-devel libjpeg-devel libpng-devel gmp-devel mysql-devel aspell-
devel zlib zlib-devel

Configure script errors
--------------------------------------------
In my experience, these errors have been due (with any software, PHP included) mostly
to missing development packages, which contain the libraries and headers needed to
compile support for that library's function into the application.

This becomes a process of:
-executing the ./configure script and looking at the error
-installing the devel package providing the resource referenced by the error (google
using the error as search term as needed)
-repeat until the ./configure script makes it through without error

Upshot: identify the software referenced by the error, and install it.

Example
-----------
Example error:
configure: error: Cannot find OpenSSL's <evp.h>
Example explanation
configure is looking for a header (and probably a lot of other stuff) from a
missing openssl package.
Example solution:
php-5.2.9]$sudo yum install openssl-devel

Compiling (and testing and submitting)
----------------------------------------------
with ./configure working, you're ready to compile. I think it's important to test and
submit the tests to the developers, you do what you want.

$ make;make test

Installing
-------------
$sudo make install

(be sure you, heh, have the system php removed before you do this step. seriously)

Best of luck!
Tom420.Duhamel
02-Feb-2009 01:31
I have successfully installed Apache 2.2.11 and PHP 5.2.8 under Red Hat 9.0 on a
Pentium 166 with 32 MB of RAM.

While I used RH9, the worst possible case, these notes are probably good for RH-based
distributions too (Red Hat Enterprise, Fedora, CentOS...)

If you want to install MySQL, it needs to be installed before PHP because PHP
requires some libraries be available.

One think important when picking up a binary distribution of MySQL is to download all
four packages: MySQL-server, MySQL-devel, MySQL-client and MySQL-shared. Note: The
MySQL was bundled with PHP 4 but is not anymore in PHP 5.

Then you need to install Apache before PHP, because again PHP needs some libraries be
available. I installed Apache 2 from source, using the very last version available,
which is 2.2.11.

I installed PHP 5.2.8 from source. Here, I had a number of problems, but none which I
could not resolve easily, some of them with a little help from different forums I
found through Google.

Rembember: When it says you need a package named xyz and you notice there is also one
named xyz-devel, grab it.

Most of the packages I got from:
http://legacy.redhat.com/pub/redhat/linux/9/en/os/i386/RedHat/RPMS/
A similar page exists for other versions of Red Hat
and:
http://rpmfind.net/
This site has an updated version of some of the packages. Make sure to use only the
one labeled for you version (in my case, Red Hat 9.0) or it will not likely work.

You already have glibc and glibc-common installed, but you need to get glibc-devel
and glibc-kernheaders. Make sure to match glibc's version (rpm -q glibc). Note: When
it says kernel-header is a required dependency, that's glibc-kernheader (not kernel-
source). You will also need binutils (no need to match the version), and gcc and cpp
(version must match).

You need zlib-devel (zlib is probably already installed, match the version you have).

If you install the GD extension, the actual library is already bundled with PHP 5
(use that one, they have done some changes in there, so don't upgrade), but you will
need to install libpng and libpng-devel (match version, or disable in configure if
you don't want) and libjpeg (no -devel with that one).

You will also need libxml2. Now there were a problem, because PHP requires libxml2 be
2.6 or greater, but Red Hat only supplied 2.5.4-1 for RH9 (if you have a more recent
distro, you might be more lucky). After looking for a while, I decided to grab the
source code for the most recent distribution at the official website
(http://xmlsoft.org/) and compiled.

Hope my post is useful to someone. Please, share your experience when
compiling/installing for your particular platform and setup. Remember how hard it's
been for you the very first time. I confess, my very first server installation took
me nearly a week and I was glad others helped me.
nabil at world dot com
24-May-2008 02:27
I couldn't start Apache2 after installing PHP5 in archlinux, I got this error :

Cannot load /.../libphp5.so into server: /.../libphp5.so: undefined symbol: _efree

The solution was "make clean" on the PHP5 source directory, then ./configure, make &
make install again.
chris@gerlt -dot- net
22-Sep-2006 01:33
Install issues on Redhat, specifically RHEL4 with php4 already installed:

I discovered that there was an issue caused by redhat loading php4 in another file
seperate from the httpd.conf file! This took me hours to discover. Make sure you
know if the apache config file (httpd.conf) is loading configurations from a
directory (or another file(s)) as well. If so, look in there for any php module
loading which could conflict with the new module you are compiling/installing.
susie91
28-Aug-2006 03:34
for slackware 10.2 users with apache2, mysql5, and trying to install php5:

when following the directions above, after this step:

./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql

i kept getting this error:
"Unable to find MySql header files...."

the only way i could get php5 with mysql support was to compile MySql5 from source,
and not use the binary as the mysql site recommends.

then i was able to ./configure successfully, but for some reason php was configured
to compile the CGI version.

so, had to use this ./configure line:

./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql -
-disable-cgi

alternatively, you could install php4 which does bundle the MySql client files.
jaya
05-Jul-2006 06:41
PHP 5.1.4 INSTALLATION on Solaris 9 (Sparc)

Solaris9 Packages Installed:

Verify required package installation:
root# pkginfo SUNWbtool SUNWsprot SUNWtoo SUNWhea SUNWarc \
SUNWlibm SUNWlibms SUNWdfbh SUNWxglh SUNWcg6h

Uninstall Default Apache Packages:
root# /etc/init.d/apache stop
root# pkginfo |grep Apache
root# pkgrm SUNWaclg SUNWapchd SUNWapchr SUNWapchu

Create installation Directory:
root# mkdir /phpdata/

Download Required Packages from Sunfreeware:

Install libiconv-1.8 and gcc3.3.2 packages
root# pkgadd -d ./libiconv-1.8-sol9-sparc-local
root# pkgadd -d ./gcc-3.3.2-sol9-sparc-local

set LD_LIBRARY_PATH, CC and PATH variables
root# LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib/sparcv9/:\
/usr/lib:/usr/openwin/lib:/opt/local/lib:/usr/local/ssl/lib:\
/usr/local/apr/lib:/opt/mysql/mysql/lib
root# CC=gcc
root# PATH=$PATH:/usr/ucb:/usr/local/bin/
root# export LD_LIBRARY_PATH CC PATH

Install apr-1.2.2 and aprutil-1.2.2 packages

root# gzcat apr-1.2.2.tar.gz |tar xvf -
root# cd apr-1.2.2
root# ./configure
root# make
root# make install
root# cd ..

root# gzcat aprutil-1.2.2.tar.gz |tar xvf -
root# cd apr-util-1.2.2/
root# ./configure --with-apr=/usr/local/apr/
root# make
root# make install

Install gawk-3.1.4, expat-1.95.5, db-4.2.52.NC,
gdbm-1.8.3, libgcc-3.3 and libxml2-2.6.16 packages
root# cd ..
root# pkgadd -d ./gawk-3.1.4-sol9-sparc-local
root# pkgadd -d ./expat-1.95.5-sol9-sparc-local
root# pkgadd -d ./db-4.2.52.NC-sol9-sparc-local
root# pkgadd -d ./gdbm-1.8.3-sol9-sparc-local
root# pkgadd -d ./libgcc-3.3-sol9-sparc-local
root# pkgadd -d ./libxml2-2.6.16-sol9-sparc-local

Install GNU make package
root# gzcat make-3.81.tar.gz |tar xvf -
root# cd make-3.81
root# ./configure
root# make
root# make install
root# cd ..

Install mysql-standard-5.0.22 package
Search for user mysql
root# grep mysql /etc/passwd
root# grep mysql /etc/group

If not found create user and group mysql
root# groupadd mysql
root# useradd -G mysql mysql
root# pkgadd -d ./mysql-standard-5.0.22-solaris9-sparc.pkg.gz

Install openssl-0.9.7g package
root# gzcat openssl-0.9.7g.tar.gz |tar xvf -
root# cd openssl-0.9.7g
root# ./config shared
root# make
root# make install
root# cd ..

Install Apache2 package
root# gzcat httpd-2.2.0.tar.gz |tar xvf -
root# cd httpd-2.2.0
root# ./configure --enable-so
root# /usr/local/bin/make
root# /usr/local/bin/make install
root# cd ..

Install php-5.1.4 package
root# gzcat php-5.1.4.tar.gz |tar xvf -
root# cd php-5.1.4
root# ./configure --with-apxs2=/usr/local/apache2/bin/apxs\
--with-ldap --with-mysql=/opt/mysql/mysql/
root# /usr/local/bin/make
root# /usr/local/bin/make install
root# cp php.ini-dist /usr/local/lib/php.ini

Edit httpd.conf to load the PHP module
and to parse certain extensions as PHP
root# vi /usr/local/apache2/conf/httpd.conf
LoadModule php5_module modules/libphp5.so
AddType application/x-httpd-php .php .phtml

Start Apache
root# /usr/local/apache2/bin/apachectl start

Add environmental variables below HTTPD
root# vi /usr/local/apache2/bin/apachectl
LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib/sparcv9/:
/usr/lib:/usr/openwin/lib:/opt/local/lib:/usr/local/ssl/lib:
/usr/local/apr/lib:/opt/mysql/mysql/lib
PATH=/bin:/sbin:/usr/ccs/bin:/usr/sbin:/usr/openwin/bin:\
/usr/ucb:/usr/local/bin/
export LD_LIBRARY_PATH PATH

Create Apache Startup Script
felixcca at yahoo dot ca
30-Mar-2006 02:13
I've (painfully) discovered that installing PHP5 with "make install" under SuSe 9.2
is NOT a good idea.
http://www.aditus.nu/jpgraph/apache2suse.php
This page explains how to install it without breaking everything that's php-related
in the Apache2 configuration. Its first purpose, though, is to show how to have php 4
and 5 to cohabit properly.
frank@ethisoft
28-Sep-2005 09:30
Using Apache2 & PHP5 work perfectly fine & safe together.
- all core modules are safe in Zend Engine 2
- third-party-libraries should be avoided
- semaphores and shared memory enables you to ensure yourself that your
application/website is thread-safe also with non-thread-safe PHP modules!
happyboy at php dot org
03-Aug-2005 11:30
FILE TRUNCATED!!

during the make process should u receive an error declaring ext/ctype/ctype.lo (or
another file) is truncated then you need to 'make clean' prior to a healthy 'make'
and 'make install.'

looking into your ext/ directory you may find the offensive file to be 1 byte long.
mihai dot sandu at gtstelecom dot ro
28-Feb-2005 01:22
For the SuSE9.2 install of PHP5.
First:
If building on a x64 platform, please set LDFLAGS="-L/usr/lib64" before configure.
As for install, it suffices to go to /etc/apache2 and:
ln -s sysconfig.d/loadmodule.conf httpd2-prefork.conf
and then make install
neil
10-Feb-2005 10:21
To install mysql and mysqli with PHP5 do the following:

after doing:

./configure --with-mysql=/path/to/mysql_config --with-mysqli=/path/to/mysql_config

do this:

"
if you want to use both the old mysql and the new mysqli interface, load the
Makefile into your editor and search for the line beginning with EXTRA_LIBS; it
includes -lmysqlclient twice; remove the second instance
"

then you can:

make
make install

.....
Pleasse note: you must have mysql-dev installed (RPM or source) or you will not have
the mysql_config file at all. The standard, server, and client installations of
MySQL do not include it. I read somewhere that the mysql and mysqli paths must be
identical.

Quoted from Michael Kofler at the following link:
http://www.kofler.cc/forum/forumthread.php?rootID=3571
Dan Scott (dan dot scott at acm dot org)
20-Jan-2005 04:36
Building PHP 5.x with Apache2 on SuSE Professional 9.1/9.2

SuSE uses a rather fragmented set of Apache configuration files stored in
/etc/apache2/. When you configure PHP 5.x with:

$ ./configure --with-apxs2=/usr/sbin/apxs2
$ make

everything builds just fine; but when you issue:
$ su -c "make install"

the unconventional Apache conf file layout confuses the install-sapi section of the
Makefile and the process halts with the following error:

apxs:Error: Config file /etc/apache2/httpd2-prefork.conf not found.
make: *** [install-sapi] Error 1

At this point only the PHP SAPI library has been copied into place; the rest of the
files (like PEAR scripts, PHP-CLI, etc) have not been installed. But never fear! You
can overcome this problem with the following steps:

1. Edit Makefile and change the following line to remove "install-sapi":
install_targets = install-sapi install-cli install-pear install-build install-headers
install-programs

2. Issue the make install command again:
$ su -c "make install"

3. Add the PHP module & type instructions to the Apache configuration. As root,
create a new file, /etc/apache2/conf.d/php5.conf that contains the following lines:

LoadModule php5_module /usr/lib/apache2/libphp5.so
AddType application/x-httpd-php php

--- And that's it. Everything else is just as the documentation suggests it should
be.
praveen dot k at masconit dot com
15-Nov-2004 09:38
Hi too had same problem with multiview like when i execute http://huey/admin/test.php
it used to compile but when i use http://huey/admin/test it wouldnt recognise it as
php file... i worked it out with the addhandler method and AddType in different line
and setting multiview for directive

"multiviews Options Indexes FollowSymLinks MultiViews"

the directives u can set it to root directory so now when u type pn test it will
search in precendence for test.php, test.html if any .....

its working for me with apache2.0.47 and php 4.3.9 on solaris

praveen
Lighttpd 1.4 on Unix systems
This section contains notes and hints specific to Lighttpd 1.4 installs of PHP on Unix
systems.
Please use the Lighttpd trac to learn how to install Lighttpd properly before continuing.
Fastcgi is the preferred SAPI to connect PHP and Lighttpd. Fastcgi is automagically enabled
in php-cgi in PHP 5.3, but for older versions configure PHP with --enable-fastcgi. To confirm
that PHP has fastcgi enabled, php -v should contain PHP 5.2.5 (cgi-fcgi) Before PHP 5.2.3,
fastcgi was enabled on the php binary (there was no php-cgi).
Letting Lighttpd spawn php processes
To configure Lighttpd to connect to php and spawn fastcgi processes, edit lighttpd.conf.
Sockets are preferred to connect to fastcgi processes on the local system.
Example #1 Partial lighttpd.conf
server.modules += ( "mod_fastcgi" )

fastcgi.server = ( ".php" =>
((
"socket" => "/tmp/php.socket",
"bin-path" => "/usr/local/bin/php-cgi",
"bin-environment" => (
"PHP_FCGI_CHILDREN" => "16",
"PHP_FCGI_MAX_REQUESTS" => "10000"
),
"min-procs" => 1,
"max-procs" => 1,
"idle-timeout" => 20
))
)
The bin-path directive allows lighttpd to spawn fastcgi processes dynamically. PHP will
spawn children according to the PHP_FCGI_CHILDREN environment variable. The "bin-
environment" directive sets the environment for the spawned processes. PHP will kill a child
process after the number of requests specified by PHP_FCGI_MAX_REQUESTS is reached.
The directives "min-procs" and "max-procs" should generally be avoided with PHP. PHP
manages its own children and opcode caches like APC will only share among children
managed by PHP. If "min-procs" is set to something greater than 1, the total number of php
responders will be multiplied PHP_FCGI_CHILDREN (2 min-procs * 16 children gives 32
responders).
Spawning with spawn-fcgi
Lighttpd provides a program called spawn-fcgi to ease the process of spawning fastcgi
processes easier.
Spawning php-cgi
It is possible to spawn processes without spawn-fcgi, though a bit of heavy-lifting is
required. Setting the PHP_FCGI_CHILDREN environment var controls how many children
PHP will spawn to handle incoming requests. Setting PHP_FCGI_MAX_REQUESTS will
determine how long (in requests) each child will live. Here's a simple bash script to help
spawn php responders.
Example #2 Spawning FastCGI Responders
#!/bin/sh

# Location of the php-cgi binary
PHP=/usr/local/bin/php-cgi

# PID File location
PHP_PID=/tmp/php.pid

# Binding to an address
#FCGI_BIND_ADDRESS=10.0.1.1:10000
# Binding to a domain socket
FCGI_BIND_ADDRESS=/tmp/php.sock

PHP_FCGI_CHILDREN=16
PHP_FCGI_MAX_REQUESTS=10000

env -i PHP_FCGI_CHILDREN=$PHP_FCGI_CHILDREN \
PHP_FCGI_MAX_REQUESTS=$PHP_FCGI_MAX_REQUESTS \
$PHP -b $FCGI_BIND_ADDRESS &

echo $! > "$PHP_PID"

Connecting to remote FCGI instances
Fastcgi instances can be spawned on multiple remote machines in order to scale
applications.
Example #3 Connecting to remote php-fastcgi instances
fastcgi.server = ( ".php" =>
(( "host" => "10.0.0.2", "port" => 1030 ),
( "host" => "10.0.0.3", "port" => 1030 ))
)

User Contributed Notes
Lighttpd 1.4 on Unix systems
Ant P.
10-Jun-2010 02:09
If PHP_FCGI_MAX_REQUESTS isn't given, the default value is 500.
askroot at gmail dot com
07-Apr-2009 09:32
<-- Start -->
#!/bin/bash

/usr/bin/spawn-fcgi \
-s /var/run/lighttpd/php-fastcgi-kr.php.net.socket \
-f "/usr/bin/php-cgi -c /etc/php-kr.php.net.ini" \
-u lighttpd \
-g lighttpd \
-C 4 \
-P /var/run/spawn-fcgi-kr.php.net.pid \
-F 12
<-- End -->

lighttpd 1.5 - Config
<-- Start -->
$HTTP["host"] =~ "^(www.)?kr.php.net" {
server.document-root = "/home/kr.php.net"
accesslog.filename = "/var/log/lighttpd/kr.php.net-access_log"
index-file.names = ( "index.php", "index.html", "index.htm" )
url.access-deny = ( "~", ".inc", ".htaccess" )
server.error-handler-404 = "/error.php"
alias.url = (
"/FAQ.php" => "/home/kr.php.net/manual/kr/faq.php",
"/stats" => "/home/kr.php.net-stats"
)
setenv.add-environment = (
"MIRROR_LANGUAGE" => "kr",
"MIRROR_STATS" => "1"
)
$HTTP["url"] =~ "\.php$" {
proxy-core.balancer = "round-robin"
proxy-core.allow-x-sendfile = "enable"
proxy-core.protocol = "fastcgi"
proxy-core.backends = ( "unix:/var/run/lighttpd/php-fastcgi-
kr.php.net.socket" )
proxy-core.max-pool-size = 16
}
}
<-- End -->
Sun, iPlanet and Netscape servers on Sun Solaris
This section contains notes and hints specific to Sun Java System Web Server, Sun ONE
Web Server, iPlanet and Netscape server installs of PHP on Sun Solaris.
From PHP 4.3.3 on you can use PHP scripts with the NSAPI module to generate custom
directory listings and error pages. Additional functions for Apache compatibility are also
available. For support in current web servers read the note about subrequests.
You can find more information about setting up PHP for the Netscape Enterprise Server
(NES) here: http://benoit.noss.free.fr/php/install-php4.html
To build PHP with Sun JSWS/Sun ONE WS/iPlanet/Netscape web servers, enter the proper
install directory for the --with-nsapi=[DIR] option. The default directory is usually
/opt/netscape/suitespot/. Please also read /php-xxx-version/sapi/nsapi/nsapi-readme.txt.
1. Install the following packages from http://www.sunfreeware.com/ or another
download site:
autoconf-2.13
automake-1.4
bison-1_25-sol26-sparc-local
flex-2_5_4a-sol26-sparc-local
gcc-2_95_2-sol26-sparc-local
gzip-1.2.4-sol26-sparc-local
m4-1_4-sol26-sparc-local
make-3_76_1-sol26-sparc-local
mysql-3.23.24-beta (if you want mysql support)
perl-5_005_03-sol26-sparc-local
tar-1.13 (GNU tar)
2. Make sure your path includes the proper directories
PATH=.:/usr/local/bin:/usr/sbin:/usr/bin:/usr/ccs/bin and make it available to your
system export PATH.
3. gunzip php-x.x.x.tar.gz (if you have a .gz dist, otherwise go to 4).
4. tar xvf php-x.x.x.tar
5. Change to your extracted PHP directory: cd ../php-x.x.x
6. For the following step, make sure /opt/netscape/suitespot/ is where your netscape
server is installed. Otherwise, change to the correct path and run:
7. ./configure --with-mysql=/usr/local/mysql \
8. --with-nsapi=/opt/netscape/suitespot/ \
--enable-libgcc
9. Run make followed by make install.
After performing the base install and reading the appropriate readme file, you may need to
perform some additional configuration steps.
Configuration Instructions for Sun/iPlanet/Netscape
Firstly you may need to add some paths to the LD_LIBRARY_PATH environment for the
server to find all the shared libs. This can best done in the start script for your web server.
The start script is often located in: /path/to/server/https-servername/start. You may also
need to edit the configuration files that are located in: /path/to/server/https-
servername/config/.
1. Add the following line to mime.types (you can do that by the administration server):
2. type=magnus-internal/x-httpd-php exts=php
3. Edit magnus.conf (for servers >= 6) or obj.conf (for servers < 6) and add the
following, shlib will vary depending on your system, it will be something like
/opt/netscape/suitespot/bin/libphp4.so. You should place the following lines after
mime types init.
4. Init fn="load-modules" funcs="php4_init,php4_execute,php4_auth_trans"
shlib="/opt/netscape/suitespot/bin/libphp4.so"
5. Init fn="php4_init" LateInit="yes" errorString="Failed to initialize PHP!"
[php_ini="/path/to/php.ini"]
(PHP >= 4.3.3) The php_ini parameter is optional but with it you can place your
php.ini in your web server config directory.
6. Configure the default object in obj.conf (for virtual server classes [version 6.0+] in
their vserver.obj.conf):
7. <Object name="default">
8. .
9. .
10. .
11. .#NOTE this next line should happen after all 'ObjectType' and before all
'AddLog' lines
12. Service fn="php4_execute" type="magnus-internal/x-httpd-php" [inikey=value
inikey=value ...]
13. .
14. .
15. </Object>
(PHP >= 4.3.3) As additional parameters you can add some special php.ini-values,
for example you can set a docroot="/path/to/docroot" specific to the context
php4_execute is called. For boolean ini-keys please use 0/1 as value, not
"On","Off",... (this will not work correctly), e.g. zlib.output_compression=1 instead of
zlib.output_compression="On"
16. This is only needed if you want to configure a directory that only consists of PHP
scripts (same like a cgi-bin directory):
17. <Object name="x-httpd-php">
18. ObjectType fn="force-type" type="magnus-internal/x-httpd-php"
19. Service fn=php4_execute [inikey=value inikey=value ...]
20. </Object>
After that you can configure a directory in the Administration server and assign it the
style x-httpd-php. All files in it will get executed as PHP. This is nice to hide PHP
usage by renaming files to .html.
21. Setup of authentication: PHP authentication cannot be used with any other
authentication. ALL AUTHENTICATION IS PASSED TO YOUR PHP SCRIPT. To
configure PHP Authentication for the entire server, add the following line to your
default object:
22. <Object name="default">
23. AuthTrans fn=php4_auth_trans
24. .
25. .
26. .
27. </Object>
28. To use PHP Authentication on a single directory, add the following:
29. <Object ppath="d:\path\to\authenticated\dir\*">
30. AuthTrans fn=php4_auth_trans
31. </Object>
Note: The stacksize that PHP uses depends on the configuration of the web server. If you
get crashes with very large PHP scripts, it is recommended to raise it with the Admin Server
(in the section "MAGNUS EDITOR").
CGI environment and recommended modifications in php.ini
Important when writing PHP scripts is the fact that Sun JSWS/Sun ONE
WS/iPlanet/Netscape is a multithreaded web server. Because of that all requests are
running in the same process space (the space of the web server itself) and this space has
only one environment. If you want to get CGI variables like PATH_INFO, HTTP_HOST etc. it
is not the correct way to try this in the old PHP way with getenv() or a similar way (register
globals to environment, $_ENV). You would only get the environment of the running web
server without any valid CGI variables!
Note: Why are there (invalid) CGI variables in the environment?
Answer: This is because you started the web server process from the admin server which
runs the startup script of the web server, you wanted to start, as a CGI script (a CGI script
inside of the admin server!). This is why the environment of the started web server has
some CGI environment variables in it. You can test this by starting the web server not from
the administration server. Use the command line as root user and start it manually - you
will see there are no CGI-like environment variables.
Simply change your scripts to get CGI variables in the correct way for PHP 4.x by using the
superglobal $_SERVER. If you have older scripts which use $HTTP_HOST, etc., you should
turn on register_globals in php.ini and change the variable order too (important: remove "E"
from it, because you do not need the environment here):
variables_order = "GPCS"
register_globals = On
Special use for error pages or self-made directory listings (PHP >= 4.3.3)
You can use PHP to generate the error pages for "404 Not Found" or similar. Add the
following line to the object in obj.conf for every error page you want to overwrite:
Error fn="php4_execute" code=XXX script="/path/to/script.php" [inikey=value
inikey=value...]
where XXX is the HTTP error code. Please delete any other Error directives which could
interfere with yours. If you want to place a page for all errors that could exist, leave the
code parameter out. Your script can get the HTTP status code with
$_SERVER['ERROR_TYPE'].
Another possibility is to generate self-made directory listings. Just create a PHP script which
displays a directory listing and replace the corresponding default Service line for
type="magnus-internal/directory" in obj.conf with the following:
Service fn="php4_execute" type="magnus-internal/directory"
script="/path/to/script.php" [inikey=value inikey=value...]
For both error and directory listing pages the original URI and translated URI are in the
variables $_SERVER['PATH_INFO'] and $_SERVER['PATH_TRANSLATED'].
Note about nsapi_virtual() and subrequests (PHP >= 4.3.3)
The NSAPI module now supports the nsapi_virtual() function (alias: virtual()) to make
subrequests on the web server and insert the result in the web page. This function uses
some undocumented features from the NSAPI library. On Unix the module automatically
looks for the needed functions and uses them if available. If not, nsapi_virtual() is disabled.
Note: But be warned: Support for nsapi_virtual() is EXPERIMENTAL!!!



CGI and command line setups Lighttpd 1.4 on Unix systems

Last updated: Fri, 11 Jun 2010

User Contributed Notes
Sun, iPlanet and Netscape servers on Sun Solaris
Brian
07-Apr-2008 02:15
For me at least, this part of the second line in the magnus.conf is not optional:

Init fn="php5_init" LateInit="yes"

Without it, the web server crashes when trying to execute php files
yairl at savion dot huji dot ac dot il
29-Nov-2007 01:01
For installation instruction for the new Sun One 7 webserver you must read the
following doc. PHP 5.2.X will work fine, old version needs some changes.

http://developers.sun.com/webtier/reference/techart/php2.html
ericbackstrom at hotmail dot com
27-Mar-2006 11:09
Using gcc 3.3 I had problems compiling PHP for 64 bits, I had to replace mysql/64
bits with mysql/32 bits (Solaris cannot mix 32 bits and 64 bits libraries), so I
specified the following compiler flag:

CFLAGS="-m32";export CFLAGS;

I also had problems with PHP 5.1.2 in sapi/nsapi/nsapi.c source code, It had
incorrect comments and file paths :S

When trying to install PHP with mysql support I found I had these problems too:
http://bugs.php.net/bug.php?id=34516... So don't mix sun ld and gcc ld because you
will get into troubles. I built mysql libraries myself in a separated directory.

And don't forget to set your LD_LIBRARY_PATH to something like:

LD_LIBRARY_PATH="/usr/local/lib:/usr/lib"
vijay
13-Mar-2006 02:48
If I start my iPlanet (v6.0 SP2) webserver with PHP5.1.2 i get this message every 1/2
sec in my error log....

[12/Mar/2006:11:01:48] failure (15936): Failed to read kernel statistics structures
(No such device or address)

This happens only if I start my server loading PHP module. FYI - When I configured my
php I had it use oracle instant client libraries.

One fix I found was to comment out this line in my magnus.conf file.

#Init fn="stats-init" profiling="on"

But I don't think i can do this on my prodcution machine. Any ideas to come around
this issue?

Thanks
Vijay
jedokahn at yahoo dot com at
23-Nov-2004 08:50
I noted and installed *all* pkgs required to compile PHP5 but kept getting an error
on compile when it attempted to test the gcc compiler. The /usr/ccs/bin and all the
$PATH requirements were ALL there....why the error? I tried running gcc from the
command prompt and got a "gcc: fatal: libiconv.so.2: open failed: "....DUH I needed
to install the libiconv pkg from sunfreeware.com for gcc compiler to work. Just a
small bonehead maneuver, but I thought I would add it just in case someone else ran
into the particular problem.
masochisthalo at yahoo dot com
23-Aug-2004 09:28
Title: Barebones PHP Installation on Sun One Web Server 6.1 for JDS2
Author: Hijinio Reynoso Jr.
Last Updated: August 23, 2004
Summary: If you have installed Sun One Web Server 6.1 on the JDS (aka Java Desktop
System from Sun), this will help you get PHP installed on it (without XML and MySQL
support.) In any case, this should get you started which is better than not having
it installed at all. These directions were based mainly on those available from
PHP.net, but updated to meet the needs of this specific configuration.

Instructions
----------------------------
0. Make sure your web server isn't running and ensure that all JDS developer packages
are installed; to be safe, I always ensure that all developer packages are available
via Applications > System Tools > Administration > Software Installer

1. Download http://us3.php.net/get/php-5.0.1.tar.bz2/from/a/mirror and extract into
the directory of your choice. (5.0.1 was the only version I could get to make install
correctly)

2. CD into the extracted PHP directory and type:
> ./configure --with-nsapi=/opt/SUNWwbsvr --enable-libgcc --disable-libxml
(Your web server directory may vary from the above's default.)

3. Once it's done configuring (and it should be successful should you have all the
proper packages), type:
> make

4. When its done compiling, it's time to install as root:
# make install

5. Now, configuration of your web server begins:
# cd /opt/SUNWwbsvr/https-[yourWebServer]/config

6. vi mime.types (or other editor) to add this line into it:
type=magnus-internal/x-httpd-php exts=php

7. vi magnus.conf to add the following 2 lines to end of it: (NOTE: the 2nd line
could be optional)
Init fn="load-modules" funcs="php5_init,php5_execute,php5_auth_trans"
shlib="/opt/SUNWwbsvr/bin/libphp5.so"
Init fn="php5_init" LateInit="yes" errorString="Failed to initialize PHP!"
[php_ini="/path/to/php.ini"]

8. vi obj.conf to add the following line to <Object name="default">. Make sure this
happens after all "ObjectType" entries and before any "AddLog" entries: (NOTE: for
virtual servers, edit vserver.obj.conf)
Service fn="php5_execute" type="magnus-internal/x-httpd-php" [inikey=value
inikey=value ...]

9. Now, start up your web server. Also, make sure to log into the admin server and
click the "Apply" button in there. You will also have set "index.php" as an index
filename in your virtual server's Document Preferences.

10. Congrats! Now, you have PHP installed! Of course, there are other features you
could enable (MySQL, XML, etc.), but I haven't tested against those. Just consult
the following page for hints: http://www.php.net/manual/en/install.unix.sun.php
mark at markround dot com
19-Aug-2004 04:36
Quick note : By replacing "php4" with "php5", the above instructions work perfectly
when building PHP5 for an iPlanet server. EG:-

Init fn="load-modules" funcs="php5_init,php5_execute,php5_auth_trans" etc.

Works fine here on 6.0SP2, Solaris 9 Sparc.

-Mark
[mark at markround dot com]
CGI and command line setups
By default, PHP is built as both a CLI and CGI program, which can be used for CGI
processing. If you are running a web server that PHP has module support for, you should
generally go for that solution for performance reasons. However, the CGI version enables
users to run different PHP-enabled pages under different user-ids.
Warning
A server deployed in CGI mode is open to several possible vulnerabilities. Please read our
CGI security section to learn how to defend yourself from such attacks.
Testing
If you have built PHP as a CGI program, you may test your build by typing make test. It is
always a good idea to test your build. This way you may catch a problem with PHP on your
platform early instead of having to struggle with it later.
Using Variables
Some server supplied environment variables are not defined in the current CGI/1.1
specification. Only the following variables are defined there: AUTH_TYPE,
CONTENT_LENGTH, CONTENT_TYPE, GATEWAY_INTERFACE, PATH_INFO,
PATH_TRANSLATED, QUERY_STRING, REMOTE_ADDR, REMOTE_HOST, REMOTE_IDENT,
REMOTE_USER, REQUEST_METHOD, SCRIPT_NAME, SERVER_NAME, SERVER_PORT,
SERVER_PROTOCOL, and SERVER_SOFTWARE. Everything else should be treated as 'vendor
extensions'.



HP-UX specific installation notes Sun, iPlanet and Netscape servers on Sun Solaris

Last updated: Fri, 11 Jun 2010

User Contributed Notes
CGI and command line setups
gordon_e_rouse at yahoo dot com dot au
28-Feb-2008 08:25
Have noticed on debian now, and may be true of other builds, that if you are using
php as a command line language, you don't need the -q ie: #!/usr/bin/php -q anymore.

What really took me ages to work out was how to the use php in cgi mode (ie in a cgi-
bin directory) as it doesn't send http headers by default. It also fails to populate
$_GET and $_POST arrays.

Turns out debian php build comes with /usr/bin/php-cgi

Use this in your shebang if running CGI scripts!

ie:

#!/usr/bin/php-cgi

I understand now - but had to figure this out myself!

Keywords I tried to solve this problem with were:

PHP, CGI, no $_GET array, Premature end of script headers, No http Headers, debian

Hopefully this post might save someone many hours of frustration, if they are
googling the above words!
info at ch2o dot info
17-Jun-2005 02:59
additionnal information to fastcgi...

the compilation of fastcgi library is not nessesary, php include a modified version
of this library,
and fastcgi module have this own implementation of the protocole fastcgi...

on the first server (where apache are!) the uid and gid of apache instance of the
fastcgi module
must be the same on the php file to execute...
without that they dont work...
the module refuse to send the request to the fastcgi php server...
info at ch2o dot info
13-Jun-2005 05:59
for using fastcgi external server in place of cgi or mod php with php:

to compile fastcgi librairie:

wget http://www.fastcgi.com/dist/fcgi-2.4.0.tar.gz
tar xzvf fcgi-2.4.0.tar.gz
cd fcgi-2.4.0
./configure
make
gmake install

to compile the fastcgi apache module:

wget http://www.fastcgi.com/dist/mod_fastcgi-2.4.2.tar.gz
tar xvzf mod_fastcgi-2.4.2.tar.gz
cd mod_fastcgi-2.4.2
path/to/apache/bin/apxs -i -A -n fastcgi -o mod_fastcgi.la -c *.c

after you must modify the http.conf to add that:

# load fcgi module
LoadModule fastcgi_module modules/mod_fastcgi.so

# authorization to execute fcgi on tree "/fcgi-bin/"
<Location /fcgi-bin/>
Options ExecCGI
SetHandler fastcgi-script
</Location>

# define fastcgi external serveur for virtual path "/fcgi-bin/phpfcgi" to execute
on targetmachinehost with targetport
FastCgiExternalServer /fcgi-bin/phpfcgi -host targetmachinehostname:targetport


# mime type definietion for some extention
AddType application/x-httpd-fastphp .php .cphp .php4

#define apache cgi regirection with the virtual action script /fcgi-bin/phpfcgi
associated with the defined mime type.
Action application/x-httpd-fastphp /fcgi-bin/phpfcgi

start apache.

compile php with --enable-cgi and --enable-fastcgi=/to/lib/fastcgi

start on target machine php with "php -b ip:port" for ear request from mod_fastcgi.

some aditional thing are in sapi/cgi/README.FastCGI of php src tree.

the document root of the apache machine must be synchronous with the php target
machine... with the same tree...

and with that solution you can mixe php5 and php4 with different extention of apache
directory limitation to one or another version...

with performance like mod_php!
kptrs at yahoo dot com
06-Jun-2004 11:37
Dug out from the discussion at the site below is a good tip: if you are working with
an existing PHP installation which did not build either the commandline or CGI
servers, you can use the lynx non-graphical web browser to get the web server to
execute php scripts from the command line (or cron jobs, etc):

lynx -dump http://whatever

>If you wish to use PHP as a scripting language, a good article to read is
>http://www.phpbuilder.com/columns/darrell20000319.php3

>note that the article is aimed at *nix not win32, but most of it still applies
phil at philkern dot de
03-Jan-2003 06:40
Thanks nordkyn, this one was very helpful.
Please note that the kernel has to be compiled with misc binary support, which is
activated on most distributions like Debian.
You would have to please these two lines in a script to run it after every reboot, on
debian I propose /etc/init.d/bootmisc.sh
You could place this lines at the end but before : exit 0
---
# Install PHP as binary handler

mount -t binfmt_misc none /proc/sys/fs/binfmt_misc
echo ":PHP:E::php::/usr/bin/php4:" > /proc/sys/fs/binfmt_misc/register
---
And please remember that the package management would override the file on the next
distribution upgrade :)
cv at corbach dot de
20-Feb-2002 04:18
Up to and including 4.1.1 you have to set doc_root to an non empty value if you
configure PHP for CGI usage with --enable-discard-path.
HP-UX specific installation notes
This section contains notes and hints specific to installing PHP on HP-UX systems.
There are two main options for installing PHP on HP-UX systems. Either compile it, or install
a pre-compiled binary.
Official pre-compiled packages are located here: http://software.hp.com/
Until this manual section is rewritten, the documentation about compiling PHP (and related
extensions) on HP-UX systems has been removed. For now, consider reading the following
external resource: Building Apache and PHP on HP-UX 11.11



OpenBSD installation notes CGI and command line setups

Last updated: Fri, 11 Jun 2010

User Contributed Notes
HP-UX specific installation notes
Vinayak
23-Mar-2006 12:14
Installing PHP 5.x with Apache 2.x on HP UX 11i and configuring
PHP 5.x with Oracle 9i

I am very glad to share this information to configure PHP 5.x work
with Apache 2.x and Oracle 9i on HP UX 11i.

Step 1: Install Apache 2.x with DSO support:
--------------------------------------------

This is a stratight forward Apache installation with
--enable-so option

gzip -d httpd-2_0_NN.tar.gz
tar xvf httpd-2_0_NN.tar
cd httpd-2_0_NN

./configure \
--prefix=/var/apps/apache2 \
--enable-so \
--enable-mods-shared=most \
--libexecdir=/var/apps/apache2/libexec

You can add other options as required.

make

make install

Step 2: Install and configure PHP 5.x with Oracle 9i
----------------------------------------------------

Edit the ./configure file to change "$OCI8_DIR/lib" as "$OCI8_DIR/lib32"

By default, with Oracle 9i, "$OCI8_DIR/lib" will be poiting to
Oracle 64 bit libraries in "$OCI8_DIR/lib64" directory.
Unfortunately, PHP 5.x does not work with 64 bit oracle shared libraries.

Run configure..

$ ./configure \
--prefix=/var/apps/php \
--with-apxs2=/var/apps/apache2/bin/apxs \
--with-oci8=/oracle/app/product/9.0.2 \
--disable-libxml \
--enable-libgcc \
--enable-ftp \
--enable-calendar \
--enable-track-vars \
--enable-trans-sid \
--enable-sigchild \
--libexecdir=/var/apps/apache2/libexec \
--with-config-file-path=/var/apps/apache2/conf

--enable-libgcc \
--enable-sigchild \

You can add other options as required. You can use the --help
option to configure to get a complete list.

After configure runs, you must edit the file libtool.

$ vi ./libtool

At line 184, you should change the line from:

deplibs_check_method="unknown"
to
deplibs_check_method="pass_all"

so that PHP and mod_php are properly compiled.

3. Compile and install the files.

Run make. This should complete normally.

$ make

Run make install. This will fail when it attempts to call apxs.

$ make install

Step 3: Configure Apache 2.x
----------------------------

Edit httpd.conf file to include

For PHP 5:

LoadModule php5_module modules/libphp5.so

AddType application/x-httpd-php .php .phtml


Set environment variables in $APACHE_ROOT/bin/envvars file

SHLIB_PATH="/var/apps/apache2/lib:$SHLIB_PATH"
export SHLIB_PATH

LD_LIBRARY_PATH=$ORACLE_HOME/app/product/9.0.2
/lib32
export LD_LIBRARY_PATH

LD_PRELOAD=/usr/lib/libpthread.sl:$ORACLE_HOME/app/
product/9.0.2/JRE/lib/PA_RISC/native_threads/libjava.sl
export LD_PRELOAD

After lot of hard work, by following the above procedure,
we were able to make PHP 5.x is work with Apache 2.x
and Oracle 9i on HP UX 11i OS.

Hope this will save your time!!
flconseil at yahoo dot fr
23-Jan-2006 02:47
If hpws is not an option for you, or if you want to build Apache and PHP with your
own options and extensions, I have written a step by step tutorial.

It explains how to build Apache 2.0 and PHP 5 from scratch on HP-UX 11i (11.11),
including most modules and extensions (zlib, SSL, LDAP, iconv, expat, xml, xslt, gd,
png, Xpm, jpeg, freetype, bzip2, curl, MySQL, PostgreSQL, Oracle, AdoDB) :

http://flaupretre.free.fr/redir.php?key=build_apa_php
Marcus dot Reimann at reimann-systemberatung dot de
29-Aug-2003 02:50
If you need an Apache2-Server with PHP4 under HP-UX 11.x, it's a good way to download
the HP-WebServer from the HP-Website (http://software.hp.com). The HP-Webserver comes
with numerous moduls. First install the HP-Webserver (swinstall -s
/absolute_path_to_depot_file/name_of_depot_file). After that, download the newest
PHP-Version from http://www.php.net (HP ships the HP-Webserver with an old PHP-
Version) and unpack the tar-file in a working-directory.

Use the following parameters for configure PHP:
./configure --with-apxs2=/opt/hpws/apache/bin/apxs --prefix=/opt/hpws/apache/php [and
so on...]

If configure prints the error "expr: An integer value was expected.", than you have
to edit the Script "configure". Replace the line:
APACHE_VERSION=`expr $4 \* 1000000 + $5 \* 1000 + $6`
with the following (correct and very long) line:
APACHE_VERSION=`$APXS_HTTPD -v | head -1 | cut -f3 -d' ' | cut -f2 -d'/' | awk 'BEGIN
{ FS = "."; } { printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'`

Why? The output of "httpd -v" prints the following string:
Server version: HP-UX_Apache-based_Web_Server/2.0.46
Server built: Jun 26 2003 04:41:28
But the configure-Script can't deal with this string.
jason dot sheets at hp dot com
27-Feb-2003 10:45
In order to use PHP 4.3.0 on HP-UX 11 I've found I must compile it statically with
Apache, it does not build as a module.
jsheets at shadotech dot com
30-Sep-2002 06:42
To clarify the my $dso_ext = "so"; comment, you can find my $dso_ext = "so"; in your
apxs script you need to change that line to my $dso_ext = "sl"; otherwise make
install will fail.
nikrou at ifrance dot com
08-Aug-2002 11:32
On HP-UX 11.00, there's a problem to compiling PHP as a DSO module. The script apxs
is looking fot libphp4.so instead of libphp4.sl. Change the line in the script
(search "extension").
Write : my $dso_ext = "sl";
instead of : my $dso_ext = "so"; // old line

Nicolas
ichoudhury007 at yahoo dot com
31-May-2002 04:11
On HP-UX 11 ... When you are compiling PHP as DSO, you will encounter an error during
"make install"

/usr/local/apache/bin/apxs -i -a -n php4 libs/libphp4.sl
apxs:Error: file libs/libphp4.sl is not a DSO
*** Error exit code 1

---- This is because installation is looking for libphp4.so instead of sl. You can
rename or link as libphp4.so and run
james at nospam dot hp dot com
29-Jan-2002 03:46
To build for HP-UX 10.X/11.X (and some other UNIX variants) with '--enable-sockets',
you'll get an error about 'u_int' being redefined in /usr/include/netinet/in.h and
ext/sockets/sockets.c will fail to compile. The problem is this line from
main/php_config.h:
#define in_addr_t u_int

The above define is a problem because HP-UX (and some other UNIXs) typedef
in_addr_t. A good workaround is to replace this define in main/php_config.h with the
lines from the HP-UX 11.X netinet/in.h header file (which will work for 10.X as
well):
#ifndef _IN_ADDR_T
#define _IN_ADDR_T
#ifdef __LP64__
typedef unsigned int in_addr_t;
#else
typedef unsigned long in_addr_t;
#endif
#endif
spam at adhocinc dot com
11-Oct-2001 09:35
For PHP 4.0.6 under HP-UX 11.00, I ran into errors during the compilation related to
"LC_CTYPE" and other "LC_" vars. The compilation complained that "LC_" such and such
first used in such and such function. (I think the error first came up in
php_pcre.c, then in basic_functions.c). The solution was to add "#include
<locale.h>" to the php.h file. Compilation was successful after that was added, with
no other issues. Used gcc 2.95.3, apache 1.3.20, bison 1.28, flex 2.5.4.a.
steven at oakleafconsultancy dot com
23-Jul-2001 03:28
Just a quick point to those of you (like me!) who might not be sharp enough to notice
this: If you want to install PHP on an HP-UX 11.x box then you'll need to download
and install the 11.x (not 10.20) versions of the software (like gcc and bison). I
didn't notice this and spent a large proportion of a day trying to figure out why the
software wouldn't install!
Steve
marshalm at ebrd dot com
17-May-2001 05:58
HP-UX 11.X PA-RISC installation with oracle (oci8). You need to install the HP-UX
patch PHSS_22514 patch (updated libdld.sl), otherwise you will get errors with
dlopen() and dlclose() not found during the apache integration stage.
jonas__linden at hotmail dot com
23-Jan-2001 05:05
Building under HP-UX11
If you are using HP ANSI C you have to add +e i.e -Aa -D_HPUX_SOURCE +e
OpenBSD installation notes
This section contains notes and hints specific to installing PHP on OpenBSD 3.6.
Using Binary Packages
Using binary packages to install PHP on OpenBSD is the recommended and simplest
method. The core package has been separated from the various modules, and each can be
installed and removed independently from the others. The files you need can be found on
your OpenBSD CD or on the FTP site.
The main package you need to install is php4-core-4.3.8.tgz, which contains the basic
engine (plus gettext and iconv). Next, take a look at the module packages, such as php4-
mysql-4.3.8.tgz or php4-imap-4.3.8.tgz. You need to use the phpxs command to activate
and deactivate these modules in your php.ini.
Example #1 OpenBSD Package Install Example
# pkg_add php4-core-4.3.8.tgz
# /usr/local/sbin/phpxs -s
# cp /usr/local/share/doc/php4/php.ini-recommended /var/www/conf/php.ini
(add in mysql)
# pkg_add php4-mysql-4.3.8.tgz
# /usr/local/sbin/phpxs -a mysql
(add in imap)
# pkg_add php4-imap-4.3.8.tgz
# /usr/local/sbin/phpxs -a imap
(remove mysql as a test)
# pkg_delete php4-mysql-4.3.8
# /usr/local/sbin/phpxs -r mysql
(install the PEAR libraries)
# pkg_add php4-pear-4.3.8.tgz
Read the packages(7) manual page for more information about binary packages on
OpenBSD.
Using Ports
You can also compile up PHP from source using the ports tree. However, this is only
recommended for users familiar with OpenBSD. The PHP 4 port is split into two sub-
directories: core and extensions. The extensions directory generates sub-packages for all of
the supported PHP modules. If you find you do not want to create some of these modules,
use the no_* FLAVOR. For example, to skip building the imap module, set the FLAVOR to
no_imap.
Common Problems
The default install of Apache runs inside a chroot(2) jail, which will restrict PHP
scripts to accessing files under /var/www. You will therefore need to create a
/var/www/tmp directory for PHP session files to be stored, or use an alternative
session backend. In addition, database sockets need to be placed inside the jail or
listen on the localhost interface. If you use network functions, some files from /etc
such as /etc/resolv.conf and /etc/services will need to be moved into /var/www/etc.
The OpenBSD PEAR package automatically installs into the correct chroot directories,
so no special modification is needed there. More information on the OpenBSD Apache
is available in the OpenBSD FAQ.
The OpenBSD 3.6 package for the gd extension requires XFree86 to be installed. If
you do not wish to use some of the font features that require X11, install the php4-
gd-4.3.8-no_x11.tgz package instead.
Older Releases
Older releases of OpenBSD used the FLAVORS system to compile up a statically linked PHP.
Since it is hard to generate binary packages using this method, it is now deprecated. You
can still use the old stable ports trees if you wish, but they are unsupported by the
OpenBSD team. If you have any comments about this, the current maintainer for the port is
Anil Madhavapeddy (avsm at openbsd dot org).



Solaris specific installation tips HP-UX specific installation notes

Last updated: Fri, 11 Jun 2010

User Contributed Notes
OpenBSD installation notes
hg at ostc dot de
16-May-2005 05:45
Also you should add "-a /var/www/dev/log" to the syslogd_flags
for propper logging of php-extensions like imap.so and create
a /var/www/etc/master.passwd with an www-user-entry and run
pwd_mkdb -d /var/www/etc /var/www/etc/master.passwd for propper
use of libc-client.a functions in imap.so.
openbsd-fanatic
10-May-2005 08:51
I am user that is just migrating to open source and thought I would take openbsd for
a spin. This article, by Gregory L. Magnusson, really helped me to get a working
apache-php-mysql server going on openbsd.
http://www.devx.com/security/Article/28059/0/page/1
ameen(at)dausha(dot)net
03-Nov-2003 03:47
I just finished spinning my wheels with PHP/Apache on OpenBSD 3.3, and it took a
Google to fix my problem. I followed the instructions by (0429196301 at netcabo dot
pt) written on Sep 19, 2003 and kept being fed a segmentation fault when I tried to
start httpd.

Then I read the page cited below that suggested playing with the order of the
LoadModules, and put the PHP first. I followed that recommendation and httpd started
without problems!

Page that saved me:
http://archives.neohapsis.com/archives/openbsd/2002-04/3074.html

"Change around the order of the Apache modules, this is one of the
drawbacks to the module API for Apache 1.3 is that the order is very
important. I would try making the PHP 4 module first, Perl module second
and FP module last. "
sanchero [at] gvsu [dot] edu
10-May-2003 06:59
On OpenBSD 3.2, given the steps outlined above using pre-built packages you will get
a new "/var/www/conf/httpd.conf" that contains a section like this:

<IfDefine SSL>
AddModule mod_ssl.c
AddModule mod_php4.c
</IfDefine>

This causes mod_php4 to load only when starting Apache w/SSL, so if this isn't what
you want add the mod_php4 line again above (or below) this section, like so:

AddModule mod_php4.c <<------ SEE? - now should load normally.
<IfDefine SSL>
AddModule mod_ssl.c
AddModule mod_php4.c
</IfDefine>

I also added this for good measure:

<IfModule mod_php4.c>
AddType application/x-httpd-php .php [blah blah]
</IfModule>

Seems to work.
Solaris specific installation tips
This section contains notes and hints specific to installing PHP on Solaris systems.
Required software
Solaris installs often lack C compilers and their related tools. Read this FAQ for information
on why using GNU versions for some of these tools is necessary. The required software is as
follows:
gcc (recommended, other C compilers may work)
make
flex
bison
m4
autoconf
automake
perl
gzip
tar
GNU sed
In addition, you will need to install (and possibly compile) any additional software specific to
your configuration, such as Oracle or MySQL.
Using Packages
You can simplify the Solaris install process by using pkgadd to install most of your needed
components.



Debian GNU/Linux installation notes OpenBSD installation notes

Last updated: Fri, 11 Jun 2010

User Contributed Notes
Solaris specific installation tips
julie at baumler dot com
29-Dec-2006 05:22
There's a great how-to for Solaris 10 from Mel Lester Jr at
http://meljr.com/~meljr/AMPSolaris10.html.

It even shows how to install php in a global zone and configure it in your other
zones.
francois at tekwire dot net
06-Oct-2006 08:11
A detailed HOWTO document describing how to build Apache & PHP on Solaris is
available at http://www.tekwire.net/redir.php/build_apa_php

This document also explains how to build from scratch every piece of software they
can depend on, including almost every Apache modules and PHP extensions : Apache 2.0,
PHP V4 & V5, zlib, OpenSSL, OpenLDAP, expat, iconv, mod_jk, xml2, xslt, png, jpeg,
freetype, bzip2, curl, imap, MySQL, PostgreSQL, mm.

Also includes a cute dependency diagram making clear the relationships between all
these libraries.
ozone at cname dot com
15-Jan-2006 05:46
php >= 5.1.1 requires a fully GNU toolchain on solaris; /usr/ccs/bin/ld will fail to
link. see bug 35496.
AxL
19-Dec-2005 06:48
If you have problems building php with sqlite on solaris, add "-lrt" library so you
dont get the fdatasync undefined symbol error.
anacreo
18-Dec-2004 04:11
Below was copied from a Sun Forum -- if having problems compiling on Solaris 10 try
this:

Re: where is ctid_t defined? (Solaris 10)
Author: Juergen.Keil Nov 17, 2004 10:37 AM (reply 1 of 10)
ctid_t is defined in /usr/include/sys/types.h ("typedef id_t ctid_t;").

I guess what has happend is that you're using a gcc compiler that
was build on Solaris 9 (or some other Solaris release older than
Solaris 10 b69), and this gcc release has a set of "fixed" gcc specific
headers that don't match your s10b69 system headers any more.

The fix is to build a fresh set of gcc "fixed" headers:

# cd /opt/sfw/gcc-3/lib/gcc-lib/i386-pc-solaris2.9/3.3.2/install-tools/

# cat > mkheaders.conf
SHELL=/bin/sh
SYSTEM_HEADER_DIR="/usr/include"
OTHER_FIXINCLUDES_DIRS=""
FIXPROTO_DEFINES="-D_XOPEN_SOURCE"
STMP_FIXPROTO="stmp-fixproto"
STMP_FIXINC="stmp-fixinc"
^D

# ./mkheaders
xlark at sdf dot lonestar dot org
12-Jul-2003 02:48
If you do a "Core Install" of Solaris, be sure you have installed the SUNWlibm and
SUNWlibms packages. PHP 4.2.3 fails to compile without them.

If you get errors with GCC about math.h, then you don't have them installed.
ejflores at alcatel dot es
03-Jul-2003 01:14
./configure not run fine with /usr/ucb/tr you need to install GNU textutils
ineves at iportalmais dot pt
07-Mar-2003 11:09
I have compiled php 4.2.3, on my solaris 9, sparc, it works, i have gcc 3.2.2, from
sunfreeware.org, i have compiled with

./configure --prefix=/opt/php --with-apxs=/opt/apache/bin/apxs --with-
pgsql=/opt/pgsql --with-imap=/usr/src/soft/imap-2002b --with-ldap --with-imap-
ssl=/usr/local/ssl

It compiles, but when i try to run it says something like:

bash-2.05# /opt/apache/bin/apachectl start
Syntax error on line 205 of /opt/apache/conf/httpd.conf:
Cannot load /opt/apache/libexec/libphp4.so into server: ld.so.1:
/opt/apache/bin/httpd: fatal: relocation error: file /opt/apache/libexec/libphp4.so:
symbol ldap_start_tls_s: referenced symbol not found
/opt/apache/bin/apachectl start: httpd could not be started

This means that the ldap librarys that came with solaris, are not very fine, you
should use from openldap.org packages...

it is using this library:

bash-2.05# ldd /opt/apache/libexec/libphp4.so
...
libldap.so.5 => /usr/lib/libldap.so.5

his one is from solaris installation.

(sorry about my english)
nicos at php dot net
06-Jan-2003 03:49
Note that you also need GNU sed or you'll have some errors lile "Output line too
long."
m at hackerz dot uk dot co
15-Oct-2002 04:49
Compiled Ok on Solaris 9 after the addition of Bison Flex automake and autoconf,
adding /usr/local/bin to the path and linking /usr/ccs/bin/ar to /usr/local/bin/ar.
php at woodNO-SPAMstea dot com
26-Jun-2002 06:15
Howard Glynn's post from May 22 is right on - if you're running Solaris 8, make sure
you get the latest Recommended patch cluster. I've been struggling with that library
problem that happens when you start Apache for several weeks, tweaking the config,
setting LD_LIBRARY_PATH, etc. I couldn't believe that the PHP developers wouldn't
have the Solaris build right - seems like a fairly important OS. But the latest
Solaris patch cluster fixed the problem, so I guess it was my fault for not being up
to date. I'm running PHP 4.2.1 now with Apache 2.0.36, works great.
ltfrench at vt dot edu
09-Jun-2002 09:09
To get PHP 4.2.0 or better to make on Solaris 8 (using gcc and gnu autoconf) you need
to:
ln -s /usr/local/bin/gcc /usr/local/bin/cc

See: http://bugs.php.net/bug.php?id=16833
howardglynn at hotmail dot com
22-May-2002 05:26
I've had a lot of problems with "dn_skipname" reference errors when trying to do a
php / apache shared-library install on solaris 8. All compiling was clean, but could
not restart apache with mod_php. After much trial and error, I found a solution by
installing patch 109326-07 which has some fixes for resolver (I think). I had one web
server without the patch, and one with it, and was able to show the same commands
compiling, working and restarting on one, but not the other. Installed patch on
machine, compiled clean and was up and running after doing this. Works great. Get the
patch from sun.com
gsmith1 at iupui dot edu
04-Apr-2002 12:35
Loading 4.1.2 on solaris 8 in C shell with mysql 4.0.1 I kept running into file not
found errors by ld during make. A specific error relating to adding mysql was solved
by adding the following environment variable:
setenv LD_RUN_PATH=/usr/lib:/usr/local/lib:/usr/local/mysql/lib
shane dot kinsch at netracorp dot comNOSPAM
17-Feb-2002 08:49
PHP 4.1.1 / Apache 1.32 Buile Issues (Solaris 2.8)

Apache build options:
./configure --prefix=/usr/local/etc/apache --enable-module=rewrite --enable-
shared=rewrite

PHP build options:
./configure --with-mysql=/usr/local/etc/mysql --with-
apxs=/usr/local/etc/apache/bin/apxs

Both Apache and PHP compiled without errors and installed cleanly.

The Error when starting Apache:
Syntax error on line 208 of /usr/local/etc/apache/conf/httpd.conf:
Cannot load /usr/local/etc/apache/libexec/libphp4.so into server:
ld.so.1: /usr/local/etc/apache/bin/httpd: fatal: relocation error: file
/usr/local/etc/apache/libexec/libphp4.so: symbol dn_skipname: referenced symbol not
found ./apachectl start: httpd could not be started

Line 208 in the httpd.conf file is:
LoadModule php4_module libexec/libphp4.so

The solution:
For some reason, even though LD_LIBRARY_PATH was being set properly,
it wasn't being read fully. You will need to create a runtime
linking environment by doing this:

#crle -c /var/ld/ld.config -l /usr/lib:/usr/local/lib:/usr/local/etc/mysql/lib

Shane Kinsch
NetraCorp LLC / SecurNET Consulting
Louis at ewens dot com
23-Jun-2001 02:39
On Solaris, if upon starting Apache you get an error like this:

Syntax error on line 33 of /usr/local/apache/conf/httpd.conf:
Cannot load /usr/local/apache/libexec/libphp4.so into server: ld.so.1: /usr/loca
l/apache/bin/httpd: fatal: libmysqlclient.so.10: open failed: No such file or
directory
./apachectl start: httpd could not be started

..try inserting the following lines into the configuration section of your apachectl
startup shell script:

LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/mysql/lib/mysql
export LD_LIBRARY_PATH

Change the /usr/local/mysql/ prefix to where ever your MySQL installation is. Make
sure to add on the /lib/mysql extension to your own path though.

Do your normal "apachectl start" command to start Apache and voila, no more error.
Apachectl can be found in the bin directory of your Apache installation.
cullin at cometsystems dot com
23-Jan-2001 04:59
When compiling and installing on Solaris, you might encounter a but that occurs only
when you try and start apache - in otherwords, the module compiles fine but it won't
run! The specific error is that it can't find a symbol called "__muldi3". From what
I can tell, this is an internal symbol created by gcc and the problem happens when
you compile the code with gcc and then use a different linker.

To fix the problem, make sure that there is only one 'ld' program in your $PATH and
that you also specify '--with-gnu-ld' in your configuration.
Debian GNU/Linux installation notes
This section contains notes and hints specific to installing PHP on Debian GNU/Linux.
Warning
Unofficial builds from third-parties are not supported here. Any bugs should be reported to
the Debian team unless they can be reproduced using the latest builds from our download
area.
While the instructions for building PHP on Unix apply to Debian as well, this manual page
contains specific information for other options, such as using either the apt-get or aptitude
commands. This manual page uses these two commands interchangeably.
Using APT
First, note that other related packages may be desired like libapache2-mod-php5 to
integrate with Apache 2, and php-pear for PEAR.
Second, before installing a package, it's wise to ensure the package list is up to date.
Typically, this is done by running the command apt-get update.
Example #1 Debian Install Example with Apache 2
# apt-get install php5-common libapache2-mod-php5 php5-cli
APT will automatically install the PHP 5 module for Apache 2 and all of its dependencies, and
then activate it. Apache should be restarted in order for the changes take place. For
example:
Example #2 Stopping and starting Apache once PHP is installed
# /etc/init.d/apache2 stop
# /etc/init.d/apache2 start
Better control of configuration
In the last section, PHP was installed with only core modules. It's very likely that additional
modules will be desired, such as MySQL, cURL, GD, etc. These may also be installed via the
apt-get command.
Example #3 Methods for listing additional PHP 5 packages
# apt-cache search php5
# aptitude search php5
# aptitude search php5 |grep -i mysql
The examples will show a lot of packages including several PHP specific ones like php5-cgi,
php5-cli and php5-dev. Determine which are needed and install them like any other with
either apt-get or aptitude. And because Debian performs dependency checks, it'll prompt for
those so for example to install MySQL and cURL:
Example #4 Install PHP with MySQL, cURL
# apt-get install php5-mysql php5-curl
APT will automatically add the appropriate lines to the different php.ini related files like
/etc/php5/apache2/php.ini, /etc/php5/conf.d/pdo.ini, etc. and depending on the extension
will add entries similar to extension=foo.so. However, restarting the web server (like
Apache) is required before these changes take affect.
Common Problems
If the PHP scripts are not parsing via the web server, then it's likely that PHP was not
added to the web server's configuration file, which on Debian may be
/etc/apache2/apache2.conf or similar. See the Debian manual for further details.
If an extension was seemingly installed yet the functions are undefined, be sure that
the appropriate ini file is being loaded and/or the web server was restarted after
installation.
There are two basic commands for installing packages on Debian (and other linux
variants): apt-get and aptitude. However, explaining the subtle differences between
these commands goes beyond the scope of this manual.



Installation on Mac OS X Solaris specific installation tips

Last updated: Fri, 11 Jun 2010

User Contributed Notes
Debian GNU/Linux installation notes
juraj at jurajsplayground dot com
09-May-2009 12:59
On Ubuntu (since 7.04), rather do:
sudo tasksel install lamp-server

Details:
https://help.ubuntu.com/community/ApacheMySQLPHP
tranzbit at yahoo dot com
02-May-2009 08:59
On Ubuntu:

sudo apt-get install apache2 php5 mysql-client-5.0 mysql-server-5.0 phpmyadmin
libapache2-mod-php5 libapache2-mod-auth-mysql php5-mysql

then restart the computer/start mysql manually
From:
http://ubuntuforums.org/showthread.php?t=186492
John Fisher
09-Feb-2007 12:53
With Apache2 and Php4 under Debian Sarge there is an extra configuration file
: /etc/apache2/sites-available/default
This file is not clearly documented, at least not for noobs, in Apache docs.

It overrides the conf file in the way you expect the /etc/apache2/conf.d/apache2-
doc to do according to the README.

Add ExecCGI to it to get rid of "Options ExecCGI is off in this directory" errors.
Ben A.
18-Dec-2005 06:53
Although there are no PHP 5 packages for Debian 3.1 (aka "stable" or "sarge"), there
are currently PHP 5 packages for "testing"/"etch" and "unstable"/"sid". Installation
works the same way.

Also, the same process can be used for Ubuntu, but note that some of the packages may
be in the "universe" section instead of "main".
jimmychan at example dot com
24-Oct-2005 05:01
If you are using Debian 3.1

It is total, the php.ini is under
/etc/php4/apache2

Since Debian 3.1 default apache is 2.0.x version, this one just said how to change
the php.ini under apache 1.3.x

If you need enable the ext. need manaul edit php.ini, and comment out # of what the
ext. that you want to enable

Of course, you much first install the ext. first by like that

apt-get install php4-gd php4-mysql ......
Installation on Mac OS X
Table of Contents
Using Packages
Using the bundled PHP
Compiling for OS X Server
Installing for Apache on MacOS X Client
This section contains notes and hints specific to installing PHP on Mac OS X. There are two
slightly different versions of Mac OS X, Client and Server, our manual deals with installing
PHP on both systems. Note that PHP is not available for MacOS 9 and earlier versions.



Using Packages Debian GNU/Linux installation notes

Last updated: Fri, 11 Jun 2010

User Contributed Notes
Installation on Mac OS X
Dan Black
08-Mar-2007 04:00
My httpd.conf had some of the lines, but not all of them -- mine was missing the
LoadModule and AddModule lines for php. I'm not sure why -- I don't delete any of
those; I just comment them out if I'm not using them. Plus, the note above put a
space in "LoadModule"; it has no space. I didn't know about the "apachectl graceful"
trick, though -- since "httpd -k restart" stopped working (probably around 10.2), I
had just been doing it manually -- find the process, kill it, and hit httpd again --
thanks for the tip!

So for those who are missing any of the lines, here are the full lines.

In the section with all the other LoadModules:
LoadModule php4_module libexec/httpd/libphp4.so</div>

Directly below that section should be the AddModules; you need:
AddModule mod_php4.c

And then the AddType lines should be right after the language priorities (so after
the AddCharset lines and after the LanguagePriority bit):
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

Then restart apache/httpd as described above, and hopefully you should be good.

BTW, the actual module should be at:
/usr/libexec/httpd/libphp4.so
So if things fail, you can check to see if that's there.

Thanks to others who posted here; it definitely helped and got me on the right
track. I just had to find the module manually to write my own LoadModule line.
Jeff Hayden
10-Sep-2006 06:17
Just a note. The darwinports software is now macports and you can get it at:
http://www.macports.org/

If you use macports, be sure to change any refernces you may have in your calling
scripts to macports as the file macports now gets installed.
andreas at fink dot org
18-Aug-2004 07:01
To build on MacOS X 10.3.5 set the environment variable CFLAGS in the following way
(depending on your shell)

setenv CFLAGS "-DBIND_8_COMPAT=1 -DEAPI -O3"

export CFLAGS="-DBIND_8_COMPAT=1 -DEAPI -O3"

Then launch configure with the options:

./configure --prefix=/usr --mandir=/usr/share/man ....

The -DBIND_8_COMPAT=1 gets you over a problem in the DNS files because MacOS X has
definitions for Bind9 and PHP expects Bind8 definitions. -DEAPI is needed if you
build it for Apache 1.3.31. -O3 enables the gcc optimizer.

You can also add one of the following lines to your CFLAGS depending on the CPU you
use to further improve speed:
-mcpu=G3 -mtune=G3
-mcpu=G4 -mtune=G4
-mcpu=G5 -mtune=G5
Rick
29-Oct-2003 02:12
under MacOS 10.3 if your compile fails

vi Makefile
find the dns.c entry
add the switch -DBIND_8_COMPAT
run make again
jack dash pinette at uiowa dot edu
24-Jan-2003 09:56
PHP 4.3.0 can easily be build on Mac OS X client; you don't need to download a
binary. The process is quite fast and painless.

See
http://www.onlamp.com/pub/a/php/2003/01/17/phpcookbook.html
for details.
php at radicalcomputingconcepts dot com
15-May-2002 11:35
10.1 with fink installed into /sw ,mysql installed from fink.
finally :
Apache/1.3.24 (Darwin) DAV/1.0.3 PHP/4.2.1 mod_ssl/2.8.8 OpenSSL/0.9.6c configured

initial apache config:
./configure --prefix=/sw --enable-shared=max --enable-module=most --target=apache --
with-layout=GNU
--enable-suexec --suexec-caller=www-data

then php config:
./configure --prefix=/sw --with-xml --with-apache=../apache_1.3.24 --with-curl=/sw --
with-pdflib=/sw
--enable-exif --with-mysq=/sw

then mod-ssl config:
./configure --with-apache=../apache_1.3.24 --with-ssl=/sw --enable-rule=SSL_SDBM

final apache config:
./configure --prefix=/sw --enable-shared=max --enable-module=most --target=apache --
with-layout=GNU
--enable-suexec --suexec-caller=www-data --activate-module=src/modules/php4/libphp4.a
--enable-module=ssl

on final make of apache there was error in src/modules/ssl. i had to rm -ldbm and -
lgcc and run gcc line by hand. then was able to finish make.

i dont know what effect that may have on the build and i am interested to know, this
was the only problem spot finally after many hours of hacking at it.
testing so far:
phpinfo() via http and https works.
info at ericbontenbal dot nl
18-Feb-2002 05:43
for using PHP on MacOSX, see article #106485 of the Apple knowledge base
lanhel at mac dot com
08-Nov-2001 02:14
Getting PHP running on 10.1 is simple.

1. su to root
2. Edit /etc/httpd/httpd.conf
3. Uncomment "Load Module php4_module" line.
4. Uncomment "AddModule mod_php4.c" line.
5. Uncomment "AddType application/x-httpd-php .php" line.
6. Uncomment "AddType application/x-httpd-php-source .phps" line.
7. Find "<Directory /home/*/Sites>" block and uncomment the entire Directory
directive block.

This will allow PHP to execute from ~/Sites directory.
larry(at)shafferinteractive.com
24-Sep-2001 12:40
For the latest on Mac OS X PHP installs (as of 10.0.4 on 9.24.01) check out
http://developer.apple.com/internet/macosx/php.html

This page also has some info on MySQL installs.
oster at ieee dot org
30-Jul-2001 07:17
If you've got Mac OS X pre-installed on your Mac, you've also got php4 pre-installed.
You don't need to download or compile anything. You just need to edit the
/etc/httpd/httpd.conf file. Use the "sudo open -a TextEdit..." command line, above.
Search for "php", and make sure you've un-commented _all_ the relevant lines: the two
AddType lines above, and also the AddModule and LoadModule lines. (but not the
AddType lines for php3, since you'll be using php4.) Save and restart Apache with
"sudo apachectl graceful", and you are done.
Using Packages
There are a few pre-packaged and pre-compiled versions of PHP for Mac OS X. This can help
in setting up a standard configuration, but if you need to have a different set of features
(such as a secure server, or a different database driver), you may need to build PHP and/or
your web server yourself. If you are unfamiliar with building and compiling your own
software, it's worth checking whether somebody has already built a packaged version of
PHP with the features you need.
The following resources offer easy to install packages and precompiled binaries for PHP on
Mac OS:
MacPorts: http://www.macports.org/
Entropy: http://www.entropy.ch/software/macosx/php/
Fink: http://www.finkproject.org/
Homebrew: http://github.com/mxcl/homebrew
Using the bundled PHP
PHP has come standard with Macs since OS X version 10.0.0. Enabling PHP with the default
web server requires uncommenting a few lines in the Apache configuration file httpd.conf
whereas the CGI and/or CLI are enabled by default (easily accessible via the Terminal
program).
Enabling PHP using the instructions below is meant for quickly setting up a local
development environment. It's highly recommended to always upgrade PHP to the newest
version. Like most live software, newer versions are created to fix bugs and add features
and PHP being is no different. See the appropriate MAC OS X installation documentation for
further details. The following instructions are geared towards a beginner with details
provided for getting a default setup to work. All users are encouraged to compile, or install
a new packaged version.
The standard installation type is using mod_php, and enabling the bundled mod_php on Mac
OS X for the Apache web server (the default web server, that is accessible via System
Preferences) involves the following steps:
1. Locate and open the Apache configuration file. By default, the location is as follows:
/private/etc/apache2/httpd.conf Using Finder or Spotlight to find this file may prove
difficult as by default it's private and owned by the root user.
Note: One way to open this is by using a Unix based text editor in the Terminal, for
example nano, and because the file is owned by root we'll use the sudo command to
open it (as root) so for example type the following into the Terminal Application
(after, it will prompt for a password): sudo nano /private/etc/apache2/httpd.conf
Noteworthy nano commands: ^w (search), ^o (save), and ^x (exit) where ^
represents the Ctrl key.
Note: Versions of Mac OS X prior to 10.5 were bundled with older versions of PHP
and Apache. As such, the Apache configuration file on legacy machines may be
/etc/httpd/httpd.conf.
2. With a text editor, uncomment the lines (by removing the #) that look similar to the
following (these two lines are often not together, locate them both in the file):
3. # LoadModule php5_module libexec/httpd/libphp5.so
4.
5. # AddModule mod_php5.c
Notice the location/path. When building PHP in the future, the above files should be
replaced or commented out.
6. Be sure the desired extensions will parse as PHP (examples: .php .html and .inc)
Due to the following statement already existing in httpd.conf (as of Mac Panther),
once PHP is enabled the .php files will automatically parse as PHP.
<IfModule mod_php5.c>
# If php is turned on, we respect .php and .phps files.
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

# Since most users will want index.php to work we
# also automatically enable index.php
<IfModule mod_dir.c>
DirectoryIndex index.html index.php
</IfModule>
</IfModule>
Note: Before OS X 10.5 (Leopard), PHP 4 was bundled instead of PHP 5 in which
case the above instructions will differ slightly by changing 5's to 4's.
7. Be sure the DirectoryIndex loads the desired default index file This is also set in
httpd.conf. Typically index.php and index.html are used. By default index.php is
enabled because it's also in the PHP check shown above. Adjust accordingly.
8. Set the php.ini location or use the default A typical default location on Mac OS X is
/usr/local/php/php.ini and a call to phpinfo() will reveal this information. If a php.ini
is not used, PHP will use all default values. See also the related FAQ on finding
php.ini.
9. Locate or set the DocumentRoot This is the root directory for all the web files. Files in
this directory are served from the web server so the PHP files will parse as PHP
before outputting them to the browser. A typical default path is
/Library/WebServer/Documents but this can be set to anything in httpd.conf.
Alternatively, the default DocumentRoot for individual users is
/Users/yourusername/Sites
10. Create a phpinfo() file
The phpinfo() function will display information about PHP. Consider creating a file in
the DocumentRoot with the following PHP code:
<?php phpinfo(); ?>
11. Restart Apache, and load the PHP file created above To restart, either execute sudo
apachectl graceful in the shell or stop/start the "Personal Web Server" option in the
OS X System Preferences. By default, loading local files in the browser will have an
URL like so: http://localhost/info.php Or using the DocumentRoot in the user
directory is another option and would end up looking like:
http://localhost/~yourusername/info.php
The CLI (or CGI in older versions) is appropriately named php and likely exists as
/usr/bin/php. Open up the terminal, read the command line section of the PHP manual, and
execute php -v to check the PHP version of this PHP binary. A call to phpinfo() will also
reveal this information.



Compiling for OS X Server Using Packages

Last updated: Fri, 11 Jun 2010

User Contributed Notes
Using the bundled PHP
Anonymous
15-Nov-2008 10:36
You only have to uncomment:
#LoadModule php5_module libexec/apache2/libphp5.so

This is gone:
# AddModule mod_php5.c

The statement in 3 was changed to:
<IfModule mime_module>
#
# TypesConfig points to the file containing the list of mappings from
# filename extension to MIME-type.
#
TypesConfig /private/etc/apache2/mime.types

#
# AddType allows you to add to or override the MIME configuration
# file specified in TypesConfig for specific file types.
#
#AddType application/x-gzip .tgz
#
# AddEncoding allows you to have certain browsers uncompress
# information on the fly. Note: Not all browsers support this.
#
#AddEncoding x-compress .Z
#AddEncoding x-gzip .gz .tgz
#
# If the AddEncoding directives above are commented-out, then you
# probably should define those extensions to indicate media types:
#
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz

#
# AddHandler allows you to map certain file extensions to "handlers":
# actions unrelated to filetype. These can be either built into the server
# or added with the Action directive (see below)
#
# To use CGI scripts outside of ScriptAliased directories:
# (You will also need to add "ExecCGI" to the "Options" directive.)
#
#AddHandler cgi-script .cgi

# For type maps (negotiated resources):
#AddHandler type-map var

#
# Filters allow you to process content before it is sent to the client.
#
# To parse .shtml files for server-side includes (SSI):
# (You will also need to add "Includes" to the "Options" directive.)
#
#AddType text/html .shtml
#AddOutputFilter INCLUDES .shtml
</IfModule>

Extra MIME types can either be added to the file /private/etc/apache2/mime.types or
by using an AddType directive as commented on above.
jaffle
24-Oct-2008 09:36
Additionally, it seems that the default installation of php on Mac OS X (10.5 tested)
does not point to the default location of the mysql.sock file that is installed in a
standard MySQL 5.0 installation.

This prevents php working with locally hosted MySQL databases.

Adding the following line to the /private/etc/apache2/other/php5.conf file did the
trick:

php_value mysql.default_socket /tmp/mysql.sock

(make sure you put it in between the </IfModule> statements)
sachin at dharmapurikar dot in
22-Oct-2008 12:28
I am using MacOSX 10.5.4 and only enabling the mod_php5 wasn't enough to get the PHP
support. I had to add following block before I could use php on machine -

<IfModule mod_php5.c>
# If php is turned on, we respect .php and .phps files.
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

# Since most users will want index.php to work we
# also automatically enable index.php
<IfModule mod_dir.c>
DirectoryIndex index.html index.php
</IfModule>
</IfModule>
Compiling for OS X Server
Mac OS X Server install
1. Get the latest distributions of Apache and PHP.
2. Untar them, and run the configure program on Apache like so.
3. ./configure --exec-prefix=/usr \
4. --localstatedir=/var \
5. --mandir=/usr/share/man \
6. --libexecdir=/System/Library/Apache/Modules \
7. --iconsdir=/System/Library/Apache/Icons \
8. --includedir=/System/Library/Frameworks/Apache.framework/Versions/1.3/Headers
\
9. --enable-shared=max \
10. --enable-module=most \
--target=apache
11. If you want the compiler to do some optimization, you may also want to add this
line:
setenv OPTIM=-O2
12. Next, go to the PHP 4 source directory and configure it.
13. ./configure --prefix=/usr \
14. --sysconfdir=/etc \
15. --localstatedir=/var \
16. --mandir=/usr/share/man \
17. --with-xml \
--with-apache=/src/apache_1.3.12
If you have any other additions (MySQL, GD, etc.), be sure to add them here. For
the --with-apache string, put in the path to your apache source directory, for
example /src/apache_1.3.12.
18. Type make and make install. This will add a directory to your Apache source
directory under src/modules/php4.
19. Now, reconfigure Apache to build in PHP 4.
20. ./configure --exec-prefix=/usr \
21. --localstatedir=/var \
22. --mandir=/usr/share/man \
23. --libexecdir=/System/Library/Apache/Modules \
24. --iconsdir=/System/Library/Apache/Icons \
25. --includedir=/System/Library/Frameworks/Apache.framework/Versions/1.3/Headers
\
26. --enable-shared=max \
27. --enable-module=most \
28. --target=apache \
--activate-module=src/modules/php4/libphp4.a
You may get a message telling you that libmodphp4.a is out of date. If so, go to the
src/modules/php4 directory inside your Apache source directory and run this
command: ranlib libmodphp4.a. Then go back to the root of the Apache source
directory and run the above configure command again. That'll bring the link table
up to date. Run make and make install again.
29. Copy and rename the php.ini-development file to your bin directory from your PHP 4
source directory: cp php.ini-development /usr/local/bin/php.ini or (if your
don't have a local directory) cp php.ini-development /usr/bin/php.ini.
Installing for Apache on MacOS X Client
The following instructions will help you install a PHP module for the Apache web server
included in MacOS X using the MacOS GUI. This version includes MySQL, PostgreSQL, and
iODBC database support, cURL, GD, PDFLib, LDAP, and more. These instructions are
graciously provided by Marc Liyanage.
Warning
Be sure you know what you're doing before advancing beyond this point! You can cause
irreparable harm to your Apache installation otherwise.
Note: These instructions will only work with the original Apache web server as shipped by
Apple. If you re-built or upgraded your Apache, you will have to build your own PHP module.
To install:
1. For Apache 1.3, download: http://www2.entropy.ch/download/entropy-php-
5.2.4-1.tar.gz
2. For Apache 2, download: wget http://www2.entropy.ch/download/entropy-php-
5.2.4-1-apache2.tar.gz
3. Unpack the compressed .tar.gz file, but DO NOT USE StuffIt Expander. Instead, use
Apple's BOMArchiveHelper or the command line.
4. Double-click the installer package and follow the directions of the installer
application.
That's all! PHP should now be up and running. You can test it by dropping a file named
test.php into your Sites folder in your home directory. Into that file, write this line: <?php
phpinfo() ?>.
Now open up 127.0.0.1/~your_username/test.php in your web browser. You should see a
status table with information about the PHP module.



Installation on Windows systems Compiling for OS X Server

Last updated: Fri, 11 Jun 2010

User Contributed Notes
Installing for Apache on MacOS X Client
nabaja at gmx dot com
27-Feb-2009 08:15
I wanted to update my iMac (osx 10.5.6) from php 5.2.3 to 5.2.9 . I downloaded the
source from this site, tried to install with some changes and screwed up my php. Come
to find out that you need to use the ./configure command to set everything up JUST
RIGHT for you computer. i ran this command in the terminal window while in the
unzipped php-5.2.9 directory:
./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --
mandir=/usr/share/man --infodir=/usr/share/info --with-apxs2=/usr/sbin/apxs --with-
curl --with-gd --enable-exif --enable-fastcgi --enable-zip --with-ldap=/usr --with-
kerberos=/usr --with-zlib=/usr --enable-ftp --enable-sockets --with-iodbc=/usr --
with-config-file-path=/etc --with-openssl --with-xmlrpc --with-xsl=/usr

make

sudo make install (then type your pw)

you can change the settings, but you'd better get it right!

mysql settings:
--with-mysql=/usr/local/mysql --with-mysql-sock=/var/mysql --with-
mysqli=/usr/local/mysql/bin/mysql_config

also, you can check out the apple developers site, that helped me.
if your apache server gets screwed up, use the note above to reinstall apache2, then
install php, everything should work fine, it did for me.
mdoyle at cooperationireland dot org
07-Apr-2008 02:54
With OSX 10.5, the bundled version is up to date but didn't come with the modules I
needed (notably I wanted the pgsql database extension).

Getting this to work was quite simple in the end, what made it difficult is the
build-options for Apache. After searching on google, I found instructions to re-build
apache with the following options:

./configure --enable-layout=Darwin --enable-mods-shared=all

(Step 1: download the latest Apache2.2 source files,
Step 2: extract the tarball
Step 3: ./configure --enable-layout=Darwin --enable-mods-shared=all
Step 4: make all
Step 5: sudo make install)

Without this step, when I rebuilt PHP either directly with the source from the
PHP.net site or using MacPorts I was getting an error about the wrong architecture
like this one:

httpd: Syntax error on line 114 of /private/etc/apache2/httpd.conf: Cannot load
/usr/libexec/apache2/libphp5.so into server: dlopen(/usr/libexec/apache2/libphp5.so,
10): no suitable image found. Did find:\n\t/usr/libexec/apache2/libphp5.so: mach-o,
but wrong architecture

After re-building and Apache with the configuration above and restarting it,
everything worked again and I can now use PostgreSQL from within PHP on my MacBook
Pro.
rahul
08-May-2007 07:54
if `wget` isn't installed or not in your path use `curl -O` instead.






Installation on Windows systems
Table of Contents
Windows Installer (PHP 5.1.0 and earlier)
Windows Installer (PHP 5.2 and later)
Manual Installation Steps
ActiveScript
Microsoft IIS
Microsoft IIS 5.1 and IIS 6.0
Microsoft IIS 7.0 and later
Apache 1.3.x on Microsoft Windows
Apache 2.x on Microsoft Windows
Sun, iPlanet and Netscape servers on Microsoft Windows
OmniHTTPd Server
Sambar Server on Microsoft Windows
Xitami on Microsoft Windows
Building from source
Installation of extensions on Windows
Command Line PHP on Microsoft Windows
This section applies to Windows 98/Me and Windows NT/2000/XP/2003. PHP will not work
on 16 bit platforms such as Windows 3.1 and sometimes we refer to the supported Windows
platforms as Win32. Windows 95 is no longer supported as of PHP 4.3.0.
Note: Windows 98/ME/NT4 is no longer supported as of PHP 5.3.0.
Note: Windows 95 is no longer supported as of PHP 4.3.0.
There are two main ways to install PHP for Windows: either manually or by using the
installer.
If you have Microsoft Visual Studio, you can also build PHP from the original source code.
Once you have PHP installed on your Windows system, you may also want to load various
extensions for added functionality.
Warning
There are several all-in-one installers over the Internet, but none of those are endorsed by
PHP.net, as we believe that using one of the official windows packages from
http://www.php.net/downloads.php is the best choice to have your system secure and
optimized.



Windows Installer (PHP 5.1.0 and earlier) Installing for Apache on MacOS X Client

Last updated: Fri, 11 Jun 2010

User Contributed Notes
Installation on Windows systems
freeman0774 at gmail dot com
29-Jan-2010 09:33
Under Windows2000 Advanced Server it returns http error 500 if you have php installed
on a path that uses spaces (for example C:\program files\php); solved coping the
php5isapi.dll under winnt\system32 (but I think any path without spaces will be
good).

Thinks this will help.
bufoni at hotmail dot com
18-Sep-2009 02:49
Oh Man!

I installed by Microsoft Installer, manually, whatever I always received de same
error from IIS7.

HTTP Error 404.3 - Not Found
The page you are requesting cannot be served because of the extension configuration.
If the page is a script, add a handler. If the file should be downloaded, add a MIME
map.

The IIS7 interface is quite diferent and are not all together like IIS6

The 5.3 version have not any of those files: php5stdll, php5isapi.dll. etc.

The installer puts others files in handlers and I decided to use them as substitutes.
Nothing done!

After that, I discovered that installer do not install these files within the sites,
but in the root default site configuration of IIS7.

So, I copied the root configuration to my site and them it worked (all others
procedures were done e.g. copy php.ini to windows folder)
Fernando O.
31-Jul-2009 10:28
I found a way to install it properly, on IIS 7:

Note

Set IIS to allow 32-bits if you are on 64-bits

cscript %SYSTEMDRIVE%\inetpub\adminscripts\adsutil.vbs SET
W3SVC/AppPools/Enable32bitAppOnWin64 1

Set enviroment variables

PATH to, say, C:\php\

PHPRC to, that same dir

Go to Web Service Extensions: Add a new extension...

Name it for example php, and point it to the php5isapi.dll.

Set status to Allowed.

Right click Web Sites:

On the tab, ISAPI Filters, name it for example php, and point it to the php5isapi.dll

Then go to Home directory tab:

Click Configuration

On Mappings, click add:

Executable would be: php5isapi.dll
Extension to: .php

Click OK, then OK.

Then on the tab Documents click Add:

and add there what you want to load as default, say index.php

Then stop, and start IIS.

This worked for me on a Windows 2003 Server, and WinXP 64.

I hope this saves time for someone.
rich at corephp dot co dot uk
02-Jul-2009 12:06
As of today (2nd July 2009) it appears that the current VC6 Windows archive doesn't
include a DLL for Apache 2.2, and the two included ones don't work with 2.2 at all.
The VC9 build is of course only for IIS, so no joy there either.
robert dot johnson at icap dot com
19-May-2009 10:38
IIS ISAPI module is not included in the Windows msi installer for version 5.2.9-2.

Either use the zip file and set it up manually, or use the installer for version
5.2.9-1 instead.
dpharshman at dslextreme dot com
17-May-2009 12:52
PHP 5.2.9.2 Install on XP Pro IIS 5.1 - phpinfo( ) results incorrect

Testing Date: 05.15.09

Background:
For several days now I, as a newbie, have been unsure if I had installed PHP
correctly, or not. No matter what I did phpinfo( ) reported "Configuratin File Path"
as: C:\WINDOWS. I was left to wonder what was wrong.

To help resolve the phpinfo() issue, I conducted a series of tests using two
scripts:

The first is test-php-ini-loaded.php; it is stored in c:\inetpub\wwwroot, and has
the following code:

<?php
$inipath = php_ini_loaded_file();

if ($inipath) {
echo 'Loaded php.ini: ' . $inipath;
} else {
echo 'A php.ini file is not loaded';
}
?>

The second script is simply calls phpinfo( ). It is named test.php, is stored in
c:\inetpub\wwroot, and has the following code:

<?php phpinfo( ); ?>

My Dev Environment:
1. Windows XP Pro SP3
2. IIS 5.1 / MMC 3.0
3. PHP 5.2.9.2 phpMyAdmin not yet installed
4. (plus MySQL 5.1, etc.)
5. Install location is on my local E: drive

The Tests:

Test 1:
a. PHPRC environment variable and IniFilePath Registry left in place and active
b. Verified no other copies of php.ini exist on the system other than in my E:\PHP
folder
c. Renamed php.ini to hold-php.ini
d. Stopped and started IIS (net stop iisadmin and net start w3svc)
e. Ran test-php-ini-loaded.php to check whether my php.ini is loaded. It is not.
f. Ran "test.php". Loaded Configuration File was empty, while Configuration File
(php.ini) Path showed: C:\WINDOWS.

Test 2:
a. Moved php.ini from E:\PHP to C:\WINDOWS
b. Stopped and started IIS
c. Ran "test-php-ini-loaded.php" to check if my php.ini is loaded. It is not, which
surprised me.
d. Ran "test.php". My php.ini is apparently not loaded, or found, by phpinfo( ),
even though Configuration File (php.ini) Path reports it as being in C:\WINDOWS.
e. Note: Per PHPs The configuration file note, PHP's search order
includes: Windows directory (C:\windows or C:\winnt) (for Windows), ...; but it
apparently doesnt or php.ini would have been found and displayed at Loaded
Configuration File.

Test 3:
a. Left the solo copy of my php.ini in C:\WINDOWS
b. Disabled PHPRC environment variable by renaming it to Ex-PHPRC and saving the
settings (note: for this test I left the Registry entry for PHP IniFilePath intact)
c. Stopped and started IIS
d. Ran "test-php-ini-loaded.php" to check whether my php.ini is loaded. Predictably
it is not found.
e. Ran the "test.php". Again, my php.ini file is reported as not found in C:\WINDOWS
though Configuration File (php.ini) Path reports it as being there.

Test 4:
a. To be thorough and eliminate all possible sources of mis-direction I deleted the
PHP IniFilePath Registry entry (after backing up the Registry). The PHPRC
environment variable was left disabled.
b. Stopped and started IIS
c. Ran "test-php-ini-loaded.php" to check whether my php.ini is loaded. Predictably
it is not.
d. Ran "test.php". Again, no change. My php.ini file is not found Configuration
File (php.ini) Path reports it as being there.

Conclusions:
The first conclusion I came to is that, in the default download version of phpinfo(
), Configuration File (php.ini) Path is hard-wired to report C:\WINDOWS whether
php.ini is there or not. Further, that C:\WINDOWS is not a default search location
(at least not on XP).

However, given an otherwise proper setup, phpinfo() reporting C:\WINDOWS as the
value for Configuration File (php.ini) Path is merely misleading and is not
actually harmful or indicative of a failed installation.

Thanks go to Peter Guy of www.peterguy.com who suggested the testing, and to Daniel
Brown of www.php.net for some initial guidance.

P.S. This note is not meant to take anything away from PHP. It is a fine tool. The
sole purpose of the testing was to confirm that my installation of PHP was correct.
Mark C in SF
13-Apr-2009 06:19
I hadn't installed PHP in years, used the PHP 5.2.9-2 installer. Selected FastCGI on
IIS, I just didn't work. On both a w2k3 server and on a Vista laptop.

First, I forget to install from ZIP, as I had before. I suggest a notice on the
download page. The message "Use of the installer isn't the preferred method for
installing PHP." is on the "Windows Installer (PHP 5.1.0 and earlier)" page. Is that
no longer true for "Windows Installer (PHP 5.2 and later)"?

Next, I found the recent Microsoft Web Platform Installer (WPI) at http://php.iis.net

It just works. There are no config settings, it just installed FastCGI on IIS on the
W2k3 server and on the Vista laptop. Took a download+install of the WPI tool, and a
few minutes for php install.

I'll likely never take a more careful look at what happened; for a production server
I'll install manually. (or use Apache :))
brian dot twardzik at usask dot ca
07-Apr-2009 05:07
Been fighting with this for a while.

Installing PHP on IIS 6.0 using the ISAPI extension.

Note, if you have a web.config file present within the Virtual Directory folder, or
otherwise configure the Virtual Directory to run ASP.NET scripts in a specific
configuration...

IIS will ignore its ISAPI obligations to render your PHP script and then cite a 401.3
error, access denied based on ACL. If you have Integrated Windows Authentication
turned on as a second authentication method, the web browser will prompt you for
credentials. If you supply some, either from the local machine or from your domain,
the website will suddenly work. This will also result in your website loading when
you reference it via Localhost. Only works with Localhost, and does not work with any
network-access IP.

Oddly enough, Anonymous impersonation will FAIL under these conditions! Why? I
suspect it is because ASP.NET scripts run under the APPLICATION-POOL USERNAME
CONTEXT. Once its kicked into that gear, any hope of using Anonymous user
impersonation may go out the window.

References:
/*******************/
Impersonation in ASP.NET:

(Look up "Impersonation in ASP.NET (IIS 6.0)" on www.microsoft.com/Technet/ )

Developer.com Article Demonstrating how ASP.NET Runs under ApplicationPools:

http://www.developer.com/net/asp/article.php/2245511

/*******************/

This, to date, is my only theory.

Filemon/Process Mon will not register any kind of failed file access attempts,
everything will appear normally. Even the presence of a BUFFER_OVERFLOW message is
normal within the context of SYSINTERNALS traces...

But if you download the IIS 6.0 resource kit, pay attention specifically to IISTRACE.

Running IISTRACE and hitting your webserver will reveal that the PHP5ISAPI filter DLL
is never called! Only the asp filter DLL.

The moral of your story? Keep web.config files out of your PHP directories!
PHP Lover
18-Sep-2008 07:33
Well, When i installed the php with its all extension i repeteadly get the following
error message "The specified CGI application misbehaved by not returning a complete
set of HTTP headers".
I followed the following steps and the problem never came again on php 5 and iis6.

1)Made a copy of all php extensions (i.e. ext directory)
2)Using the installer removed it completely. Then manually delete php.ini file.
3)Installed the php again, but this time without any extension(i.e program only) and
configured as cgi.
4)edit the php.ini file to enable the extensions and copy required extension files to
php directory.

that's it. since then i never found any problem with it. i have installed it dozen of
times like this way.
rowoot at gmail dot com
31-Jul-2008 03:13
Here is a tutorial on how to get the latest
apache, php/mysql alongwith phpmyadmin installed
in windows vista/xp.

http://www.visionmasterdesigns.com/category/wp/php/

Regards
J Veitch {a} Computer Muskoka dot - calm
28-Jul-2008 12:58
On IIS7 and Vista I got errors using Appcmd to add the handlers. I also wasn't able
to choose FastCGI when adding the handler in the IIS Manager GUI. Removal of CGI from
IIS components, a reboot, and re-adding CGI to IIS components allowed selection of
FastCGI in the GUI and made it possible to complete the configuration steps.

Here is a URL (note the complete URL is presented here as 2 lines) for another
tutorial on the process with steps for both GUI and command line configuration:
learn.iis.net/page.aspx/246/
using-fastcgi-to-host-php-applications-on-iis7/
php at vondi dot no-ip dot com
07-Jun-2008 06:44
If you get errors like this:
PHP Notice: Constant XML_ELEMENT_NODE already defined in Unknown on line 0

And many more complaining about XML constants, comment out the line:
extension=php_domxml.dll
in your php.ini. That extension seems to be compiled into PHP when you get those
errors or something else is including the functionality before that dll.
chun the man
25-May-2008 01:18
Just to note that if you are following any books about installation, of php and
apache 2.2.8, the latest edition of these application gave many people problems while
configuring it.

you might have probs getting php to work with mysql or you might get error in
myphpadmin missing mbstring, even you followed the instructions carefully.

The new php.ini reside in c:\Windows not c:\PHP or with the rest of the php
installation. But the other files still remain in c:\PHP\ext (php_mbstring.dll etc)
libmysql.dll goes in ther system32 folder.

configure your php.ini from the windows folder. :-)
Marco Tibben
08-May-2008 08:59
Installing Apache and PHP on windows Vista?

DO NOT install them in the programs file, but in locations like c:\php and c:\apache

You will end up in all kind of rights problems if you don't..

Succes!
dotpointer
25-Apr-2008 11:36
Beware!

PHP 5.2.5 + Apache 2.2

Putting thread-safe-extensions into a non-thread-safe PHP installation or the
opposite results in "Unable to load dynamic library..."-error. Errors looks like the
file could not be found, but they're misleading. File is found, but file does not
have correct content inside.

To fix this, re-run the msi-installer and install your extensions from there instead.

If you enable ALL extensions to save time, you'll soon find out you failed as many of
them will fail to load beacause of missing systems not installed on your system.
badscorp at hotmail dot com
25-Feb-2008 08:22
My experience in running php 4 and php 5 on the same machine with IIS as ISAPI module
(tested on XP Pro).

1- Extract the ZIP packages of both php 4 & php 5 to c:\php4 & c:\php5, each in its
own folder.

2- Setup the corresponding php.ini files in c:\php4 and c:\php5, by renaming php.ini-
dist to php.ini..

3- Add the Web Service Extensions for php4 and php5. For php4 use
c:\php4\sapi\php4isapi.dll, php5 use c:\php5\php5isapi.dll..

4- Add the following registry keys:

HKEY_LOCAL_MACHINE\SOFTWARE\PHP\5\IniFilePath -> c:\php5

HKEY_LOCAL_MACHINE\SOFTWARE\PHP\IniFilePath -> c:\php4

5- Add c:\php4 and c:\php5 to the PATH environment variable, separated by semis.

6- Create a session and an uploadtemp folders in any location, then add them in the
session.save_path in bothe php ini files (there are two in php4?), and give
IUSR_machinename write access to them.

7- Associate each web site in IIS with the corresponding php version.

8- Reboot..

Use phpinfo() to test it in each site.

Regards,,
Eduardo Bigai at xedco dot net
15-Jan-2008 04:40
If you get this error: "Service Unavailable" after installing PHP to a Windows XP x64
Pro, and you followed all the instructions posted in this page, you may want to try
checking the ISAPI Filters in your IIS.

Make sure your a running the 32-bit version of the
Microsoft.NET\Framework\v2.0.50727\aspnet_filter.dll.

If you are running the 64-bit version, you will notice that liested item in the ISAPI
Filters has a red arrow pointing down. This means that the service failed to load.
Delete this item from the list and add a new one. Make sure you use the one located
here: %Windows%/Microsoft.NET\Framework\v2.*\aspnet_filter.dll.

Also make sure the permissions to your PHP folder have "NETWORK SERVICE", "IUSR_*",
"SYSTEM" included.

I hope this helps you saving some precious time
sediaz at simpleonlinehelp dot com
08-Jan-2008 05:02
For those of you that would like visuals, there's a video tutorial that will help you
get PHP5 installed on Windows 2K3 w/ IIS6.

It's pretty straight forward.

The link to the site, if you're interested, is:
http://www.videotutorialzone.com

The title is:
Installing PHP5 on Windows 2003 and IIS6

I hope this helps others as it did me.

Scott
smileclick at hotmail dot com
23-Dec-2007 03:02
Still Can't Run PHP Code?

After installing php-5.2.5-win32-installer.msi on my Windows XP2. with IIS5.1 it
still didn't run PHP files.

I eventually found the fix*:

1. Goto Control Panel>System>Advanced>Environmental Variables
2. Add a New System Variable "PHRC" and set its path as "C:\Program Files\PHP"
3. Restart

*source:
http://us2.php.net/manual/en/faq.installation.php
#faq.installation.addtopath
robert dot johnson at icap dot com
13-Dec-2007 03:19
IIS setup: 403 forbidden error.

We had installed two separate different PHP versions - PHP 5.1.4 followed by 5.2.5.

We configured 5.2.5 php5isapi.dll to be loaded as the .php file type extension.

Despite this, php version 5.1.4 was being loaded. We renamed 5.1.4's folder and then
PHP was not loading at all.

There were no visible references to 5.1.4 in the IIS configuration, but in the file
\webConfig.xml, there was a reference to 5.1.4's isapi under IISFilters.

To fix this problem, we added version 5.2.5's php5isapi.dll to the ISAPI Filter
category for the web site, in the IIS control panel.
Philip Thompson
28-Nov-2007 07:13
If you use the installer for Windows (PHP >= 5.2.x) and you want the mysql_*
functions to be used, you may have to restart your machine after you install.

I was getting the error "Call to undefined function mysql_connect..." However, I knew
that my php.ini settings were correct and I was including php_mysql.dll. When I
viewed phpinfo(), it was not showing that MySQL was part of the install. My first
thought was to restart Apache - this did not change anything. So, then I restarted
the machine, viewed phpinfo() again and it was now there.

I've manually installed several times on Windows and not had this problem. This was
my first time running the installer. I think it may have something to do with setting
registry values or changing environment variables. Nonetheless, hope this helps.
scott dot thomas @t inin d0t com
09-Nov-2007 04:34
Just a note on impossible to figure out 404 errors regarding include statements, NTLM
authentication, and images (IIS/PHP):

My php pages with include functions were returning 404 errors and it turned out it
was because every include include page included an image in the wrong directory. As
you can see when /knowledge/addin/img/li.gif is not found (404) the index.php is also
returned as 404. What led me down the wrong path was the fact that the domain user
was not present in the request for the index.php when an include was
present. Changing my style sheet to load /knowledge/img/li.gif (the correct location
of the image) cause the entire page to come back OK (200) and use the proper domain
user for NTLM authentication. If I hadn't happened across this by accident I don't
know that I would have ever figured it out.

GET /knowledge/addin/img/li.gif - 80 - 172.16.128.43
404 0 3
GET /knowledge/index.php do=newarticle&type=qa 80 - 172.16.128.43
404 0 0

GET /knowledge/img/li.gif - 80 domain\scott.thomas 172.16.128.43
200 0 0
GET /knowledge/index.php do=newarticle&type=qa 80 domain\scott.thomas 172.16.128.43
200 0 0
infortechpro at yahoo dot com
06-Nov-2007 10:00
Hello,

I had trouble setting up PHP 5 to work IIS 5 (Windows 2000).

I keep getting a HTTP 500 error.

I checked the php5isapi.dll file path, the permissions and all that but the error did
not go way.

The way I got it to work was by adding the IUSR_(machine name) and IWAM_(machine
name) account to the administrators group and restarting the computer.

I hope this helps someone out there.

Cheers.
snapper
22-Oct-2007 08:34
Regarding the "No input file specified." problem where 404 error pages aren't sent if
the requested non-existent file ends in .php, this was helpful to me . . .
http://www.phpbuilder.com/board/showthread.php?t=9212

In a nutshell:

In IIS Management Console (v5.1 in my case), select "Default Web Site", right-click
and select "Properties", "Home Directory" tab, "Configuration..." under Application
Settings, "Mappings" tab, select the line for the .php file extension, select "Edit"
and check these two things:

1) ensure that executable C:\PHP\php5isapi.dll filename is not truncated
2) ensure there is a tick in the box next to "Check that file exists".

Click OK, OK, OK.

Cheers.
Uday Kari
30-Sep-2007 01:24
First I got a HTTP 405 error, resolving which I got an HTTP 404 error...read on for
how this was fixed...

Environment: PHP 5.2.4, IIS 6.0 ISAPI, Windows Server 2003.

Installation: Simply downloaded the PHP 5.2.4 installer [22,002Kb] - 30 August 2007
and ran it doing next, next until Finish.

To get rid of 405 error, ensure that your php directory allows scripts. Start-
>Control Panel->Administrative Tools->Internet Information Services-> (select
website, navigate to directory with your php and right-click your directory) ->
Properties -> Directory TAB -> Change Execute Permissions from "None" to "Scripts"
(to allow PHP).

To get rid of 404 error, ensure that your executable mapping for the .php extension
is properly coded. Start->Control Panel->Administrative Tools->Internet Information
Services-> (select web site) ->Properties->Home Directory->Configuration->Mapping and
then change the Executable Path for .php files from C:\Program~\PHP\php5is~1.DLL (or
whatever crazy path) to "C:\Program Files\PHP\php5isapi.dll"

(IMPORTANT: the quotes from c:\ to end of dll are important since the default install
location, Program Files, has a space...in my youth I would yell "Stupid
Microsoft"...but now I would more maturely just note that there is an inconsistency
with the way that Paths are defined...in definingenvironment variables, for instance,
such spaces are OK...).
osoto3 at hotmail dot com
22-Sep-2007 08:35
Another tip that might save hours of aggravation (and cursing):

I was setting the Mappings in the IIS 5.1 Manager by going to
Default Web Site -> Properties -> Home Directory -> Configuration ->Mappings

I noticed that the ".php" extension that previously I added was the only one shown in
quotes, which had been added automatically due to the fact that my PHP files are
installed in directory "D:\Program Files\PHP", which contains a blank space in its
name. All the other entries had no quotes and when I tried to take the quotes out,
IIS responded that the path was invalid. I assumed (correctly) that the quotes were
causing problems. So I copied php5isapi.dll to C:\windows (which does not have a
space in the directory name) and reentered the path without quotes in the Mappings
screen, and then ...

Finally, my browser was able to process and show my hello.php file correctly!

Hope this helps someone.
Jack Hardie
08-Sep-2007 09:33
If you are installing PHP on Vista just go to David Wang's blog.
http://blogs.msdn.com/david.wang/
archive/2006/06/21/HOWTO-Install-and-Run-PHP-on-IIS7-Part-2.aspx

Magic!
paul_lynch67 at hotmail dot com
06-Sep-2007 07:25
Hi,

I've written a manual installation guide for PHP 5.x on Windows Server 2003 and IIS
6.0 which you can find here :

http://www.iisadmin.co.uk/?p=4

This is the same article which used to be hosted on the IIS Resources web site. I
hope some of you find it useful.

Regards,

Paul Lynch [IIS MVP]
Ananda Sim
07-Aug-2007 12:00
I installed php 5.2.3 using the msi package to Windows XP SP2. First time, ISAPI
choice defaulted to installing php to c:\program files\php. The IIS Manager >
Websites > Home Directory > Extensions used the short filename. Didn't work - message
was "module not found". I then removed and installed to c:\php. That worked easily.
fabrizio dot barbarino at uniud dot it
16-Jul-2007 10:23
In order to enable your x64 version of Windows 2003 Server executing the php*.dll
through IIS, you can execute the script shown here:

http://technet2.microsoft.com/windowsserver/en/library/
36f8964c-cf86-44cf-94a4-2873ad0d175f1033.mspx?mfr=true

I've tested it with Windows 2003 Server x64 SP2 and PHP 5.2.3 and it works.

Good work,
Fabar
Jeremy Griffith
20-Jun-2007 06:46
If you have installed using the msi file, allowed it to configure IIS6 for you using
the default directory, and are receiving a 404 error (specifically 404 2 error in
your log file), then you need to modify the "application extension" for .php to
include the full quoted path. The default uses the old 8.3 convention which is not
considered the same by IIS, and therefor the web extension isn't allowed.
klugg at tlen dot pl
11-Jun-2007 08:56
If by any chance you tried to install PHP 5 and marry it with IIS (like me), you
might get into quite a frustrating situation, where separately IIS works, PHP works,
but together they spit at you a "no input file specified" without further
information.
The solution: don't set doc_root in php.ini to "c:\inetpub"! Just leave it empty or
comment it out.
Don't forget to restart IIS.
Also, the easiest way to restart IIS is through the "internet information services"
control - right click on the computer name, select "All tasks", "Restart IIS..." and
confirm.
No need to go through the cmd magic spells anymore!
imi at deltanet dot hr
06-Jun-2007 04:19
PHP 5.2.3 under IIS 5.1 (as ISAPI) and Windows XP

If you have trouble trying to get run the combination above using PHP installer
please make sure that your executable path for .php file on IIS has been written
correctly.

Start->Control Panel->Administrative Tools->Internet Information Services-> (then
select your web site) ->Properties->Home Directory->Configuration->Mapping and then
change the Executable Path for .php files from C:\PHP\php5is~1.DLL to
C:\PHP\php5isapi.dll
jcwebb at dicoe dot com
16-May-2007 08:50
PHPv522 configuration considerations (php.ini) on Win3k(iis6)

cgi.force_redirect = 0
++ You MUST set this (its commented out by default)

two new settings are included...
session.save_path = "C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\php\session"
upload_tmp_dir = "C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\php\upload"
++ sessions will fail: $_SESSION['something'] unless you deal with permissions on the
new location,
or simply comment out the session.save_path and go back to default "c:\windows\temp"
amoo_miki at yahoo dot com
14-May-2007 08:29
Trying to get PHP run under IIS7 (on Vista) you might find that PHP crashes at
startup.

The reason seems to be GD2 needs mbstring while the attempt to load GD2 is being made
before mbstring is loaded. While it was clear that an attempt to load it was made by
GD2, but it never got loaded causing the crash and error.

Simply moving mbstring to the top of the list solved the issue.
Load mbstring as the first extension in your php.ini.
davideatarkehostdotnet
07-May-2007 02:16
i have encountered always the same problem installing php on windows 2003 (it always
worked fine with w2k) "php has encountered an access violation at xxxx". tried php5.x
and downgrade to php4.x without success. problem was solved only by giving r+w+e
permission on php folder to user IIS_WPG
i_robot73 at hotmail dot com
23-Apr-2007 02:30
Running on Win2k3 x64 w/ IIS6. Followed the BASIC setup (unzip, PHPRC, add extension
to IIS) and still no go.

Wasn't until I enabled x86 that it 'popped':

cscript d:\inetpub\adminscripts\adsutil.vbs SET W3SVC/AppPools/Enable32bitAppOnWin64
1

No security issues that needed fixing. Test .php file came up like a champ!
Sirichai
26-Mar-2007 08:06
Another Tips:

1. I've tried many ways installing PHP on IIS5.1 (WinXP) Many resources on the
internet recommended to use a zip package, but the fact is it doesn't work.(geeez) It
is a lot easier to go for the MSI installer and be sure to check those IIS functions
and other extensions in the installer wizard.

2. If you got an ERROR404 on any Virtual Directory on IIS5/IIS6, but html files are
displayed correctly, just edit php.ini and empty doc_root

3. If the sourcecode of php file is printed instead of the compiled one, just change
all short tags <? /* Like this. */ ?> to full tags <?php /* Like this. */ ?>

4. If you want to connect to mssql server on IIS platform, you HAVE TO add this in
the registry
HKEY_LOCAL_MACHINE\SOFTWARE\M*icrosoft\ MSSQLServer\Client\ConnectTo]DSQUERY=DBNETLIB

It is amazing that everybody MUST follow these rules above, but I didn't see any of
them appeared on php official site nor top google rankings.

cheers.
christian dot ulbrich at gmx dot de
13-Jan-2007 07:15
I have an IIS 6.0 with PHP 5.2.0 as ISAPI-module. Installation went fine, using one
of the numerous guides available, however I couldn't get my PHP to load any
extensions!

It took me quite a while, to find the catch, it seems, that PHP 5.2.0 doesn't like
the quotation marks " in some of its directory variables.

Thus, changing

extension_dir = "c:\php\ext\"

to

extension_dir = c:\php\ext\

did the trick for me...
john@ellingsworth
13-Nov-2006 01:06
Another cause of the "No input file specified" on systems with multiple hosts is that
the doc_root setting in the php.ini file has been set to a specific directory. When
using IIS with multiple hosts in distinct top level directories you should comment
the doc_root line out.
jneill at gamedaytv dot com
09-Nov-2006 01:36
Here's how to run dual PHP instances with PHP 5.2 and any previous PHP on Windows
2003:

1. Right-click My Computer, go to Advanced tab, and click on Environment Variables.

Add the two installations and their EXT directories to the Path variable. For
example, add:
c:\php;c:\php\ext;c:\TMAS\php;c:\tmas\php\ext;

Then, add the newer PHP version's directory as a variable called PHPRC. For example:
Variable:PHPRC
Value: C:\PHP

Click OK to close the Environment Variables window, and click OK to close System
Properties.

2. In registry, under HKEY_LOCAL_MACHINE>SOFTWARE>PHP, add a REG_SZ key called
iniFilePath and give it a value
of the directory where the older PHP is installed. For example:
C:\TMAS\PHP

3. In IIS, go to the Web Service Extensions. Add both versions' ISAPI module
separately to the extensions
list, and allow both.

4. In IIS, go to each website utilizing the PHP versions. Set an ISAPI filter if
needed. On the Home Directory
tab, click Configuration, and add .php, .php3, .phtml, and any other extensions
needed (perhaps .html?) to
be filtered through PHP, and specify the ISAPI module version needed for each
website.

You can now run two versions of PHP. This is because the order of where to look for
the .ini file changed
between previous PHP versions and PHP 5.2, as documented at http://us2.php.net/ini:

---------------------------------------------------
php.ini is searched in these locations (in order):

* SAPI module specific location (PHPIniDir directive in Apache 2, -c command line
option in CGI and CLI, php_ini parameter in NSAPI, PHP_INI_PATH environment variable
in THTTPD)
* The PHPRC environment variable. Before PHP 5.2.0 this was checked after the
registry key mentioned below.
* HKEY_LOCAL_MACHINE\SOFTWARE\PHP\IniFilePath (Windows Registry location)
* Current working directory (for CLI)
* The web server's directory (for SAPI modules), or directory of PHP (otherwise
in Windows)
* Windows directory (C:\windows or C:\winnt) (for Windows), or --with-config-
file-path compile time option
----------------------------------------------------
afitzs at for-finance dot com
08-Nov-2006 07:11
I have found the following procedure to work correctly EVERY time for installing PHP
version 5.x.x on Windows 2003 servers. (I have done over 100 of these on Web,
Standard & Enterprise)

1. Download the current PHP Zip file to a folder of your choosing.

2. Download the old Installer.exe (I use 5.0.2)

3. Run the installer and accept the defaults in all cases except the IIS server,
choose IIS 6.0 or later. The installer will complain that a script map is not
registered and ask you if you want to register it. SAY YES!!!

4. Run the installer a *second* time, using the same settings as above. This time
instead of the complaint that a script is not registered you should see a black dos
box open and then close. This is your clue that the install was successful.

5. Copy your PHP .zip file to c:\php and extract and overwrite all files from the
regular installer.

6. Edit c:\windows\php.ini to enable any extensions you may need and to set the
extension directory to c:/php/ext

All should be good to go. Test by running an info() from the web server.

I have used this install on over 100 installs of 2003/IIS web servers. Generally they
have been virgin installs, but a few have had existing sites on them. Using the above
method I am able to install PHP in under 2 min. Of course, these are windows systems
thus your mileage may vary.

Note: I just tried to use the new .msi installer without success. Resorted to the
above procedure and now have 5.2.0 running on the new server.

Note2: PHP powers that be, please make a copy of the old installer available again
somewhere easily found by people. I would be screwed if I had not kept an archive
copy of the 5.0 installer.
webmaster at nachelfamily dot com
08-Nov-2006 01:13
I made the mistake of setting a 'wildcard application map' for PHP on a Windows 2003
/ IIS 6.0 / PHP ISAPI installation.

This resulted in "No input file specified" errors whenever I tried to load the
default page in my site's directories. I don't know why this broke things, but it
did.

If anyone has the same problem, this may be the cause.
yacahuma
05-Oct-2006 07:44
IIS6 AND PHP5 on w2k3
1.download php and unzip to c:\php
- also create c:\php\sessions
2.add c:\php to you path
-right click mycomputer,properties,advance,env variables
2.On IIS Manager add web service extension
-name: php isapi
-req files: c:\php\php5isapi.dll
3.Now let iis know what to do with .php
-On iis Manager,right click Web Sites, properties, home directory tab,
configuration button, add button
executable: c:\php\php5isapi.dll
extension: .php
limit to: GET,POST,HEAD
4. rename php.ini-recommended to php.ini
you can copy php.ini to c:windows or modify the registry to look for php.ini in
c:\php
to use the registry create a php.reg file with the following inside. after this
just double click. do not put the lines.
-------------------------------------------------
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\PHP]
"IniFilePath"="C:\\php"
-------------------------------------------------

5. modify php.ini with
short_open_tag = On
extension_dir = "c:\php\ext"
cgi.force_redirect = 0

6. the web sites are going to be using the default pool. this runs under network
service. go to c:\php and give the network service read& execute, list folder
content,read
-go to c:\php\sessions and add write and modify access network service
winterspan - AT - g m a i l . /C/O/M
20-May-2006 04:57
READ HERE If installing PHP 5.x on Windows Server 2003 / IIS 6.x ...
It was extremely frustrating getting this to work, so hopefully my struggle will
allow others to do this the *easy* way.
BEFORE installing PHP 5 from a web tutorial (a good one found here:
http://www.peterguy.com/php/install_IIS6.html)
You need to READ THESE TIPS:

#Necessary Permissions For WinServer 2003 / IIS6.0#

These are the permission settings I found to work well with good security:
NTFS permissions (right-click file or folder, select preferences, go to security tab)

1) PHP Install folder -> You need to give NT account: 'Network Service' read/execute
permissions on the 'php' install folder (e.g., C:\\PHP). If you have a TMP or SESSION
folder within the main PHP folder, you need to give account 'Network Service'
read/execute AND write access on those folders. *(You DO NOT need to give the
anonymous internet user account: 'IUSR_[name]' ANY permissions on the PHP INSTALL
files themselves. )*

2) You DO need to give account: 'IUSR_name' Read/execute
permissions on the actual WWW root folder and web .php files (if you want to apply to
all sites) or each websites WWW root and .php files if running multiple sites.

3) Within the IIS 6.0 console itself, in the website's preferences (right click on
ind. site or 'websites' node to apply to all sites -> select preferences) on the
'Directory Security' tab -> click edit, and if you wish to allow anonymous access to
your site, check the anonymous access box and be sure to enter account: 'IUSR_name'.

4) *MOST IMPORTANT*
As mentioned by a few others, install php and configure the php.ini WITH NO
EXTENSIONS AT FIRST. The reason being if one of the extensions fail, the error dialog
will pop up OUTSIDE of a terminal services window (remote desktop). So you will NOT
BE ABLE to click on the error, and the websites php file you are trying to load in
your browser will hang indefinately (after having this happen for 12 hours I almost
went insane trying to figure out the problem) LOL.

Then when you have successfully loaded a test php page in the browser, go back to the
php.ini file and add extensions in one at a time.

If YOU have any tips I haven't included, email me. Again,
I am not a professional, still a student in learning. :)

Now that you have read that, go back to the link I placed near the top, and follow
his tutorial for general installation/setup.
Nestor Custodio
04-May-2006 03:40
If the path to your PHP directory has spaces (e.g. "C:\\Program Files\\PHP") and IIS
gives a 500+ error or responds with "The specified module could not be found." when
you try to run a PHP script, try changing the ISAPI DLL's path in IIS (in the "Home
Directory" tab, under "Configuration...") to the 8.3-equivalent path.

That is, use C:\\PROGRA~1\\PHP\\php5isapi.dll instead of "C:\\Program
Files\\PHP\\php5isapi.dll".
Cam McVey
20-Apr-2006 10:48
If you are using Application Pool Isolation and you're trying to get PHP to run as
CGI and you're getting 403 errors, try looking at this article (watch the word wrap):
http://www.servertastic.com/articles/2005/11/
unable-to-run-perl-or-php-in-application-pool-isolation/
SmugWimp at smugwimp dot com
20-Apr-2006 09:29
If you make changes to your PHP.ini file, consider the following.

(I'm running IIS5 on W2K server. I don't know about 2K3)

PHP will not "take" the changes until the webserver is restarted, and that doesn't
mean through the MMC. Usually folks just reboot. But you can also use the following
commands, for a much faster "turnaround". At a command line prompt, type:

iisreset /stop

and that will stop the webserver service. Then type:

net start w3svc

and that will start the webserver service again. MUCH faster than a reboot, and you
can check your changes faster as a result with the old:

<?php>
phpinfo();
?>

in your page somewhere.

I wish I could remember where I read this tip; it isn't anything I came up with...
ratkinson at tbs-ltd dot co dot uk
04-Apr-2006 12:28
When installing onto the Windows IIS platform, ensure you add the PHPRC Server
Variable to point to your PHP.INI file.

Also, add '.INI' to the FILEEXT Server Variable. Failure to add these could stop the
PHP engine being able to find your PHP.INI file, and none of your modifications will
be read.

Rob.
niatech
01-Mar-2006 04:36
Thought someone would save some time and headaches by using this post.

Our tech department is migrating to Windows 2003 Server and they have some complex
security implementations between our Web Servers and our Application (COM) servers.

If you have this type of scenario and are receiving the "Warning (null)(): Unable to
lookup.... Access is denied." error, it is because the "Identity" in the Web Server's
application pool does not have sufficient permissions to connect to the Application
(COM) Server.

To fix this:

- create a new Application Pool
- right click the new pool and select "properties"
- click on the "Identity" tab
- change the permissions from "Network Service" to a user on the Web Server who has
access to call the Application (COM) server.
- right click the application pool
- click "start"
- right click your web site
- click on the "Home Directory" tab
- change the application pool to the new application pool you've just created.
- restart IIS

Hopefully this will save someone some time and headaches.
mach
28-Feb-2006 02:15
I've installed Apache + PHP on a Windows machine of which I'm not an administrator.

I found out it was necessary to change the permissions of the httpd.conf file on
C:\Program Files\Apache Group\Apache\conf in order to have everything working. Since
I'm also using cygwin this was simply done with: >chmod 755 httpd.conf.
lukasz at szostak dot biz
15-Jan-2006 03:50
You can have multiple versions of PHP running on the same Apache server. I have seen
many different solutions pointing at achieving this, but most of them required
installing additional instances of Apache, redirecting ports/hosts, etc., which was
not satisfying for me.
Finally, I have come up with the simplest solution I've seen so far, limited to
reconfiguring Apache's httpd.conf.

My goal is to have PHP5 as the default scripting language for .php files in my
DocumentRoot (which is in my case d:/htdocs), and PHP4 for specified DocumentRoot
subdirectories.

Here it is (Apache's httpd.conf contents):

---------------------------
# replace with your PHP4 directory
ScriptAlias /php4/ "c:/usr/php4/"
# replace with your PHP5 directory
ScriptAlias /php5/ "c:/usr/php5/"

AddType application/x-httpd-php .php
Action application/x-httpd-php "/php5/php-cgi.exe"

# populate this for every directory with PHP4 code
<Directory "d:/htdocs/some_subdir">
Action application/x-httpd-php "/php4/php.exe"
# directory where your PHP4 php.ini file is located at
SetEnv PHPRC "c:/usr/php4"
</Directory>

# remember to put this section below the above
<Directory "d:/htdocs">
# directory where your PHP5 php.ini file is located at
SetEnv PHPRC "c:/usr/php5"
</Directory>
---------------------------

This solution is not limited to having only two parallel versions of PHP. You can
play with httpd.conf contents to have as many PHP versions configured as you want.
You can also use multiple php.ini configuration files for the same PHP version (but
for different DocumentRoot subfolders), which might be useful in some cases.

Remember to put your php.ini files in directories specified in lines "SetEnv
PHPRC...", and make sure that there's no php.ini files in other directories (such as
c:\windows in Windows).

And finally, as you can see, I run PHP in CGI mode. This has its advantages and
limitations. If you have to run PHP as Apache module, then... sorry - you have to use
other solution (the best advice as always is: Google it!).

Hope this helps someone.
phil at pelanne dot com
05-Jan-2006 05:22
For those of you trying to install PHP 4 and PHP 5 concurrently on a windows 2003
box, there is just one rule you need to adhere to in order to make it work:

- Don't have either of them in c:\php\.
- Don't have a php.ini in your system32 directory.

Put PHP 4 into a directory called c:\php4\. Put its php.ini in there, and make sure
all the paths reflect the c:\php4 directory.

Likewise, put PHP 5 into a directory called c:\php5\. Put its php.ini in there, and
make sure all the paths reflect the c:\php5 directory.

Add them as allowed script mappings in your iis extensions area, and have fun!
cormierma_at_csdcso.on.ca
21-Dec-2005 09:34
Note to windows server 2003 users

If you install php5 ISAPI on windows server 2003 / IIS and keep getting a 404 when
you try to view a php script don`t just activate "all unknown ISAPI extensions" but
also activate "All Unknown CGI Extensions".
Cevher Bozkur
13-Oct-2005 01:37
I've installed php 5.0.5 with the ISAPI module, as the isapi dll file (php5isapi.dll)
resides in the php root directory, I didn't have trouble in my installation (In php4
this dll file is in sapi directory and it should be moved to php root directory).

I changed some of my settings in php.ini file and restart IIS Web site,but my changes
weren't applied.

Then I go to Control Panel>Administrative Tools>Services and restart the IIS Admin
Service.

Everything worked like a charm...
william keith
28-Sep-2005 10:51
Dirt Simple Install Guide For PHP5/W2K Servers

For those of us out there who still have 2K servers, this is a great 3 min step by
step to get you up and running.

http://www.onlamp.com/pub/a/php/2000/12/14/php_admin.html

Thanks to it's author, Darrell Brogdon!
thedeadraptor2000 at yahoo dot com
30-Aug-2005 03:02
Note regarding PHP4 Installation on IIS5 + Win2K

Tip: Don't install PHP4 on Directories with spaces in between.

I've had problems Installing PHP 4.0.0 on IIS5, Win2k's default web server, spanish
version (I live in Colombia). I've had HTTP 500 Errors and I followed all
instructions step by step, but nothing seemed to work.

I solved the problem eventually, and I think it had something to do with the fact
that I have installed PHP4 manually and placed it in the directory "C:\Archivos de
programa\php-4.4.0-Win32" ('Archivos de programa' stands for 'Program Files'), a
directory with spaces in between.

When I added the application mappings for "C:\Archivos de programa\php-4.4.0-
Win32/sapi/php4isapi.php", An error would ocurr and a message along with it: "Escriba
una ruta de acceso valida", as in "Write a valid access rute", as in "I can't find
the file".

I thought i had it when I encapsulated it with Doublequotes ("), but that didn't work
either.

As a final long shot, I copied the php4isapi.dll to the windows/system32 directory
and 'WALA!' It worked.

I'm not sure, but i suspect that it had to do with spaces in between directory names,
so avoid those, or copy the isapi module to another directory.

Hope this helps someone!
wappa at hotmail dotandthekangaroo com
05-Aug-2005 03:16
Don't forget if you are getting ACL exceptions to reading the test php page you have
created you MUST share the PHP directory or the resources PHP uses to "everyone" but
remember use restricted access for security.
jp at iticonsulting dot nl
23-Jul-2005 04:42
If you get 404 page not found on Windows/IIS5, have a look at
C:\SYSTEM32\INETSRV\URLSCAN

There is a .ini file there that prevents some files from being served by IIS, even if
they exist, instead IIS will give a 404. The urlscan logfile (same place) should give
you some insight into what parameter is preventing a page from loading, if any.
Feroz Zahid
08-Jun-2005 08:41
In order to run php scripts with php.exe CGI instead of php4isapi.dll under IIS,
following steps can be followed.

i) Add a web service extension for PHP using IIS manager. Choose a web service
extension name like 'PHP' and add your php.exe path in the 'file location' while
adding the required file e.g. 'C:\php\php.exe' in the Add extension dialog box. Don't
forget to 'Allow' the extension file.

ii) Open php.ini file located at %systemroot%. Set the following variables to the
shown values.

cgi.force_redirect = 0
cgi.redirect_status_env = ENV_VAR_NAME

iii) In your websites, add Application Mapping for '.php' and set the executable path
to your php.exe file path.

You can test whether PHP is running or not and other PHP settings using the following
simple PHP script.

<?php>
phpinfo();
?>

Feroz Zahid
ferozzahid [_at_] usa [_dot_] [_com_]
donald at netriver dot net
04-May-2005 08:21
On the Windows 2003 & IIS6 platform, you can run different websites on different
versions & copies of PHP. This is useful in at least two cases:

1. You want one website on your box to have register_globals on, but since you're
running IIS, you cannot specify that in an .htaccess file. And you definately don't
want register_globals on for the rest of the websites.
2. You want to run different versions of PHP for different websites, or even just
different extensions. Say you wanted one site to use 4.0.5 and a different site to
use 4.1.11.

Its simple, just:
1. Move your php.ini file from your c:\windows\ directory directly to your php
directory (by default that would be c:\php\)
2. Make sure you don't have a php.ini file in any other location that would
supercede the c:\php\php.ini file. Using phpinfo(); is useful here.
3. Have your alternate version of php (either a different version or a different
php.ini) have its own install directory, like c:\php4RG\ or c:\php405\.
4. In the Home Directory Configuration for your website, specify the .php extension
to use a different script, pointing it at the alternate directory.
doyouunderstand at gmail dot com
04-Mar-2005 12:31
For those having trouble installing PHP 5+ ISAPI for IIS 6 (on Windows 2003 server),
who have tried everything on this site and all over the net, with no success (like I
did) - try the following before throwing your server out of a 3rd story window.

http://www.benmardesign.com/IIS_PHP_MYSQL_setup/php_setup.html

It was the only thing that worked out of all the many solutions I tried.

Probably some other solutions would've worked as well, but in my frusterated state of
mind, this explanation was the clearest.

My problem was that in addition to adding the the Web service extension, I was not
adding the ISAPI extensions for the websites in IIS Manager manaully. ALSO, remember
to reboot after the changes on the site listed above. It's the only thing he forgot
to mention, and depending on your setup, you may need to reboot to register the dll
moves and changes made. (IIS restart will not re-register dlls).
Steve N
02-Feb-2005 04:33
Just a note following on from Luis D regarding adding the pgp4ts.dll as a Web Server
Extension.

I just used the latest php-4.3.10-installer.exe from php.net and had the problems
where .php files could not be found.

In order to get them to work I added and allowed the php.exe as a Web Service
Extension and not the php4tx.dll.

Cheers,

Steve
claudio_jvt at hotmail dot com
14-Jan-2005 12:38
One very helpfull note to Win2003 iis6 users:
If you'd like to use isapi in the web service extensions and you're in a development
server (or even if your php.ini config file changes frequently), here's what you can
do:

Php.ini runtime changes:
Create a new application pool in iis:
iis->select server->application pools->new application pool
Use default settings;
go to the application pool you've created, properties->
check the "Recycle worker process" option, and give it a small value (10 is nice
:) ).

Now go to your site (or virtual directory site)-> properties->
change the application pool to the newly configured appPool.

At this moment, is good to make a iss restart (note this is the only resart needed).

Your site is now semi-runtime changed :)
You can try it with the usal php info() test. Change something in the php.ini and
check the number of requests it takes to use the new configuration.

The downside of this approach (wich is still better than to use php-cgi.exe): the
process is recycled, so all the configuration in php.ini is read every N requests -
with php-cgi.exe, this would happen for every request, so.. is a good solution.

Again, be carefull when using this in a production environment, since the load can
increase (not sure how much, but it will certainly increase).

And keep in the new appPool JUST the php sites that require runtime changes in
php.ini !

------
You've helped me, so I help you ;)
Tks
chris at move dash media dot com
10-Jan-2005 12:39
Note to windows users, if you are trying to install php5 ISAPI on windows server 2003
/ IIS and getting a 404 when you try to view a simple php script, even though
everything else seems to be right... click into "web service extensions" from IIS
and either add a new web service extension, or click onto "all unknown ISAPI
extensions" and click allow.
ntadmin at aplus dot net
27-Aug-2004 06:53
When configuring application pools with configurable
accounts instead of NETWORK SERVICE or LOCAL SYSTEM
remember to add the user to the correct security contexts found here:

Note: Watch for wordwrap
http://www.microsoft.com/resources/documentation/
WindowsServ/2003/standard/proddocs/en-us/Default.asp?
url=/resources/documentation/WindowsServ/2003/standard/
proddocs/en-us/sec_acc_wpenable.asp

Otherwise you will recieve 403 errors.
Sean Boulter
15-Apr-2004 09:00
This fixes the "The directory name is invalid" error.

In IIS 5.1 on Windows XP Pro, Go into the Internet Information Services, and into the
properties of the virtual directory where the problem occurs. On The 'Virtual
Directory' tab, click on the 'Configuration...' button. Select the '.php' extension,
and press 'Edit'. On the bottom, Check the 'Check that file exists' checkbox.
Luis D
27-Mar-2004 12:49
This is just to clarify on a posting on this page that states the nescesity of
allowing all unknown cgi Extensions in Windows 2003 IIS 6. Although this will work
and it should be consider as a quick option for an itranet solution with no web
access at all.

This poses a very serious security problem and its not the best course of action, in
my opinion. The proper way of making this work will be to actually enable the
extension that you want to execute. After verifying that the .php extension is
present, simply go to "Web Service extensions" in the IIS Manager and click on "Add a
new web service extension";

Once the "new web service extension" opens:

1- Add the "extension name" field, please enter "PHP" (or what ever you wanna call
it) Other more conservative admins will say call it what it is and always input
".php". Its up to you!
2-Click on the "add" button and browse to the php4ts.dll file on your c:\PHP
(default) and then click open --> OK and set the checkmark under "set extension
status to allowed" click OK and thats it!!!

If you missed the checkmark moment cause you are just so impatient, like me, then
simply select the extension on the web service extensions windows and click ALLOW.

This is a very simple process and it will work everytime.

I hope this helps, as I have found several things in this forums that are incredibly
helpfull!!

PS: For the non programmer, it is a good practice to install mysql and a free php
forum like bb2 to test how well your php IIS and mysql is working.
ferchland at computer-kontor dot de
06-Feb-2004 04:51
If need a php4apache.dll compiled with EAPI _and_ you run Apache with mod_ssl, use
the Apache from
http://hunter.campbus.com/

This is already a binary for win32, but the *.lib and headers are included.
ungdi at hotmail dot com
21-Jan-2004 09:36
Under a Windows 2003 and IIS 6.x installation of PHP, it is interesting to note that
by default in most cases, the "DefaultAppPool" for the "Default Web Site" is running
under the security context of "Network Service" which maybe too restrictive. This
results in a 403: Forbidden error every time you try to access a PHP page.

You have several options to remedy the problem:
an obvious one is to make it run as the "Local System", but that may be too much
power for some administrators' tastes.

The other option is at the IIS Manager,
go to the computer's "Application Pools" folder,
and go to the properties dialog box of the "DefaultAppPool",
and then to the "Identity" tab, and select the "Configurable" identity of
"IWAM_[COMPUTER_NAME]" as the security context. This will make the application pool
run the way it did in the previous versions.

This solved the repeated problems of the 403 errors. However, do not forget to give
permission to "IUSR_[COMPUTER_NAME]" and "IWAM_[COMPUTER_NAME]" appropriate directory
permissions for your web directories as stated above.
spf at users dot sf dot net
19-Aug-2002 03:55
To allow acWEB.sf.net win32-webserver and Eserv 2.98 (www.eserv.ru) web-server run
PHP 4.2.2 without problems with FORCE_REDIRECT you should set "cgi.force_redirect =
Off" in php.ini in windows directory.
adam dot swick at pantellos dot com
15-Mar-2002 05:36
IIS 5: If you change the application mappings for PHP (for example, from CGI to ISAPI
module), reboot after the change is made. The PHP Application Mapping change may
cause a conflict if ISAPI applications are cached.
mike at schild dot com
01-Aug-2000 05:44
It's a hard way to get work php on win98/PWS... but with this comment-page I found it
out how it works:<br>
- error 403: give read/write rights to the directory. You can do this by clicking the
right mouse key on the directory in the explorer.<br>
- html file in a dos box: 1) clean the "doc_root" line in the php.ini file. 2)
start personal web-manager / go to 'advanced' / make for your web-default-directory a
virtual directory with all possible rights.<br>
On my system it works now!
Windows Installer (PHP 5.1.0 and earlier)
The Windows PHP installer is available from the downloads page at
http://www.php.net/downloads.php. This installs the CGI version of PHP and for IIS, PWS,
and Xitami, it configures the web server as well. The installer does not include any extra
external PHP extensions (php_*.dll) as you'll only find those in the Windows Zip Package
and PECL downloads.
Note: While the Windows installer is an easy way to make PHP work, it is restricted in many
aspects as, for example, the automatic setup of extensions is not supported. Use of the
installer isn't the preferred method for installing PHP.
First, install your selected HTTP (web) server on your system, and make sure that it works.
Run the executable installer and follow the instructions provided by the installation wizard.
Two types of installation are supported - standard, which provides sensible defaults for all
the settings it can, and advanced, which asks questions as it goes along.
The installation wizard gathers enough information to set up the php.ini file, and configure
certain web servers to use PHP. One of the web servers the PHP installer does not configure
for is Apache, so you'll need to configure it manually.
Once the installation has completed, the installer will inform you if you need to restart your
system, restart the server, or just start using PHP.
Warning
Be aware, that this setup of PHP is not secure. If you would like to have a secure PHP setup,
you'd better go on the manual way, and set every option carefully. This automatically
working setup gives you an instantly working PHP installation, but it is not meant to be used
on online servers.
Windows Installer (PHP 5.2 and later)
The Windows PHP installer for later versions of PHP is built using MSI technology using the
Wix Toolkit ( http://wix.sourceforge.net/). It will install and configure PHP and all the built-
in and PECL extensions, as well as configure many of the popular web servers such as IIS,
Apache, and Xitami.
First, install your selected HTTP (web) server on your system, and make sure that it works.
Then proceed with one of the following install types.
Normal Install
Run the MSI installer and follow the instructions provided by the installation wizard. You will
be prompted to select the Web Server you wish to configure first, along with any
configuration details needed.
You will then be prompted to select which features and extensions you wish to install and
enable. By selecting "Will be installed on local hard drive" in the drop-down menu for each
item you can trigger whether to install the feature or not. By selecting "Entire feature will be
installed on local hard drive", you will be able to install all sub-features of the included
feature ( for example by selecting this options for the feature "PDO" you will install all PDO
Drivers ).
Warning
It is not recommended to install all extensions by default, since many other them require
dependencies from outside PHP in order to function properly. Instead, use the Installation
Repair Mode that can be triggered thru the 'Add/Remove Programs' control panel to enable
or disable extensions and features after installation.
The installer then sets up PHP to be used in Windows and the php.ini file, and configures
certain web servers to use PHP. The installer will currently configure IIS, Apache, Xitami,
and Sambar Server; if you are using a different web server you'll need to configure it
manually.
Silent Install
The installer also supports a silent mode, which is helpful for Systems Administrators to
deploy PHP easily. To use silent mode:

msiexec.exe /i php-VERSION-win32-install.msi /q
You can control the install directory by passing it as a parameter to the install. For example,
to install to e:\php:

msiexec.exe /i php-VERSION-win32-install.msi /q INSTALLDIR=e:\php
You can also use the same syntax to specify the Apache Configuration Directory
(APACHEDIR), the Sambar Server directory (SAMBARDIR), and the Xitami Server directory
(XITAMIDIR).
You can also specify what features to install. For example, to install the mysqli extension
and the CGI executable:

msiexec.exe /i php-VERSION-win32-install.msi /q ADDLOCAL=cgi,ext_php_mysqli
The current list of Features to install is as follows:

MainExecutable - php.exe executable ( no longer available as of PHP
5.2.10/5.3.0; it is now included by default )
ScriptExecutable - php-win.exe executable
ext_php_* - the various extensions ( for example: ext_php_mysql for MySQL )
apache13 - Apache 1.3 module
apache20 - Apache 2.0 module
apache22 - Apache 2,2 module
apacheCGI - Apache CGI executable
iis4ISAPI - IIS ISAPI module
iis4CGI - IIS CGI executable
iis4FastCGI - IIS CGI executable
NSAPI - Sun/iPlanet/Netscape server module
netserve - NetServe Web Server CGI executable
Xitami - Xitami CGI executable
Sambar - Sambar Server ISAPI module
CGI - php-cgi.exe executable
PEAR - PEAR installer
Manual - PHP Manual in CHM Format
For more information on installing MSI installers from the command line, visit
http://msdn.microsoft.com/en-us/library/aa367988.aspx
Upgrading PHP with the Install
To upgrade, run the installer either graphically or from the command line as normal. The
installer will read your current install options, remove your old installation, and reinstall PHP
with the same options as before. It is recommended that you use this method of keeping
PHP updated instead of manually replacing the files in the installation directory.



Manual Installation Steps Windows Installer (PHP 5.1.0 and earlier)

Last updated: Fri, 11 Jun 2010

User Contributed Notes
Windows Installer (PHP 5.2 and later)
fawaz at webcitynetworks dot com
09-Mar-2010 10:24
Tryed installing PHP several times using the MSI instalation, which defaults to
"C:\Prorame Files\PHP", and could not work at all.

The OS: Windows XP, with SP3
Web Server: IIS 5.1

Instalation Steps:

Step 1: Install the MSI Instalation, but make sure you select the instalation folder
to be "C:\PHP" and NOT "C:\Programe Files\PHP\".

Step 2: Copy the "php.ini" fil from "C:\PHP", to "C:\Windows\" folder. Keep the
default settings, so far OK.

Step 3: Go to IIS, Open "Default Website", Properties, and open the "Home Directory"
tab, and then "Configue" buttton.

Step 4: Click 'Add" under Mappings Tab, and browse for "C:\PHP\php-cgi.exe" file from
'Browse', and add ".php" (i.e. without the Qoutes ""). Keep "Verb" settings to "All
Verbs" and click "OK"

Step 5: Create a php file with : <?php phpinfo();?>, and test.

It should be working fine by this time.

Hope this was helpful to all.
rod at rodsdot dot com
21-Feb-2010 10:29
On IIS 5.1 (Windows XP) and IIS 6.0 (Windows Server 2003) the following installation
method goes very smoothly, but for three additional tasks.

Before installing PHP 5.2.x using the Microsoft Web Platform Installer, make sure:

C:\PHP does not exist
C:\Program Files\PHP does not exist (it will be created)
C:\Windows\php.ini does not exist (you won't need it there)

Run Microsoft Web Platform Installer allowing it to install FastCGI support and PHP
5.2.x.

After installation you should have PHP installed in C:\Program Files\PHP.

An examination of php.ini will show you will not likely need to change any settings,
except the sendmail_from address. The Windows specific settings have been set, but
are grouped together under:

; Default timeout for socket based streams (seconds)

Those are:
upload_tmp_dir="C:\WINDOWS\Temp"
session.save_path="C:\WINDOWS\Temp"
error_log="C:\WINDOWS\temp\php-errors.log"
cgi.force_redirect=0
fastcgi.impersonate=1
fastcgi.logging=0

In addition to having the correct minimal IIS settings already set in php.ini, you
will find the Path has had C:\Program Files\PHP\ added, and the environment variable
PHPRC is set correctly.

The three things not performed by the install but needed to run:

1.
HKEY_LOCAL_MACHINE\Software\PHP\IniFilePath may be wrong. It should not be
C:\Windows, but C:\Program Files\PHP, which is what is set in both the PATH and
PHPRC. (This could be a left over setting from a previous install, but the installer
does not correct it.)

2.
In IIS manager, under the default web site properties, Home Directory (tab),
Configuration (button), Mappings, the entry for .php may be missing or wrong. It
should be:
Executable: "C:\Program Files\PHP\php-cgi.exe" with the quotes.
Verbs: Limit To: GET,HEAD,POST,TRACE
Script Engine checkbox checked
Check That File Exists checkbox checked.

3.
The installer will not set the proper security permissions for php-cgi.exe or
php.ini, both of which need to be accessible to the default Internet user account:
e.g. IUSR_machine name.

In Windows Explorer, navigate to the C:\Program Files\PHP folder, right click,
properties, security (tab), add IUSR_machinename and accept the default security
permissions.

All of these seemed to take effect without a reboot, but a reboot is
suggested. Note: Items 1 and 2 may be left over from previous installations and
might possibly be rightly ignored by the installer, but if they are not corrected (at
least check) you are going to have a problem.

Item 3 is not going to be performed by the installer. You will have to do it based
on how you have security permissions set in IIS.
peter at peterjhart dot com
02-Feb-2010 05:21
Apache2 on Windows (PHP 5.3.1):

Install VC6 x86 THREAD SAFE. If you do not see Apache in the list of webservers, it
is because you downloaded the NON-THREAD SAFE installer.
manville at doctors dot org dot uk
21-Jul-2009 01:50
I have just spent a tiresome morning trying to get PHP 5.2 / 5.3 installed onto
Apache 2.2 (WinXPSP2) (Slight oddity in setup that program files on D: drive)

I have finally got it to work by using the following:

1) Getting installation script to use "Other CGI" (would be nice if it mentioned
Apache - I believe it to be a fairly popular option)

2) Adding the following directives to httpd.conf (the Apache configuration file)

ScriptAlias /php/ "D:/Program Files/PHP/"

(This tells Apache to treat the PHP directory as script files/executables and alias
it under /php/ for ease of use later)

AddHandler x-httpd-php .php

(This tells apache to recognise all .php files as of type x-httpd-php (equally you
could call them anything you liked and after this mornings debacle I can think of one
or two choice phrases)

Action x-httpd-php "php/php-cgi.exe"

(The tells Apache to use php-cgi.exe to handle files of type x-httpd-php (or .php
files as we declared earlier). php-cgi.exe only exists if you have selected the
"Other CGI" option at installation". A lot of stuff around on the web is pointing at
php.exe which is now failing. Has this changed recently?)
infoworld at yahoo dot com
12-Feb-2009 09:41
Using the installer, I have been getting the "cannot run script" error on Windows XP
and IIS 5.1. I used both the Zip file and installer filer to make it successful:

1. I downloaded the zip file (not the installer) into C:\php\,
2. extracted the contents to the same directory (C:\php\).
3. Downloaded and ran the installer into the C:\php\

Nagesh A
Anonymous
09-Jan-2009 03:06
I just installed PHP 5.2.8 (MSI package) on windows XP, IIS 5.1.

Selected IIS-ISAPI, always got error "The specified module could not be found."
(firefox), HTTP 500 Internal Server Error (ie 7). Even though no extensions were
selected.

Trick: Install PHP to C:\PHP (and not to C:\Program Files\PHP)

In your IIS web site properties, tab home directory, configuration, application
mappings.
Remove the quotes before and after the executable path and the problem will be
solved.
jstein at image dot dk
30-Dec-2008 10:33
I just installed PHP 5.2.8 as an ISAPI-extension for IIS 6 in Windows 2003 server.

I used the Windows installer, but had to make a few changes manually:

- Copy php.ini from the PHP folder (C:\Program Files\PHP) to the Windows folder
(C:\Windows).

- Enable the ISAPI extension. (In IIS Manager under "Web Service Extensions" add a
new extension with "Required files" set to C:\Program Files\PHP\php5isapi.dll).

- Add index.php to default index pages (select properties for "Web Sites", add it on
the "Documents" tab).
Manual Installation Steps
This section contains instructions for manually installing and configuring PHP on Microsoft
Windows. For the instructions on how to use PHP installer to setup and configure PHP and a
web server on Windows refer to Windows Installer (PHP 5.2 and later).
Selecting and downloading the PHP distribution package
Download the PHP zip binary distribution from PHP for Windows: Binaries and Sources.
There are several different versions of the zip package - chose the version that is suitable
for the web server being used:
If PHP is used with IIS then choose PHP 5.3 VC9 Non Thread Safe or PHP 5.2 VC6
Non Thread Safe;
If PHP is used with Apache 1 or Apache 2 then choose PHP 5.3 VC6 or PHP 5.2 VC6.
Note: VC9 Versions are compiled with the Visual Studio 2008 compiler and have
improvements in performance and stability. The VC9 versions require you to have the
Microsoft 2008 C++ Runtime (x86) or the Microsoft 2008 C++ Runtime (x64) installed.
The PHP package structure and content
Unpack the content of the zip archive into a directory of your choice, for example C:\PHP\.
The directory and file structure extracted from the zip will look as below:
Example #1 PHP 5 package structure

c:\php
|
+--dev
| |
| |-php5ts.lib -- php5.lib in non thread safe version
|
+--ext -- extension DLLs for PHP
| |
| |-php_bz2.dll
| |
| |-php_cpdf.dll
| |
| |-...
|
+--extras -- empty
|
+--pear -- initial copy of PEAR
|
|
|-go-pear.bat -- PEAR setup script
|
|-...
|
|-php-cgi.exe -- CGI executable
|
|-php-win.exe -- executes scripts without an opened command
prompt
|
|-php.exe -- Command line PHP executable (CLI)
|
|-...
|
|-php.ini-development -- default php.ini settings
|
|-php.ini-production -- recommended php.ini settings
|
|-php5apache2_2.dll -- does not exist in non thread safe version
|
|-php5apache2_2_filter.dll -- does not exist in non thread safe version
|
|-...
|
|-php5ts.dll -- core PHP DLL ( php5.dll in non thread safe
version)
|
|-...

Below is the list of the modules and executables included in the PHP zip distribution:
go-pear.bat - the PEAR setup script. Refer to Installation (PEAR) for more details.
php-cgi.exe - CGI executable that can be used when running PHP on IIS via CGI or
FastCGI.
php-win.exe - the PHP executable for executing PHP scripts without using a
command line window (for example PHP applications that use Windows GUI).
php.exe - the PHP executable for executing PHP scripts within a command line
interface (CLI).
php5apache2_2.dll - Apache 2.2.X module.
php5apache2_2_filter.dll - Apache 2.2.X filter.
Changing the php.ini file
After the php package content has been extracted, copy the php.ini-production into php.ini
in the same folder. If necessary, it is also possible to place the php.ini into any other
location of your choice but that will require additional configuration steps as described in
PHP Configuration.
The php.ini file tells PHP how to configure itself, and how to work with the environment that
it runs in. Here are a number of settings for the php.ini file that help PHP work better with
Windows. Some of these are optional. There are many other directives that may be relevant
to your environment - refer to the list of php.ini directives for more information.
Required directives:
extension_dir = <path to extension directory> - The extension_dir needs to point to
the directory where PHP extensions files are stored. The path can be absolute (i.e.
"C:\PHP\ext") or relative (i.e. ".\ext"). Extensions that are listed lower in the php.ini
file need to be located in the extension_dir.
extension = xxxxx.dll - For each extension you wish to enable, you need a
corresponding "extension=" directive that tells PHP which extensions in the
extension_dir to load at startup time.
log_errors = On - PHP has an error logging facility that can be used to send errors to
a file, or to a service (i.e. syslog) and works in conjunction with the error_log
directive below. When running under IIS, the log_errors should be enabled, with a
valid error_log.
error_log = <path to the error log file> - The error_log needs to specify the
absolute, or relative path to the file where PHP errors should be logged. This file
needs to be writable for the web server. The most common places for this file are in
various TEMP directories, for example "C:\inetpub\temp\php-errors.log".
cgi.force_redirect = 0 - This directive is required for running under IIS. It is a
directory security facility required by many other web servers. However, enabling it
under IIS will cause the PHP engine to fail on Windows.
cgi.fix_pathinfo = 1 - This lets PHP access real path info following the CGI Spec. The
IIS FastCGI implementation needs this set.
fastcgi.impersonate = 1 - FastCGI under IIS supports the ability to impersonate
security tokens of the calling client. This allows IIS to define the security context that
the request runs under.
fastcgi.logging = 0 - FastCGI logging should be disabled on IIS. If it is left enabled,
then any messages of any class are treated by FastCGI as error conditions which will
cause IIS to generate an HTTP 500 exception.
Optional directives
max_execution_time = ## - This directive tells PHP the maximum amount of time
that it can spend executing any given script. The default for this is 30 seconds.
Increase the value of this directive if PHP application take long time to execute.
memory_limit = ###M - The amount of memory available for the PHP process, in
Megabytes. The default is 128, which is fine for most PHP applications. Some of the
more complex ones might need more.
display_errors = Off - This directive tells PHP whether to include any error messages
in the stream that it returns to the Web server. If this is set to "On", then PHP will
send whichever classes of errors that you define with the error_reporting directive
back to web server as part of the error stream. For security reasons it is
recommended to set it to "Off" on production servers in order not to reveal any
security sensitive information that is often included in the error messages.
open_basedir = <paths to directories, separated by semicolon>, e.g.
openbasedir="C:\inetpub\wwwroot;C:\inetpub\temp". This directive specified the
directory paths where PHP is allowed to perform file system operations. Any file
operation outside of the specified paths will result in an error. This directive is
especially useful for locking down the PHP installation in shared hosting
environments to prevent PHP scripts from accessing any files outside of the web
site's root directory.
upload_max_filesize = ###M and post_max_size = ###M - The maximum allowed
size of an uploaded file and post data respectively. The values of these directives
should be increased if PHP applications need to perform large uploads, such as for
example photos or video files.
PHP is now setup on your system. The next step is to choose a web server, and enable it to
run PHP. Choose a web server from the table of contents.
In addition to running PHP via a web server, PHP can run from the command line just like a
.BAT script. See Command Line PHP on Microsoft Windows for further details.



ActiveScript Windows Installer (PHP 5.2 and later)

Last updated: Fri, 11 Jun 2010

User Contributed Notes
Manual Installation Steps
Anonymous
23-Apr-2010 03:07
It should be noted that even before starting PHP installation, you should research
extension requirements for those you plan to use. For a list of common extensions
and dll requirements and prerequisites, see the table on this php.net page:
http://www.php.net/manual/en/install.windows.extensions.php

Commonly used extensions are listed in alphabetical order in the default php.ini file
that comes with the windows packages. Some extensions must be loaded before others
or else the server may crash with an unhelpful, seemingly unrelated dll error. For
example, in your php.ini file, you must manually place 'extension=php_exif.dll' -
after- 'extension=php_mbstring.dll' if you wish to use the exif and mbstring
extensions or else your server may crash. The msi installer may or may not
automatically have correct load order, but for manual installs, it does not.

Do not attempt to uncomment extension lines in the default php.ini file that comes
packaged with php install or zip packages without knowing what you're doing. Before
loading extensions in this manner, be sure you have met the prerequisites for load
order and have ready any missing dll files listed in the above link.
rich at corephp dot co dot uk
02-Jul-2009 12:02
The part about adding the Path to the System Environment Variables is different on
Vista. On XP you DO need to reboot for the Path change to be picked-up correctly. On
Vista however you do not, the change is instant.
dkflbk at nm dot ru
19-Jun-2009 01:46
There is a way to install PHP with nginx-server under windows (current version is
0.7.60)

Step-1 (install nginx server)
Just extract nginx-0.7.60.zip in C:\nginx-0.7.60

In C:\nginx-0.7.60\conf\nginx.conf uncomment and edit following lines

location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME C:/nginx-0.7.60/html$fastcgi_script_name;
#this is the one line for edition
include fastcgi_params;
}

and run C:\nginx-0.7.60\nginx.exe (the server is started)

Step-2 (install PHP5)
Just extract php in C:\PHP5

Create (or modify) php.ini

extension_dir="ext/" ;for extensions

And run C:\PHP5\php-cgi.exe -b 127.0.0.1:9000
txyoji
17-Apr-2009 02:36
php 5.1.6 zip package for windows does not include a module for apache2.2.

Use apache2.0.x or 1.3.x instead.
dee at example dot com
04-Feb-2009 09:57
I did a clean install of Apache 2.2 and PHP 5.2.6 due to conflicts with the old
httpd.conf file I had and ran into the "Call to undefined function mysql_connect()"
error when trying to run a script that connects to MySQL.

To resolve it I had to copy libmysql.dll from my PHP installation directory to the
"bin" folder of my Apache install directory.

I checked the forums.mysql.com as someone else suggested which lead me to this site
with the missing step I needed (http://www.artfulsoftware.com/php_mysql_win.html). I
spent a good part of the afternoon trying set this up. Hopefully it helps someone
out.
chhabra_gurpreet at yahoo dot com
11-Jan-2009 07:34
Hi everyone, well i've been trying to configure, install, this setup i.e., Apache,
php and mysql, well the prb wat i faced was that most of the installation
instructions were quite outdated as they used quite old softwares... well these are
the simple steps install and configure this entire setup, hope it will help
u....(this is for windows)
Software versions:
Apache - 2.2.11
Mysql - 5.1.30-community
Php - PHP Version 5.2.8

Step 1: Default installation of Apache
Step 2: Default installation of mysql
Step 3: Download php zip file, extract it to ur C: drive under c:\php
Step 4: Add these paths to ur classpath, "C:\php", "C:\php\ext", incase ur
installation directory is php, else watever is the name of ur php installation
directory use that instead of php
Step 5: Open httpd.conf, that is located in Apache web server installation folder,
under conf directory i.e.,
Apache Installation folder > conf > httpd.conf
Add these lines....
>LoadModule php5_module "c:/php/php5apache2_2.dll"
>AddType application/x-httpd-php .php
Step 6: goto php installation directory, there u'll find a file named php-ini-
recommended, rename it to, php-ini.
Step 7: Now time to modify php-ini, file... open the file in notepad, look for
extension=php_mysql.dll, uncomment it, i.e., delete ";" thats prefixed...also look
for "extension_dir=" append "C:\php\ext" incase ur php installation directory is php
else "C:\%installation dir%\ext"
Step 8: Copy libmysql.dll to c:\windows\system32

done.......... ;)
philmee95 at gmail dot com
27-Jul-2008 09:52
64 bit windows issues. PHP is 32 bit, and w3svc can only run under 32 or 64...not
both. You will have to set 32 bit compat mode.
http://www.iisadmin.co.uk/?p=14
supportatradiormidotcom
13-Mar-2008 12:44
Im running Win 2003 PHP 5 with the isapi.dll thanks to this sipmle tutorial hope it
will help someone.Cerdit goes to Peterguy.

http://www.peterguy.com/php/install_IIS6.html

Follow the instructions, PHP install made easy
bill at onemeg dot com
19-Feb-2008 11:48
Your PHP.INI file is not required to be in the C:\WINDOWS folder in XP. The trick is
to make sure that the PHP.INI can be found. If you fail to reboot after adding the
PHP folder to the path and creating the PHPRC environment variable, the file will
likely not be found. If you can't reboot, then try creating the registry entries as
described in the following document:

http://www.php.net/manual/en/configuration.php

When you execute "phpinfo();" pay special attention to the data returned in "Loaded
Configuration File". If it does not show a path and a the PHP.INI file name, the
file is not being loaded. The path of C:\WINDOWS in the Configuration File Path
section is the default location where PHP looks for the INI file and does not mean
that the file must be located there; in fact, the following document suggest that you
leave the configuration file in the C:\PHP folder:

http://www.php.net/manual/en/install.windows.manual.php
ik2008 at sipvantage dot com
18-Jan-2008 08:34
In windows XP, the php.ini file must be in c:\windows directory. Or else most of the
functions will work except mysql functions. The very first mysql command
mysql_connect will fail with the following message "Call to unsupported or undefined
function mysql_connect(); "
fgabrieli at gmail dot com
10-Jul-2007 03:55
Problem:
Error in my_thread_global_end(): 1 threads didn't exit

It seems that php 5.2.3 libmysql.dll does not work as expected, because Apache shows
this error in the logs when we use mysql_*() functions

Solution:
I found it here:
http://forums.mysql.com/read.php?10,153077,155121#msg-155121

which is to replace 'libmysql.dll' file in your PHP installation directory (also in
winnt/system32 if you copied it there) with the Dll from PHP 5.2.1

You can download the second one from here:
http://www.php.net/get/php-5.2.1-Win32.zip/from/a/mirror

Regards,
Fernando Gabrieli
sam b
29-Jun-2007 08:53
I ran across the same problem listed below, using IIS6 instead of Apache on Windows
Server 2003.

It seemed that I could run a PHP script on the command line just fine, and lines such
as:
<? if(function_exists("mysql_connect")) echo "MySQL is present."; ?>
ran without error, and printed as expected.

Loading the file via IIS (using Firefox from my Ubuntu workstation), it wouldn't
print anything, indicating that the MySQL extension hadn't been loaded.

Fix: rename/delete all "libmysql.dll" except for the one in "C:\PHP\ext" or
equivalent.

... Same fix as listed below, but I wanted to point out: it's relevant to IIS as
well.
adozolj at yahoo dot com
28-Jun-2007 04:41
I got the 'Fatal Error: call to unindentified function mysql_connect()' and resolved
it after many hours of troubleshooting. The problem has to do with the libmysql.dll
file residing in multiple directories. It SHOULD only be in the php directory. So,
erase the copy in mysql bin and the apache bin and restart apache. I hope this helps
someone. if this doesn't help check out forums.mysql.com and search "Call to
undefined function mysql_connect". (i got the solution to this problem from here)
Shivan at Freenet dot de
27-Jun-2007 08:57
I had the same problem on IIS6 with php 5.2.3, that I got a blank page and nothing
more, but the phpinfo(); worked.

The cause wasn't the not-set doc_root, but after enabling "show errors" I got an
error message, that my script used more than 8 MB... ;)

After enlarging memory it worked :))))
jussi dot korhonen at evtek dot fi
30-May-2007 11:27
With MySQL 5.0.41 & Apache/2.2.4 & PHP/5.2.2 on Windows XP SP2 php_mysql.dll failed
to load. All configurations, including php extension dir and windows path seemed to
be correct. After hours of tinkering, I found that my MySQL bin/-directory contained
a libmysql.dll too.
Because MySQL bin/-directory was before c:\php-directory in PATH, PHP tried to use
MySQL version of libmysql.dll and failed miserably. By putting c:\php in PATH before
MySQL everything worked like a charm!
andyfrazer at gorillasites dot com
25-May-2007 05:18
I was trying to start Apache 2.2.4 using PHP5.2.2 on Windows XP. When I added the
following command to the Apache httpd.conf file:

LoadModule php5_module "c:/php/php5apache2.dll"

Apache would not start. When I removed that command, it started fine.

Based on a suggestion in http://www.apachelounge.com/forum/viewtopic.php?t=570, I
tried this instead:

LoadModule php5_module "c:/php/php5apache2_2.dll"

and it started up immediately.

I wasted two evenings trying to get this work before I found the link to the
ApacheLounge forum. I hope this helps someone else.
dr dot juanc at yahoo dot com
18-Apr-2007 02:18
Installing PHP5.2.1 in IIS 6.0 bring me some troubles too.

First i need to use full tag to make it your php script works and second the IIS
didn't want to load the extension in the ext folder. I cheked the configuration a
couple of thousand of time and everything seen to be ok.

I fixed up given read access in the "ext" folder to de "IUSER/PCNAME" user or to
everyone/PCNAME user to the same folder. Just in case i did the same in the rest of
the folder inside the php folder.

I wish nobody loose an all day in the same thing, like me.

excuse my english please
shane
20-Mar-2007 10:17
IIS Windows 2003 server.

You have upgraded to PHP5 from PHP4. phpinfo- works fine. You cannot however
communicate with mysql (for example) through phpMyAdmin as it throws up an error
stating it cannot load the mysqli extension and/or you get the 'bad handshake'
warning.

Solution: update your libmySQL.dll file in your system32 folder. This requires you to
stop all internet services on your computer i.e IIS. Full details below.

#############################
Background: my server is set up as follows:

php files folder == C:\PHP
I have configured my php.ini file opening up the required extensions etc
I have mapped the necessary extension to IIS
I have configured my website extension(s)
I have mapped my windows path ';C\PHP;C\PHP\ext'
I have registered my ini file
I have tested my phpinfo() and it works
I have installed phpMyAdmin and it refuses to work
I have tried simple mysql connection scripts ...nada
I have checked everything 50 times
I am bald.

Then I did this:

##############################

1) Copy 'libmySQL.dll' from C:\PHP (or the folder where you have loaded php into)

2) Open 'Windows\system32' folder. Do nothing at the moment, just have this window
'to hand'.

3)Open IIS manager snap in(control panel - administrative tools - IIS manager)

Right click server name as shown below:

- Internet Information Services
- My Computer (local computer) - right click

Select 'all tasks' then 'Restart IIS...'
Use drop down then select 'stop internet services on XXXXX' and click 'OK'

4) Return to your 'Windows\system32' folder. Paste 'libmySQL.dll' (it is already in
your clipboard from step 1). It will warn you about overwrite the current one. Select
YES.

5) Return to IIS manager. Follow steps as in '3' above except now choose 'Restart
Internet Services on XXX' (the default option), click OK.

#############################

I hope this works for you.
hkhasgiwale at gmail dot com
06-Feb-2007 06:26
I wasted a lot of time trying to figure out the problem of not being able to display
my 'test.php' demo script to work, the file lay in my IIS 5 " C:\inetpub\wwwroot"
folder.

The file contents of test.php were:
<?php>
phpinfo();
<?>

Windows php installer version was 5.2.0

Problem lay in the minute dumb feature of windows explorer being used t
change(rename) text file extension from 'test.txt' to 'test.php'.
The resultant name looked by the IIS was still 'test.php.txt'.

I used command line to change the filename to 'test.php' and it displayed in my
browser.

http://localhost/test.php, worked right away.
simon at dna dot co dot nz
23-Jan-2007 10:42
I have found a lot of references to run the below script to test whether PHP is
running:
<?
phpinfo();
?>

Unfortunately this does not work with a php.ini based from php.ini.recommended as
that has short tags turned off by default.
Use full tags, as recommended anyway, otherwise you will just get a blank page.

<?php
phpinfo();
?>

This is probably real basic to php old timers but can easily catch us newbies.
Daniel
02-Dec-2006 05:11
Re: Manual Configuration, pathing errors in IIS and ISAPI setup

Chris @ 11-Oct-2006 and phpmanual at pbb dot dds dot nl @ 07-Oct-2004 are both
correct.

Problem is not with PHP but with IIS (mine is v5.1).

Installed PHP into C:\Program Files\PHP, and set environment variable PATH to path as
stated.

When selecting the installation of php5isapi.dll via IIS Administrator, IIS would
insert the path as:

"C:\Program Files\PHP\php5isapi.dll" (note the quotes and space in directory name)

All scripts ran and produced a HTTP 500 error.

Replaced ISAPI path in IIS with:

C:\PROGRA~1\PHP\php5isapi.dll (note the removal of the quotes and spaces, and the
replacement of the path with 8.3 format names)

All scripts ran w/o problems.

Thanks to all! I hope someone can report if a similar problem exists with IIS6/7.
Chris
12-Oct-2006 02:58
RE: phpmanual at pbb dot dds dot nl @ 07-Oct-2004 11:29

You are correct. I just had the same issue; I was following the PHP installation
instructions and some very helpful WIMP instructions.

I was trying to keep things tidy by putting my PHP directory in C:\Program
Files\PHP. I set the PATH variable, ISAPI filter config and extension in Application
Configuration, but was getting the "Specified module could not be found" error.

Changed the PHP directory to C:\PHP and reconfigured everything, did an iisreset, and
it started working immediately.

Good catch, and thank you!
mega-squall at caramail dot com
23-Jul-2006 09:19
Remember to enter FULL PATH in the extension_dir parameter in php.ini ! Using only
"./ext/" or any relative path will have your PHP failing to load extensions when
called by Apache. That's quite tricky 'cause extensions are working when PHP is used
through command line ...
Jason Greene
04-May-2006 01:06
If you are running websites within an Application Pool (which is now the default for
IIS6 under 2K3) you need to make sure that your PHP directory (e.g. C:\PHP) has read
permissions for the user assigned to the Application Pool.

1. In the IIS snap-in, choose Application Pools
2. Right-click on DefaultAppPool (or other, if you have one defined) and choose
Properties
3. Click the Identity tab
4. Make a note of the user name set as the security account for this application pool
(e.g. "Network Service")
5. Browse to your PHP directory and grant that user read permissions for the entire
directory.

In my case, I had to add permissions for the user "NETWORK SERVICE" to get PHP
scripts to work. Otherwise I received 401/403 authorization errors when trying to
load them in a remote browser.

Note also that first tried adding IUSR permissions to the PHP directory, but that had
no effect.
Ben
06-Apr-2006 10:17
In the Note Titled "Windows Server 2003 (x64 bits) + IIS 6.0" in step 1 when adding
your new .php extension, it will not work unless after you click on the "Home
Directory" you make sure that your "Execute permissions:" are set to "Scripts Only".

By default, on my machine, the permissions were set to "None" not allowing php to
run.

Also, for more security it might be wise to Add the new extension just to your
default site instead of the whole Web Sites folder in IIS. This would only apply if
you were hosting multiple sites and had a site you didn't want scripts to run on.
Tom
14-Feb-2006 05:54
On this page and the FAQ they point out that to reset the Windows PATH variable to
include your php dir, you need to completely restart the machine.

If you can't afford to do that (installing on a live server for example), you can use
the setx.exe tool from the Windows Resource Kit (google it). Like so:

c:\pathtoresourcekit> setx.exe PATH "%PATH%;c:\php" \m
Windows Server 2003 (x64 bits) + IIS 6.0
31-Jan-2006 11:16
1. Add new extension (.php)

* Expand the local computer in the left pane
* Right-click on "Web Sites" in the left pane, then click "Properties" in the
menu that pops up
* Flip top the "Home Directory" tab
* Click "Configuration"
* Flip to the "Mappings" tab
* Click "Add..."
* Enter the full path to php5isapi.dll in the "Executable" textbox (Browse... to
find it more easily if you need to)
* Enter ".php" in the "Extension" textbox
* Select radial button "Limit to", enter "GET,POST,HEAD"
* Click "OK" all the way out

2. Verify php5isapi.dll is allowed

You must verify that the versions of php5isapi.dll that you want to use are allowed.

2.1. In Internet Information Services (IIS) Manager, in the left-hand column,
click the Web Services Extensions node and verify php5isapi.dll is allowed and all
other Web Service Extensions are prohibited.
2.2. If the version of php5isapi.dll that you want to use does not appear in the
list, follow the instructions to enable it and then repeat this procedure:

Go into IIS
Below all of the websites is a folder: Web Service Extensions
In blue, to the lower left, is a choice: Add A New Web Service Extension
Add PHP/PHP5ISAPI.dll
Choose To ALLOW it.

2.3 If the version of php5isapi.dll you want to use appears on the list but is not
allowed, right click the version of php5isapi.dll you want to allow and click Allow.

3. Configuring IIS for 32-Bit Emulation Mode (THIS IS MOST IMPORTANT!!!!)

3.1. If you are installing IIS on x64-based editions of Windows Server 2003 or
Windows Server 2003 R2, IIS must be configured to run in 32 bit emulation mode.
Perform the following procedure on each front-end Web server running an x64-based
edition of Windows Server 2003.
Configure Internet Information Services (IIS) for 32-bit mode

1. Click Start, and then click Run.
2. In the Open box, type cmd, and then click OK.
3. In the command prompt window, navigate to the %drive%:\Inetpub\Adminscripts
folder, where %drive% is the drive in which Windows Server 2003 is installed.
4. In the Adminscripts folder, type the following command:

cscript adsutil.vbs set w3svc/AppPools/Enable32bitAppOnWin64 1

Note The value "1" for Enable32bitAppOnWin64 specifies 32-bit mode, whereas
the value "0" specifies 64-bit mode.
5. Press ENTER.
6. Type iisreset and then press ENTER.
7. Close the command prompt window.
8. Re-star System.

Note The Run WWW service in IIS 5.0 isolation mode check box is only selected if you
have upgraded to IIS 6.0 on Windows Server 2003 from IIS 5.0 on Windows 2000. New
installations of IIS 6.0 use IIS 6.0 worker process isolation mode by default.
patatraboum at nospam dot com
27-Dec-2005 02:09
IIS + PHP

- The browser can't find your php code like localhost/dir/dir_code.php from any
virtual directory (404 error)
- You are sure the code exists
You may rename it with a .html extension and check if it displays
- Process of your php code like localhost/root_code.php is ok from the root directory

It may come from the doc_root directive in php.ini whitch should be set to blank :

doc_root =

Then restart IIS to reload php.ini
some dude @ some place
04-Nov-2005 04:57
on two recent installation attempts on iis6 on win2k3 i followed the php manual and
windows configuration steps exactly and php would still not run.

on the first install i had to give the USER account (not IUSR) read execute
permissions to this file, c:\php\sapi\php4isapi.dll. using filemon i saw that it was
being accessed and access was denied.

steps:
- right click on this file > properties > security > add > location (select the
server -not domain if listed) > advanced > find now > Users (usually the last item) >
click OK
- select Read & Execute > apply

also a complete computer restart was required in each install
Bill dot Rook at Gmail dot com
18-Sep-2005 05:09
doc_root = ".;c:\inetpub\wwwroot" does seem to work with virtual websites. This might
be a better option then commenting out the line.
Jason
09-Sep-2005 11:54
For me atleast, the steps for installing php 5 on IIS 6 on windows 2003 seemed to get
buried with the other setups. I found it difficult to quickly look through and make
sure I covered every step. So I created a clean step by step tutorial with
screenshots:
http://psdforums.com/article.php?a=9
atomictaco at atomic-taco dot com
10-Jul-2005 04:17
In response to phpmanual at pbb dot dds dot nl:

You are absolutly correct. I found this out while trying to install PHP4 with
Apache2 on XPPro. Here are 3 general guidelines that I have found to be correct:

- Path may not have spaces. Change C:\Program Files to C:\Progra~1 If you don't
understand this, go to start-->run-->command (not cmd). Type cd\ and hit
enter. Then type dir. You should see all your directory names there.

- Paths should not be enclosed by quotes.

- Use forward slashes (/) and not backslashes (\)
thierry dot bo at nxextxcxoxuxrxrxixexr dot com
20-Dec-2004 12:50
With PHP 4.3.x and apache 1.3.x on windows, PHPRC is used only if php is installed as
cgi. With module, no matter using setenv in httpd.conf or PHPRC as windows
environment variable, it is not used.
cpz at akik-ffm dot de
19-Dec-2004 06:24
In the above, "the web server's directory" means the directory where the server
executable lives, for example for the Apache installation on my XP box this is
"\program files\apache group\apache2\bin" and NOT just "\program files\apache
group\apache2".

But it's probably best to tell your web server where PHP's ini file is stored, for
example via PHPIniDir for Apache's http.conf.
chuacheehow at gmail dot com
08-Oct-2004 12:55
My experience with IIS 5.1 is that the doc_root directive be commented in order for
virtual directories to recognise PHP files (with PHP installed as CGI).
phpmanual at pbb dot dds dot nl
07-Oct-2004 01:29
Okay, I'm a total newbie to this, so my findings may be wrong, but this is what I
found out.

The manual says "do not have spaces in the path (like C:\Program Files\PHP) as some
web servers will crash if you do". Indeed, when using this with PHP5 on WinXP, I got
the error message "The specified module could not be found."
However, the problem seems not to lie in the SPACE in the pathname, but in the QUOTES
that Windows adds when a space is in the pathname! This is what I found:

"C:\Program Files\php5\php5isapi.dll" -- doesn't work
C:\php5\php5isapi.dll -- works
"C:\php5\php5isapi.dll" -- doesn't work
C:\Progra~1\php5\php5isapi.dll -- works
"C:\Progra~1\php5\php5isapi.dll" -- doesn't work
C:\Program Files\php5\php5isapi.dll -- doesn't work, because it's not accepted by
Internet Information Services

I don't know if this all is a problem with Internet Information Services or with PHP,
but it would be nice if it was more documented in the PHP manual.
php dot user dot com
29-Aug-2004 08:43
After having the same problem as specifed below with "No input file specified". I
changed the doc_root as mentioned.

This is fine if all php scripts are going to be run from the c:\inetpub\wwwroot
directory. To enable it for multiple websites where the root directories are all
different simply leave the doc_root attribute in the php.ini file blank.

This is for the isapi version not cgi implementation. It also means you don't have to
set IUSR or IWAM access to the PHP root directory.
ActiveScript
This section contains notes specific to the ActiveScript installation.
ActiveScript is a Windows only SAPI that enables you to use PHP script in any ActiveScript
compliant host, like Windows Script Host, ASP/ASP.NET, Windows Script Components or
Microsoft Scriptlet control.
As of PHP 5.0.1, ActiveScript has been moved to the PECL repository. A DLL for this PECL
extension is currently unavailable. See also the building on Windows section.
Note: You should read the manual installation steps first!
After installing PHP, you should download the ActiveScript DLL (php5activescript.dll) and
place it in the main PHP folder (e.g. C:\php).
After having all the files needed, you must register the DLL on your system. To achieve this,
open a Command Prompt window (located in the Start Menu). Then go to your PHP
directory by typing something like cd C:\php. To register the DLL just type regsvr32
php5activescript.dll.
To test if ActiveScript is working, create a new file, named test.wsf (the extension is very
important) and type:
<job id="test">

<script language="PHPScript">
$WScript->Echo("Hello World!");
</script>

</job>
Save and double-click on the file. If you receive a little window saying "Hello World!" you're
done.
Note: In PHP 4, the engine was named 'ActivePHP', so if you are using PHP 4, you should
replace 'PHPScript' with 'ActivePHP' in the above example.
Note: ActiveScript doesn't use the default php.ini file. Instead, it will look only in the same
directory as the .exe that caused it to load. You should create php-activescript.ini and place
it in that folder, if you wish to load extensions, etc.

User Contributed Notes
ActiveScript
maflorez at cognox dot com
15-Oct-2006 05:43
Other option is this:
Copy this text, save with extension .reg and execute.

***** Begin of file don't include
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\.phs]
@="PHPScript"

[HKEY_CLASSES_ROOT\PHPScript]
@="PHPScript"
"EditFlags"=dword:00000000
"AlwaysShowExt"=""
"BrowserFlags"=dword:00000008

[HKEY_CLASSES_ROOT\PHPScript\shell]
@="Run"

[HKEY_CLASSES_ROOT\PHPScript\shell\Run]

[HKEY_CLASSES_ROOT\PHPScript\shell\Run\command]
@="wscript.exe //E:PHPScript \"%1\" \"%2\""

[HKEY_CLASSES_ROOT\PHPScript\shell\Run\ddeexec]

[HKEY_CLASSES_ROOT\PHPScript\shell\Run\ddeexec\Application]
@="wscript"

[HKEY_CLASSES_ROOT\PHPScript\shell\Run\ddeexec\Topic]
@="System"
***** End of file don't include
garfiel_fr at tiscali dot fr
11-May-2005 04:06
There is another way to execute a PHP ActiveScript:

1/ In explorer, open menu "Tools/Folder Options"
2/ Go to tab "File Type"
3/ Click on "New" button and enter a file extension ( PHS for my sample ), you can
also select "PHPScript" in "Advanced" button. Then OK, a new file extension is
registered.
4/ In tab "File Type" select the new extension and click on button "Advanced". A new
dialog box is open.
5/ Click on "New" button and fill edit box with:
Action: Run
Application to use: C:\WIN2K\system32\wscript.exe //E:PHPScript "%1" "%2"

That's all !!

Now, your code don't need XML tag at the begining. Hello work in test.phs will be:

$WScript->Echo("Bonjour le monde !");
Microsoft IIS
This section contains PHP installation instructions specific to Microsoft Internet Information
Services (IIS).
Manually installing PHP on Microsoft IIS 5.1 and IIS 6.0
Manually installing PHP on Microsoft IIS 7.0 and later
Microsoft IIS 5.1 and IIS 6.0
This section contains instructions for manually setting up Internet Information Services (IIS)
5.1 and IIS 6.0 to work with PHP on Microsoft Windows XP and Windows Server 2003. For
instructions on setting up IIS 7.0 and later versions on Windows Vista, Windows Server
2008, Windows 7 and Windows Server 2008 R2 refer to Microsoft IIS 7.0 and later.
Configuring IIS to process PHP requests
Download and install PHP in accordance to the instructions described in manual installation
steps
Note: Non-thread-safe build of PHP is recommended when using IIS. The non-thread-safe
builds are available at PHP for Windows: Binaries and Sources Releases.
Configure the CGI- and FastCGI-specific settings in php.ini file as shown below:
Example #1 CGI and FastCGI settings in php.ini
fastcgi.impersonate = 1
fastcgi.logging = 0
cgi.fix_pathinfo=1
cgi.force_redirect = 0
Download and install the Microsoft FastCGI Extension for IIS 5.1 and 6.0. The extension is
available for 32-bit and 64-bit platforms - select the right download package for your
platform.
Configure the FastCGI extension to handle PHP-specific requests by running the command
shown below. Replace the value of the "-path" parameter with the absolute file path to the
php-cgi.exe file.
Example #2 Configuring FastCGI extension to handle PHP requests
cscript %windir%\system32\inetsrv\fcgiconfig.js -add -section:"PHP" ^
-extension:php -path:"C:\PHP\php-cgi.exe"
This command will create an IIS script mapping for *.php file extension, which will result in
all URLs that end with .php being handled by FastCGI extension. Also, it will configure
FastCGI extension to use the executable php-cgi.exe to process the PHP requests.
Note: At this point the required installation and configuration steps are completed. The
remaining instructions below are optional but highly recommended for achieving optimal
functionality and performance of PHP on IIS.
Impersonation and file system access
It is recommended to enable FastCGI impersonation in PHP when using IIS. This is
controlled by the fastcgi.impersonate directive in php.ini file. When impersonation is
enabled, PHP will perform all the file system operations on behalf of the user account that
has been determined by IIS authentication. This ensures that even if the same PHP process
is shared across different IIS web sites, the PHP scripts in those web sites will not be able to
access each others' files as long as different user accounts are used for IIS authentication
on each web site.
For example IIS 5.1 and IIS 6.0, in its default configuration, has anonymous authentication
enabled with built-in user account IUSR_<MACHINE_NAME> used as a default identity. This
means that in order for IIS to execute PHP scripts, it is necessary to grant
IUSR_<MACHINE_NAME> account read permission on those scripts. If PHP applications
need to perform write operations on certain files or write files into some folders then
IUSR_<MACHINE_NAME> account should have write permission to those.
To determine which user account is used by IIS anonymous authentication, follow these
steps:
1. In the Windows Start Menu choose "Run:", type "inetmgr" and click "Ok";
2. Expand the list of web sites under the "Web Sites" node in the tree view, right-click
on a web site that is being used and select "Properties";
3. Click the "Directory Security" tab;
4. Take note of a "User name:" field in the "Authentication Methods" dialog

To modify the permissions settings on files and folders, use the Windows Explorer user
interface or icacls command.
Example #3 Configuring file access permissions
icacls C:\inetpub\wwwroot\upload /grant IUSR:(OI)(CI)(M)
Set index.php as a default document in IIS
The IIS default documents are used for HTTP requests that do not specify a document
name. With PHP applications, index.php usually acts as a default document. To add
index.php to the list of IIS default documents, follow these steps:
1. In the Windows Start Menu choose "Run:", type "inetmgr" and click "Ok";
2. Right-click on the "Web Sites" node in the tree view and select "Properties";
3. Click the "Documents" tab;
4. Click the "Add..." button and enter "index.php" for the "Default content page:".

FastCGI and PHP Recycling configuration
Configure IIS FastCGI extension settings for recycling of PHP processes by using the
commands shown below. The FastCGI setting instanceMaxRequests controls how many
requests will be processed by a single php-cgi.exe process before FastCGI extension shuts it
down. The PHP environment variable PHP_FCGI_MAX_REQUESTS controls how many
requests a single php-cgi.exe process will handle before it recycles itself. Make sure that the
value specified for FastCGI InstanceMaxRequests setting is less than or equal to the value
specified for PHP_FCGI_MAX_REQUESTS.
Example #4 Configuring FastCGI and PHP recycling
cscript %windir%\system32\inetsrv\fcgiconfig.js -set -section:"PHP" ^
-InstanceMaxRequests:10000

cscript %windir%\system32\inetsrv\fcgiconfig.js -set -section:"PHP" ^
-EnvironmentVars:PHP_FCGI_MAX_REQUESTS:10000
Configuring FastCGI timeout settings
Increase the timeout settings for FastCGI extension if there are applications that have long
running PHP scripts. The two settings that control timeouts are ActivityTimeout and
RequestTimeout. Refer to Configuring FastCGI Extension for IIS 6.0 for more information
about those settings.
Example #5 Configuring FastCGI timeout settings
cscript %windir%\system32\inetsrv\fcgiconfig.js -set -section:"PHP" ^
-ActivityTimeout:90

cscript %windir%\system32\inetsrv\fcgiconfig.js -set -section:"PHP" ^
-RequestTimeout:90
Changing the Location of php.ini file
PHP searches for php.ini file in several locations and it is possible to change the default
locations of php.ini file by using PHPRC environment variable. To instruct PHP to load the
configuration file from a custom location run the command shown below. The absolute path
to the directory with php.ini file should be specified as a value of PHPRC environment
variable.
Example #6 Changing the location of php.ini file
cscript %windir%\system32\inetsrv\fcgiconfig.js -set -section:"PHP" ^
-EnvironmentVars:PHPRC:"C:\Some\Directory\"
Microsoft IIS 7.0 and later
This section contains instructions for manually setting up Internet Information Services (IIS)
7.0 and later to work with PHP on Microsoft Windows Vista SP1, Windows 7, Windows
Server 2008 and Windows Server 2008 R2. For instructions on setting up IIS 5.1 and IIS
6.0 on Windows XP and Windows Server 2003 refer to Microsoft IIS 5.1 and IIS 6.0.
Enabling FastCGI support in IIS
FastCGI module is disabled in default installation of IIS. The steps to enable it differ based
on the version of Windows being used.
To enable FastCGI support on Windows Vista SP1 and Windows 7:
1. In the Windows Start Menu choose "Run:", type "optionalfeatures.exe" and click
"Ok";
2. In the "Windows Features" dialog expand "Internet Information Services", "World
Wide Web Services", "Application Development Features" and then enable the "CGI"
checkbox;
3. Click OK and wait until the installation is complete.

To enable FastCGI support on Windows Server 2008 and Windows Server 2008 R2:
1. In the Windows Start Menu choose "Run:", type "CompMgmtLauncher" and click
"Ok";
2. If the "Web Server (IIS)" role is not present under the "Roles" node, then add it by
clicking "Add Roles";
3. If the "Web Server (IIS)" role is present, then click "Add Role Services" and then
enable the "CGI" checkbox under "Application Development" group;
4. Click "Next" and then "Install" and wait for the installation to complete.

Configuring IIS to process PHP requests
Download and install PHP in accordance to the instructions described in manual installation
steps
Note: Non-thread-safe build of PHP is recommended when using IIS. The non-thread-safe
builds are available at PHP for Windows: Binaries and Sources Releases.
Configure the CGI- and FastCGI-specific settings in php.ini file as shown below:
Example #1 CGI and FastCGI settings in php.ini
fastcgi.impersonate = 1
fastcgi.logging = 0
cgi.fix_pathinfo=1
cgi.force_redirect = 0
Configure IIS handler mapping for PHP by using either IIS Manager user interface or a
command line tool.
Using IIS Manager user interface to create a handler mapping for PHP
Follow these steps to create an IIS handler mapping for PHP in IIS Manager user interface:
1. In the Windows Start Menu choose "Run:", type "inetmgr" and click "Ok";
2. In the IIS Manager user interface select the server node in the "Connections" tree
view;
3. In the "Features View" page open the "Handler Mappings" feature;

4. In the "Actions" pane click "Add Module Mapping...";
5. In the "Add Module Mapping" dialog enter the following:
Request path: *.php
Module: FastCgiModule
Executable: C:\[Path to PHP installation]\php-cgi.exe
Name: PHP_via_FastCGI
6. Click "Request Restrictions" button and then configure the mapping to invoke handler
only if request is mapped to a file or a folder;
7. Click OK on all the dialogs to save the configuration.

Using command line tool to create a handler mapping for PHP
Use the command shown below to create an IIS FastCGI process pool which will use php-
cgi.exe executable for processing PHP requests. Replace the value of the fullPath parameter
with the absolute file path to the php-cgi.exe file.
Example #2 Creating IIS FastCGI process pool
%windir%\system32\inetsrv\appcmd set config /section:system.webServer/fastCGI ^
/+[fullPath='c:\PHP\php-cgi.exe']
Configure IIS to handle PHP specific requests by running the command shown below.
Replace the value of the scriptProcessor parameter with the absolute file path to the php-
cgi.exe file.
Example #3 Creating handler mapping for PHP requests
%windir%\system32\inetsrv\appcmd set config /section:system.webServer/handlers ^
/+[name='PHP_via_FastCGI', path='*.php',verb='*',modules='FastCgiModule',^
scriptProcessor='c:\PHP\php-cgi.exe',resourceType='Either']
This command creates an IIS handler mapping for *.php file extension, which will result in
all URLs that end with .php being handled by FastCGI module.
Note: At this point the required installation and configuration steps are completed. The
remaining instructions below are optional but highly recommended for achieving optimal
functionality and performance of PHP on IIS.
Impersonation and file system access
It is recommended to enable FastCGI impersonation in PHP when using IIS. This is
controlled by the fastcgi.impersonate directive in php.ini file. When impersonation is
enabled, PHP will perform all the file system operations on behalf of the user account that
has been determined by IIS authentication. This ensures that even if the same PHP process
is shared across different IIS web sites, the PHP scripts in those web sites will not be able to
access each other's files as long as different user accounts are used for IIS authentication
on each web site.
For example IIS 7, in its default configuration, has anonymous authentication enabled with
built-in user account IUSR used as a default identity. This means that in order for IIS to
execute PHP scripts, it is necessary to grant IUSR account read permission on those scripts.
If PHP applications need to perform write operations on certain files or write files into some
folders then IUSR account should have write permission to those.
To determine what user account is used as an anonymous identity in IIS 7 use the following
command. Replace the "Default Web Site" with the name of IIS web site that you use. In
the output XML configuration element look for the userName attribute.
Example #4 Determining the account used as IIS anonymous identity
%windir%\system32\inetsrv\appcmd.exe list config "Default Web Site" ^
/section:anonymousAuthentication

<system.webServer>
<security>
<authentication>
<anonymousAuthentication enabled="true" userName="IUSR" />
</authentication>
</security>
</system.webServer>
Note: If userName attribute is not present in the anonymousAuthentication element, or is
set to an empty string, then it means that the application pool identity is used as an
anonymous identity for that web site.
To modify the permissions settings on files and folders, use the Windows Explorer user
interface or icacls command.
Example #5 Configuring file access permissions
icacls C:\inetpub\wwwroot\upload /grant IUSR:(OI)(CI)(M)
Set index.php as a default document in IIS
The IIS default documents are used for HTTP requests that do not specify a document
name. With PHP applications, index.php usually acts as a default document. To add
index.php to the list of IIS default documents, use this command:
Example #6 Set index.php as a default document in IIS
%windir%\system32\inetsrv\appcmd.exe set config ^
-section:system.webServer/defaultDocument /+"files.[value='index.php']" ^
/commit:apphost
FastCGI and PHP Recycling configuration
Configure IIS FastCGI settings for recycling of PHP processes by using the commands shown
below. The FastCGI setting instanceMaxRequests controls how many requests will be
processed by a single php-cgi.exe process before IIS shuts it down. The PHP environment
variable PHP_FCGI_MAX_REQUESTS controls how many requests a single php-cgi.exe
process will handle before it recycles itself. Make sure that the value specified for FastCGI
InstanceMaxRequests setting is less than or equal to the value specified for
PHP_FCGI_MAX_REQUESTS.
Example #7 Configuring FastCGI and PHP recycling
%windir%\system32\inetsrv\appcmd.exe set config -section:system.webServer/fastCgi ^
/[fullPath='c:\php\php-cgi.exe'].instanceMaxRequests:10000

%windir%\system32\inetsrv\appcmd.exe set config -section:system.webServer/fastCgi ^
/+"[fullPath='C:\{php_folder}\php-cgi.exe'].environmentVariables.^
[name='PHP_FCGI_MAX_REQUESTS',value='10000']"
FastCGI timeout settings
Increase the timeout settings for FastCGI if it is expected to have long running PHP scripts.
The two settings that control timeouts are activityTimeout and requestTimeout. Use the
commands below to change the timeout settings. Make sure to replace the value in the
fullPath parameter to contain the absolute path to the php-cgi.exe file.
Example #8 Configuring FastCGI timeout settings
%windir%\system32\inetsrv\appcmd.exe set config -section:system.webServer/fastCgi ^
/[fullPath='C:\php\php-cgi.exe',arguments=''].activityTimeout:"90" /commit:apphost

%windir%\system32\inetsrv\appcmd.exe set config -section:system.webServer/fastCgi ^
/[fullPath='C:\php\php-cgi.exe',arguments=''].requestTimeout:"90" /commit:apphost
Changing the Location of php.ini file
PHP searches for php.ini file in several locations and it is possible to change the default
locations of php.ini file by using PHPRC environment variable. To instruct PHP to load the
configuration file from a custom location run the command shown below. The absolute path
to the directory with php.ini file should be specified as a value of PHPRC environment
variable.
Example #9 Changing the location of php.ini file
appcmd.exe set config -section:system.webServer/fastCgi ^
/+"[fullPath='C:\php\php.exe',arguments=''].environmentVariables.^
[name='PHPRC',value='C:\Some\Directory\']" /commit:apphost

User Contributed Notes
Microsoft IIS 7.0 and later
Bruce Kirkpatrick
28-Oct-2009 05:56
The default installation of Windows Vista, Windows 7 and Windows Server 2008 adds a
line to the Windows/System32/drivers/etc/hosts which causes network functions
(database connect functions too, like mysql_connect) to timeout when connecting to
"localhost". To resolve this problem, remove the entry from the hosts file:
::1 localhost

or connect using the IP address, 127.0.0.1 or another domain name.

This behavior change is due to IPv6 being enabled by default in Vista or other recent
Windows version.

Now you can use the x64 snapshot builds of 5.3 on these new windows platforms to run
a completely up to date 64-bit fastcgi configuration!
Apache 1.3.x on Microsoft Windows
This section contains notes and hints specific to Apache 1.3.x installs of PHP on Microsoft
Windows systems. There are also instructions and notes for Apache 2 on a separate page.
Note: Please read the manual installation steps first!
There are two ways to set up PHP to work with Apache 1.3.x on Windows. One is to use the
CGI binary (php.exe for PHP 4 and php-cgi.exe for PHP 5), the other is to use the Apache
Module DLL. In either case you need to edit your httpd.conf to configure Apache to work
with PHP, and then restart the server.
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.
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.
After changing the configuration file, remember to restart the server, for example, NET
STOP APACHE followed by NET START APACHE, if you run Apache as a Windows Service,
or use your regular shortcuts.
Note: Remember that when adding path values in the Apache configuration files on
Windows, all backslashes such as c:\directory\file.ext should be converted to forward
slashes: c:/directory/file.ext. A trailing slash may also be necessary for directories.
Installing as an Apache module
You should add the following lines to your Apache httpd.conf file:
Example #1 PHP as an Apache 1.3.x module
This assumes PHP is installed to c:\php. Adjust the path if this is not the case.
For PHP 4:
# 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
For PHP 5:
# 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
For both:
# 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
Installing as a CGI binary
If you unzipped the PHP package to C:\php\ as described in the Manual Installation Steps
section, you need to insert these lines to your Apache configuration file to set up the CGI
binary:
Example #2 PHP and Apache 1.3.x as CGI
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
Note that the second line in the list above can be found in the actual versions of httpd.conf,
but it is commented out. Remember also to substitute the c:/php/ for your actual path to
PHP.
Warning
A server deployed in CGI mode is open to several possible vulnerabilities. Please read our
CGI security section to learn how to defend yourself from such attacks.
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 highlight_file() function. To do this simply create a PHP
script file and add this code: <?php highlight_file('some_php_script.php'); ?>.



Apache 2.x on Microsoft Windows Microsoft IIS 7.0 and later

Last updated: Fri, 11 Jun 2010

User Contributed Notes
Apache 1.3.x on Microsoft Windows
frank at circuitdata dot dk
19-Sep-2008 03:43
Entries to httpd.conf for PHP 5:

AddType application/x-httpd-php .php

AddType application/x-httpd-php-source .phps

must appear BEFORE

LoadModule php5_module "C:/php/php5apache.dll"

This should NOT be added:

AddModule mod_php5.c

It makes no sense since AddModule means activation of a module compiled staticly into
the Apache. We ofcourse do not have that!
david
05-Jun-2007 07:10
Note that if you place php in the c:\php5 director your ScriptAlias line should read

ScriptAlias /php/ "c:/php5/"

This may be obvious to regular Apache users, but I changed all sorts of things around
before realizing this was the issue. I thought

Action application/x-httpd-php "/php/php-cgi.exe"

was a path and was changing it to "/php5/php-cgi.exe" which didn't work.
BCarr
20-Jan-2006 09:35
To Besta and 'j dot b..dot sk':

'Add Module mod_php4.c' or 'AddModule mod_php5.c' may or may not be necessary
depending on your environment and version of Apache.

In my situation, this add module DID NOT work or it wasn't necessary. The LoadModule
was enough to do the trick. I tried it with PHP4 on Apache 1.3.34 and Apache 2.0.

All in all, your notes have been helpful. Thanks.
j dot b at inmail dot sk
27-Sep-2005 07:42
DO NOT FORGET to add "index.php" into
<IfModule mod_dir.c>
DirectoryIndex index.html
</IfModule>

so you get index.php processed;multiple values separate by space:
<IfModule mod_dir.c>
DirectoryIndex index.html index.php
</IfModule>
27-Aug-2005 08:51
On contrary to user "Besta"'s post

AddModule mod_php5.c

should be added to the addmodule section. I installed php5 and apache 1.3.3 and
without the above line it is not recognizing the .php files
Besta
07-Aug-2005 09:16
Do not add this line to apache http.conf. It does not work.
AddModule mod_php5.c

Also, remember to edit the system variables, edit the PATH and add the path to the
php directory and restart windows.
psychosos at gmx dot at
27-Feb-2005 01:59
Please note that the SetEnv PHPRC "directory/to/phpini/" only works when using PHP as
CGI, but _not_ when you use the PHP Apache Module!
Apache 2.x on Microsoft Windows
This section contains notes and hints specific to Apache 2.x installs of PHP on Microsoft
Windows systems. We also have instructions and notes for Apache 1.3.x users on a
separate page.
Note: You should read the manual installation steps first!
Note: Apache 2.2 Support
Users of Apache 2.2 should note that the DLL file for Apache 2.2 is named
php5apache2_2.dll rather than php5apache2.dll and is available only for PHP 5.2.0 and
later. See also http://snaps.php.net/
You are strongly encouraged to consult the Apache Documentation to get a basic
understanding of the Apache 2.x Server. Also consider reading the Windows specific notes
for Apache 2.x before reading on here.
Apache 2.x is designed to run on the Windows version designated as server platforms, such
as Windows NT 4.0, Windows 2000, Windows XP, or Windows 7. While Apache 2.x works
tolerably well on Windows 9x, support on these platforms is incomplete, and some things
will not work correctly. There is no plan to remedy this situation.
Download the most recent version of Apache 2.x and a fitting PHP version. Follow the
Manual Installation Steps and come back to go on with the integration of PHP and Apache.
There are three ways to set up PHP to work with Apache 2.x on Windows. You can run PHP
as a handler, as a CGI, or under FastCGI.
Note: Remember that when adding path values in the Apache configuration files on
Windows, all backslashes such as c:\directory\file.ext should be converted to forward
slashes: c:/directory/file.ext. A trailing slash may also be necessary for directories.
Installing as an Apache handler
You need to insert the following lines into your Apache httpd.conf configuration file to load
the PHP module for Apache 2.x:
Example #1 PHP and Apache 2.x as handler
#
LoadModule php5_module "c:/php/php5apache2.dll"
AddHandler application/x-httpd-php .php

# configure the path to php.ini
PHPIniDir "C:/php"
Note: Remember to substitute your actual path to PHP for the C:/php/ in the above
examples. Take care to use either php5apache2.dll or php5apache2_2.dll in your
LoadModule directive and verify that the referenced file is in fact located at the file path that
you point to in this directive.
The above configuration will enable PHP handling of any file that has a .php extension, even
if there are other file extensions. For example, a file named example.php.txt will be
executed by the PHP handler. To ensure that only files that end in .php are executed, use
the following configuration instead:
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
Running PHP as CGI
You should consult the Apache CGI documentation for a more complete understanding of
running CGI on Apache.
To run PHP as CGI, you'll need to place your php-cgi files in a directory designated as a CGI
directory using the ScriptAlias directive.
You will then need to insert a #! line in the PHP files, pointing to the location of your PHP
binary:
Example #2 PHP and Apache 2.x as CGI
#!C:/php/php.exe
<?php
phpinfo();
?>
Warning
A server deployed in CGI mode is open to several possible vulnerabilities. Please read our
CGI security section to learn how to defend yourself from such attacks.
Running PHP under FastCGI
Running PHP under FastCGI has a number of advantages over running it as a CGI. Setting it
up this way is fairly straightforward:
Obtain mod_fcgid from http://httpd.apache.org/mod_fcgid/. Win32 binaries are available
for download from that site. Install the module according to the instructions that will come
with it.
Configure your web server as shown below, taking care to adjust any paths to reflect your
how you have installed things on your particular system:
Example #3 Configure Apache to run PHP as FastCGI
LoadModule fcgid_module modules/mod_fcgid.so

# Where is your php.ini file?
FcgidInitialEnv PHPRC "c:/php"

AddHandler fcgid-script .php
FcgidWrapper "c:/php/php-cgi.exe" .php
Files with a .php extension will now be executed by the PHP FastCGI wrapper.



Sun, iPlanet and Netscape servers on Microsoft Windows Apache 1.3.x on Microsoft
Windows

Last updated: Fri, 11 Jun 2010

User Contributed Notes
Apache 2.x on Microsoft Windows
Michael
03-Mar-2010 05:48
The value for FcgidWrapper cannot contain spaces..

This won't work:
FcgidWrapper "c:/program files (x86)/php/php-cgi.exe" .php

But this will:
FcgidWrapper "c:/progra~2/php/php-cgi.exe" .php
Steve
24-Feb-2010 12:53
I also had a problem with the PHPIniDir declaration. This is with Apache 2.2 on
XP. I had to include a final slash, as in PHPIniDir "C:\Program Files\php\". Apache
failed to start if I did not include the slash after php.
Kerry Kobashi
14-Dec-2009 06:56
If you find that Apache crashes when you attempt to start it, its likely that one of
the PHP extensions is the cause. This is likely the case if you use the PHP Windows
installer and choose all extensions in the setup program to be installed on disk.
Unfortunately, it will also enable all extensions too causing potential problems.

For example, after installing PHP 5.2.11 and Apache 2.2 under Windows XP, Apache kept
crashing. This was due to using all three versiosn of mysql extensions attempting to
run:

[PHP_MYSQL]
extension=php_mysql.dll
[PHP_MYSQLI]
extension=php_mysqli.dll
[PHP_PDO_MYSQL]
extension=php_pdo_mysql.dll
Anonymous
10-Dec-2009 09:25
If anybody here encounters an error regarding PHPIniDir, change PHPIniDir "C:/php/"
to PHPIniDir "C:\php\".
nicolas dot grasset at gmail dot com
07-Jul-2009 05:08
Here is how I created a silent install for Apache2.2 and PHP5.2.10 on Windows XP
(running on a MacBook Pro):

Download Apache2 and PHP5 installer files in a directory and update the msi file
names in the following commands.

To have PHP installer find Apache2, do not forget APACHEDIR!

msiexec /i apache_2.2.11-win32-x86-no_ssl.msi /passive ALLUSERS=1
SERVERADMIN=admin@localhost SERVERNAME=localhost SERVERDOMAIN=localhost SERVERPORT=80
INSTALLDIR=c:\apache
msiexec /i php-5.2.10-win32-installer.msi /qn APACHEDIR=c:\apache INSTALLDIR=c:\php
ADDLOCAL=ext_php_mssql,apache22
net stop "Apache2.2"
net start "Apache2.2"
CP
16-Apr-2009 06:27
This is old news to some. But people with Apache 2.0.55 / PHP 5.1.2 might like a
reminder before they pull their hair out! (Some of us have ISPs using older version
and need to test on a like version before we upload.)

If using PHP 5.1.2, to run Apache as a module, do *not* use Stephan's
"php5apache2.dll" from http://www.ApacheLounge.com. That is for pre-5.1.2!

**There is a "php5apache2.dll" included with Windows PHP 5.1.2 zip file by default.**

If you forget this and overwrite the included DLL with Stephan's (as I did) you'll
spend hours attempting to escape "DLL hell", with no success.
Anonymous
26-Feb-2009 02:32
i followed henke37's way to for the httpd.conf

I added all this at the very end of httpd.conf

# For PHP 5
#load the php main library to avoid dll hell
Loadfile "C:\php-5.2.8-Win32\php5ts.dll"

#load the sapi so that apache can use php
LoadModule php5_module "C:\php-5.2.8-Win32\php5apache2_2.dll"

#set the php.ini location so that you don't have to waste time guessing where it is
PHPIniDir "C:\php-5.2.8-Win32"

#Hook the php file extensions
AddHandler application/x-httpd-php .php
AddHandler application/x-httpd-php-source .phps

Also i didn't use short open tags as they are disabled in
"php.ini-recommended" if you don't change anything
So use this to test
<?php
phpinfo();
?>
NOT
<? phpinfo(); ?> short open tags

added my php directory to the PATH system variable and i start apache manually not as
a service

It works for me hope it helps you!
cormac at kernan dot eu
21-Apr-2008 01:08
All good advice from henke, except where it says "Do not edit the system path". You
will NOT be able to load extensions that have dependencies e.g. MySQL, without adding
PHP to your system path. This threw me for some time as other extensions without
dependencies will work without this requirement.
cfoesterle at yahoo dot com
10-Feb-2008 04:41
I do not have IIS installed on my server, only Apache. So I had to edit the PHP.ini
file and comment out (add leading ";") to the following line
"extension=php_iisfunc.dll" as I was getting "Faulting application httpd.exe,
faulting module php_iisfunc.dll" errors when this line was active. I also added an
additional "AddType application/x-httpd-php .html" to my httpd.conf file so that
inline php would work with files ending with an extension of ".html" on my server.
mjm at alum dot mit dot edu
27-Jan-2008 04:33
If you use the PHP 5 installer, you'll notice that it uses the wrong type of slash on
Windows!

Change C:/Program Files/PHP/" to C:\Program Files\PHP\" and everything works great!
packard_bell_nec at hotmail dot com
03-Oct-2007 03:24
If you install PHP as an Apache CGI binary, you can add:
AddHandler cgi-script .php
into Apache httpd.conf, and add shebang line to every PHP scripts like:
#!php
<?php
phpinfo();
?>
. But adding shebang line has a disadvantage that if you decided to install PHP as an
Apache module afterwards, then the shebang line WILL appear in the web page.
In fact, you do NOT need to add shebang line to every PHP script even if you install
PHP as an Apache CGI binary, because you can add:
ScriptInterpreterSource Registry-Strict
into Apache httpd.conf, and make the registry file and merge it like:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\.php\Shell\ExecCGI\Command]
@="\"C:\\Program Files\\PHP\\php-cgi.exe\""
. Then you will NOT need to change the PHP scripts which do not contain shebang line.
philippeboucher at newlogiccanada dot com dot com
31-Jul-2007 09:05
To do a silent install of PHP wich correctly modify the httpd.conf file, you HAVE (I
find no other way) to put the directory of the Apache inside the INSTALLDIR's MSI
option. the APACHEDIR doesn't seem to work. That's the only way I've make it
work. Maybe it's because my Apache is not in the default directory, I don't know,
but there is a solution for people who cannot make work the silent install (for those
who are told by the php setup that it cannot find the httpd.conf file).

Hope it helps someone.
anonymousness
15-Jun-2007 02:30
Verrrrrrrry important note:

If you enable multi-byte strings for your installation of PHP, the extension loaded
MUST be the first extension in the list.

Apache, NOR PHP will generate any error messages or warning information in the error
log or in system logs about this.

This information needs to be included in the Readme or in the distributed INI files.

The recommended PHP ini's should place extension=php_mbstring.dll at the top of the
list of extensions.

I had completely forgotten about this when recently upgrading php on a test server;
and almost set out to re-install apache.
charlie at oblivion dot cz
15-Feb-2007 12:19
..try to set the extension_dir in php.ini to the absolute path.. (when you are pretty
sure that you have set the PHPIniDir the right way)
Jim Keller
11-Jan-2007 01:35
it's important to note that on Apache 2.2.3 (probably other 2.x versions as well) on
Windows, the PHPIniDir directive must use forward slashes to delimit directories, not
the backslashes commonly used for Windows path strings. If PHP seems to be ignoring
the directive, this may be why.
pcdinh at phpvietnam dot net
07-Oct-2006 10:50
PHP 6 is under active development but for those whose want to try out the new
features or just want to keep updated with the development progress of PHP 6.0, you
can follow my instructions below to install it on Windows XP and Apache 2.2.3

# For PHP 6 do something like this:
LoadModule php5_module "c:/server/php6/php6apache2_2.dll"
AddType application/x-httpd-php .php
PHPIniDir "c:/server/php6"

You should change the path as in your system. The directive LoadModule php5_module
seems a bit strange to you. It should be LoadModule php6_module instead. However, I
have just taken a look at php.internals and came across a message that said it should
be changed in the near future after the PHP 5.2 is official released. At the time I
write this, PHP 5.2 RC6 is planned to be released in the next few days.
subajawa at yahoo dot com
04-Aug-2006 08:56
To install PHP as Apache 2 CGI script, add these lines in addition to the 3 lines
mentioned in the document.

<Directory "C:/php">
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>
Isaac dot Brown at ArvinMeritor dot com
17-May-2005 12:59
Some XP machines are having troubles with the PHPIniDir derective not finding the
php.ini (or so they think). Directories that do contain a php.ini file are returned
as empty and it defaults to the next method of finding php.ini (often C:/windows or
C:/winnt).

This is likely caused by read permissions not being set correctly on NTFS file
systems, however, it has occurred when no cause could be identified. If setting
correct file permissions doesn't work, the easiest way around this problem is moving
php.ini to the Apache directory or adding the
HKEY_LOCAL_MACHINE\SOFTWARE\PHP\IniFilePath string to your registry and setting it to
the correct directory.
Sun, iPlanet and Netscape servers on Microsoft Windows
This section contains notes and hints specific to Sun Java System Web Server, Sun ONE
Web Server, iPlanet and Netscape server installs of PHP on Windows.
From PHP 4.3.3 on you can use PHP scripts with the NSAPI module to generate custom
directory listings and error pages. Additional functions for Apache compatibility are also
available. For support in current web servers read the note about subrequests.
CGI setup on Sun, iPlanet and Netscape servers
To install PHP as a CGI handler, do the following:
Copy php4ts.dll to your systemroot (the directory where you installed Windows)
Make a file association from the command line. Type the following two lines:
assoc .php=PHPScript
ftype PHPScript=c:\php\php.exe %1 %*
In the Netscape Enterprise Administration Server create a dummy shellcgi directory
and remove it just after (this step creates 5 important lines in obj.conf and allow the
web server to handle shellcgi scripts).
In the Netscape Enterprise Administration Server create a new mime type (Category:
type, Content-Type: magnus-internal/shellcgi, File Suffix:php).
Do it for each web server instance you want PHP to run
More details about setting up PHP as a CGI executable can be found here:
http://benoit.noss.free.fr/php/install-php.html
NSAPI setup on Sun, iPlanet and Netscape servers
To install PHP with NSAPI, do the following:
Copy php4ts.dll to your systemroot (the directory where you installed Windows)
Make a file association from the command line. Type the following two lines:
assoc .php=PHPScript
ftype PHPScript=c:\php\php.exe %1 %*
In the Netscape Enterprise Administration Server create a new mime type (Category:
type, Content-Type: magnus-internal/x-httpd-php, File Suffix: php).
Edit magnus.conf (for servers >= 6) or obj.conf (for servers < 6) and add the
following: You should place the lines after mime types init.
Init fn="load-modules" funcs="php4_init,php4_execute,php4_auth_trans"
shlib="c:/php/sapi/php4nsapi.dll"
Init fn="php4_init" LateInit="yes" errorString="Failed to initialise PHP!"
[php_ini="c:/path/to/php.ini"]
(PHP >= 4.3.3) The php_ini parameter is optional but with it you can place your
php.ini in your web server configuration directory.
Configure the default object in obj.conf (for virtual server classes [Sun Web Server
6.0+] in their vserver.obj.conf): In the <Object name="default"> section, place this
line necessarily after all 'ObjectType' and before all 'AddLog' lines:
Service fn="php4_execute" type="magnus-internal/x-httpd-php" [inikey=value
inikey=value ...]
(PHP >= 4.3.3) As additional parameters you can add some special php.ini-values,
for example you can set a docroot="/path/to/docroot" specific to the context
php4_execute is called. For boolean ini-keys please use 0/1 as value, not
"On","Off",... (this will not work correctly), e.g. zlib.output_compression=1 instead of
zlib.output_compression="On"
This is only needed if you want to configure a directory that only consists of PHP
scripts (same like a cgi-bin directory):
<Object name="x-httpd-php">
ObjectType fn="force-type" type="magnus-internal/x-httpd-php"
Service fn=php4_execute [inikey=value inikey=value ...]
</Object>
After that you can configure a directory in the Administration server and assign it the
style x-httpd-php. All files in it will get executed as PHP. This is nice to hide PHP
usage by renaming files to .html.
Restart your web service and apply changes
Do it for each web server instance you want PHP to run
Note: More details about setting up PHP as an NSAPI filter can be found here:
http://benoit.noss.free.fr/php/install-php4.html
Note: The stacksize that PHP uses depends on the configuration of the web server. If you
get crashes with very large PHP scripts, it is recommended to raise it with the Admin Server
(in the section "MAGNUS EDITOR").
CGI environment and recommended modifications in php.ini
Important when writing PHP scripts is the fact that Sun JSWS/Sun ONE
WS/iPlanet/Netscape is a multithreaded web server. Because of that all requests are
running in the same process space (the space of the web server itself) and this space has
only one environment. If you want to get CGI variables like PATH_INFO, HTTP_HOST etc. it
is not the correct way to try this in the old PHP way with getenv() or a similar way (register
globals to environment, $_ENV). You would only get the environment of the running web
server without any valid CGI variables!
Note: Why are there (invalid) CGI variables in the environment?
Answer: This is because you started the web server process from the admin server which
runs the startup script of the web server, you wanted to start, as a CGI script (a CGI script
inside of the admin server!). This is why the environment of the started web server has
some CGI environment variables in it. You can test this by starting the web server not from
the administration server. Use the command line as root user and start it manually - you
will see there are no CGI-like environment variables.
Simply change your scripts to get CGI variables in the correct way for PHP 4.x by using the
superglobal $_SERVER. If you have older scripts which use $HTTP_HOST, etc., you should
turn on register_globals in php.ini and change the variable order too (important: remove "E"
from it, because you do not need the environment here):
variables_order = "GPCS"
register_globals = On
Special use for error pages or self-made directory listings (PHP >= 4.3.3)
You can use PHP to generate the error pages for "404 Not Found" or similar. Add the
following line to the object in obj.conf for every error page you want to overwrite:
Error fn="php4_execute" code=XXX script="/path/to/script.php" [inikey=value
inikey=value...]
where XXX is the HTTP error code. Please delete any other Error directives which could
interfere with yours. If you want to place a page for all errors that could exist, leave the
code parameter out. Your script can get the HTTP status code with
$_SERVER['ERROR_TYPE'].
Another possibility is to generate self-made directory listings. Just create a PHP script which
displays a directory listing and replace the corresponding default Service line for
type="magnus-internal/directory" in obj.conf with the following:
Service fn="php4_execute" type="magnus-internal/directory"
script="/path/to/script.php" [inikey=value inikey=value...]
For both error and directory listing pages the original URI and translated URI are in the
variables $_SERVER['PATH_INFO'] and $_SERVER['PATH_TRANSLATED'].
Note about nsapi_virtual() and subrequests (PHP >= 4.3.3)
The NSAPI module now supports the nsapi_virtual() function (alias: virtual()) to make
subrequests on the web server and insert the result in the web page. The problem is, that
this function uses some undocumented features from the NSAPI library.
Under Unix this is not a problem, because the module automatically looks for the needed
functions and uses them if available. If not, nsapi_virtual() is disabled.
Under Windows limitations in the DLL handling need the use of a automatic detection of the
most recent ns-httpdXX.dll file. This is tested for servers till version 6.1. If a newer version
of the Sun server is used, the detection fails and nsapi_virtual() is disabled.
If this is the case, try the following: Add the following parameter to php4_init in
magnus.conf/obj.conf:
Init fn=php4_init ... server_lib="ns-httpdXX.dll"
where XX is the correct DLL version number. To get it, look in the server-root for the correct
DLL name. The DLL with the biggest filesize is the right one.
You can check the status by using the phpinfo() function.
Note: But be warned: Support for nsapi_virtual() is EXPERIMENTAL!!!

Você também pode gostar