Documente Academic
Documente Profesional
Documente Cultură
php
Chapter 1. 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.
<html>
<head>
<title>Example</title>
</head>
<body>
<?php
echo "Hi, I'm a PHP script!";
?>
</body>
</html>
Notice how this is different from a script written in other languages like Perl or C -- instead of writing a
program with lots of commands to output HTML, you write an HTML script with some embedded code to
do something (in this case, output some text). The PHP code is enclosed in special start and end tags 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. If you were to have a script similar to the above on your server, the client would receive the
results of running that script, with no way of determining what the underlying code may be. 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 webserver and a web browser. You need to run the webserver, 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:
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.
While using PHP in the e-commerce field, you'll find the Cybercash payment, CyberMUT, VeriSign Payflow
Pro and MCVE functions useful for your online payment programs.
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), 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.
Chapter 2. 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 webpage creation with PHP, though PHP is not only capable of creating webpages. 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 webserver 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:
<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.
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.
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.
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.
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 an autoglobal (or 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.)
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:
<?php
if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE) {
echo '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. You can find a list of PHP books at /books.php.
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:
<?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
}
?>
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.
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 outside of PHP for more information and examples on
using forms with PHP. Here is an example HTML 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:
It should be obvious what this does. There is nothing more to it. The $_POST['name'] and $_POST['age']
variables are automatically set for you by PHP. Earlier we used the $_SERVER autoglobal; above we just
introduced the $_POST autoglobal 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 autoglobal instead.
You may also use the $_REQUEST autoglobal, 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
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 autoglobal 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, still exist as they have since PHP 3. 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
autoglobal 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: /links.php.
To view various slide presentations that show more of what PHP can do, see the PHP Conference Material
Sites: http://conf.php.net/ and http://talks.php.net/
II. Installation and Configuration
Table of Contents
3. General Installation Considerations
4. Installation on Unix systems
5. Installation on Mac OS X
6. Installation on Windows systems
7. Installation of PECL extensions
8. Problems?
9. Runtime Configuration
Chapter 3. 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:
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 /downloads.php. We recommend
you to choose a mirror nearest to you for downloading the distributions.
Chapter 4. Installation on Unix systems
Table of Contents
Apache 1.3.x on Unix systems
Apache 2.0 on Unix systems
Caudium
fhttpd related notes
Sun, iPlanet and Netscape servers on Sun Solaris
CGI and commandline 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
webserver. 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.
The initial PHP setup and configuration process is controlled by the use of the commandline 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.
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 4-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.
11. make
12. make install
Note that unless told otherwise, 'make install' will also install PEAR,
various PHP tools such as phpize, install the PHP CLI, and more.
cp php.ini-dist /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.
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.
For PHP 4:
For PHP 5:
For PHP 4:
AddModule mod_php4.c
For PHP 5:
AddModule mod_php5.c
It's also common to setup the .phps extension to show highlighted PHP
source, this can be done with:
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.)
Example 4-2. Installation Instructions (Static Module Installation for Apache) for PHP
10. cd ../apache_1.3.x
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-dist /usr/local/lib/php.ini
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.
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.
This will create a libphp5.so (or libphp4.so in PHP 4) 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.
This will create a libphp4.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.
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 webpage 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.
These documents are complete step-by-step howtos, and describe how to buid a
self-sufficient package, including every software it depends on (zlib, SSL,
LDAP, iconv, expat, xml, xslt, gd, png, Xpm, jpeg, freetype, bzip2, curl,
MySQL, PostgreSQL, Oracle, AdoDB).
dpresley4 at yahoo dot com
06-Nov-2005 03:42
Hi,
ONE SOLUTOIN
For building php-4.4.1 or later with oci8, make sure your LD_LIBARRY_PATH
has at a minimum the following directories in its path for Oracle8i 8.1.5 or
later, Oracle9i 9.0.2 or later, and Oracle9i Release 2: 9.2.0.4 or later, do
the following:
Note: We are not using the Oracle Instant Client here. This assumes you
have an actual Oracle Installation.
1. Set ORACLE_HOME
ORACLE_HOME=/opt/app/oracle/product/9iR2
LD_LIBRARY_PATH=$ORACLE_HOME/lib: \
$ORACLE_HOME/rdbms/lib:\
$LD_LIBRARY_PATH
It should now build correctly. The key with Oracle is to ensure that you
pick up the libclntX.so (client librariess) where X is the Oracle version
associated with the version your using for instance, in the above example,
libclnt9.so
Also note that if your using Oracle 9iAS Release 2 v9.0.2, Oracle 10g iAS
Release 1 v9.0.4.1, the above steps will work because ORACLE_HOME will
containe all of the libraries necessary. Simply point ORACLE_HOME to the
top level directory of these installations and set LD_LIBRARY_PATH as
described above.
Example:
of course this is on a xeon system that has half of its modules in the
/usr/lib64 directory, so on a normal system, without the other kruft, it
would look something more like this:
Hopefully this will save someone the 6 hour headache it caused me..
diemuzi at gmail dot com
13-Jan-2005 10:11
In reference to van [at] webfreshener [dot] com to fix the krb5 problems. An
easier fix is to do the following:
ln -s /usr/kerberos/include/krb5.h /usr/include/krb5.h
ln -s /usr/kerberos/include/profile.h /usr/include/profile.h
ln -s /usr/kerberos/include/com_err.h /usr/include/com_err.h
This will help solve some deps. in the future incase a situation with
another compilation occurs.
alexander justadot henry at acm dot org
22-Dec-2004 12:48
The system at my workplace has a need for apache/php with all static
compilation. In order to save time adminning our systems, I decided to make
my own RPM of php/apache with mod_ssl support. I had always installed by
hand with the instructions on this page, but when buiding the RPM way, came
upon the following error when apache was compiling:
===> src/modules/php4
make[4]: *** No rule to make target `all'. Stop.
Ordinarily this is because one did not do a 'make install' in php before the
second apache configure, or somehow the make install failed. But the way
rpm's work, the make install must be in the %install portion of the spec
file, after all makes are completed.
make install-sapi
This line will copy relevant files to the directory specified in --with-
apache
samael99 at web dot de
24-Jun-2004 06:51
Quick hint for people using RH8:
Good Luck !
robert_sgi at yahoo dot com
08-May-2004 11:57
If you install php 4 on SGI IRIX 6.5 (in my case it was php 4.3.6 on Silicon
Graphics O2 IRIX 6.5.22 machine) and you're building it with:
--with-gettext=/usr/freeware
then you need to manually edit the file named "configure" (from the php
source directory) and change the line# 36739
from:
GETTEXT_LIBDIR=$GETTEXT_DIR/lib
to:
GETTEXT_LIBDIR=$GETTEXT_DIR/lib32
If you have problems in locating the line, search the text for
"bindtextdomain", and look several (4) lines above.
karthik (dot) k (at) extremix (dot) net
18-Jan-2004 08:28
This is regarding the post down below about the problem with openssl on RH9.
Openssl on RH9 is built with kerberos. To get PHP to build correctly you
need the output of these commands when you make.
[root@graf-spee local]# pkg-config --cflags openssl
-I/usr/kerberos/include
These could be added to your make command thus. I have not tested it out,
but should work with some tweaking
<Files *.php>
SetOutputFilter PHP
SetInputFilter PHP
</Files>
If you use both together, you will get compilation errors (duplicate symbols
while linking libphp4).
aaronmorris at mindspring dot com
05-Dec-2003 12:47
If you have the libphp4.a instead of libphp4.so on AIX, you can extract
the .so file from the .a file by running "ar -x libphp4.a".
jazee_at_bigfoot.com
26-Mar-2003 12:52
http://dan.drydog.com/apache2php.html has a nice set of instructions for
Apache2 + php
doug at NOSPAM dot techie dot net
04-Feb-2003 05:16
Users compiling under some versions of Solaris/SunOS may encounter the
following error.
symbol ap_block_alarms: referenced symbol not found
To address this problem, add the following additional flag to the Apache
build configure line:
--enable-rule=SHARED_CORE
So, adding this to the original instructions, you'd configure your Apache
build like so:
./configure --prefix=/www --enable-module=so --enable-rule=SHARED_CORE
Doug
mbabcock-php at fibrespeed dot net
20-Jul-2001 09:32
The best configuration guide I've found for Apache with PHP (and PERL,
mod_ssl, etc.) is Apacompile. Its home site is
http://www.delouw.ch/linux/apache.phtml
dimaberastau at hotmail dot com
09-Jun-2001 09:33
when installing with mysql support (--with-mysql=<path/to/your/mysql>) via
Apache APXS you'll probably get something like 'can't load
libmysqlclient.so' when you try to start up apache. There are 2 solutions to
this problem. First, (as documented in INSTALL file of the php4
distribution) you can modify /etc/ld.so.conf to contain the directory name
where libmysqlclient.so is (so if your mysql is installed in /usr/local, you
want to add something like /usr/local/lib/mysql into /etc/ld.so.conf), else
(and particularly if you haven't got the super-user on the system) you can
modify (or create if it isn't defined already) LD_LIBRARY_PATH shell
variable to reflect the changes you would have otherwise made to
/etc/ld.so.conf (again if mysql is /usr/local
LD_LIBRARY_PATH=/usr/local/lib/mysql). Either one of these methods will get
the problem sorted. Just remember to run ldconfig (so that /etc/ld.so.cache
is updated) if you chose to modify /etc/ld.so.conf
marshalm at ebrd dot com
17-May-2001 10:43
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.
Apache 2.0 on Unix systems
This section contains notes and hints specific to Apache 2.0 installs of PHP on Unix systems.
Warning
We do not recommend using a threaded MPM in production with Apache2. Use the prefork MPM instead, or
use Apache1. For information on why, read the related FAQ entry on using Apache2 with a threaded MPM
You are highly encouraged to take a look at the Apache Documentation to get a basic understanding of
the Apache 2.0 Server.
PHP and Apache 2.0.x compatibility notes: The following versions of PHP are known
to work with the most recent version of Apache 2.0.x:
Apache 2.0 SAPI-support started with PHP 4.2.0. PHP 4.2.3 works with Apache 2.0.39,
don't use any other version of Apache with PHP 4.2.3. However, the recommended setup
is to use PHP 4.3.0 or later with the most recent version of Apache2.
All mentioned versions of PHP will work still with Apache 1.3.x.
Download the most recent version of Apache 2.0 and a fitting PHP version from the above mentioned
places. This quick guide covers only the basics to get started with Apache 2.0 and PHP. For more
information read the Apache Documentation. The version numbers have been omitted here, to ensure the
instructions are not incorrect. You will need to replace the 'NN' here with the correct values from your
files.
1. gzip -d httpd-2_0_NN.tar.gz
2. tar xvf httpd-2_0_NN.tar
3. gunzip php-NN.tar.gz
4. tar -xvf php-NN.tar
5. cd httpd-2_0_NN
6. ./configure --enable-so
7. make
8. make install
9. cd ../php-NN
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 2 and MySQL support. Your
path to apxs may differ, in fact, the binary may even be named apxs2 on
your system.
11. make
12. make install
Note that unless told otherwise, 'make install' will also install PEAR,
various PHP tools such as phpize, install the PHP CLI, and more.
cp php.ini-dist /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 10.
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.
For PHP 4:
For PHP 5:
16. Use your normal procedure for starting the Apache server, e.g.:
/usr/local/apache2/bin/apachectl start
Following the steps above you will have a running Apache 2.0 with support for PHP as SAPI module. Of
course there are many more configuration options available for both, Apache and PHP. For more
information use ./configure --help in the corresponding source tree. In case you wish to build a
multithreaded version of Apache 2.0 you must overwrite the standard MPM-Module prefork either with
worker or perchild. To do so append to your configure line in step 6 above either the option --with-
mpm=worker or --with-mpm=perchild. Take care about the consequences and understand what you are
doing. For more information read the Apache documentation about the MPM-Modules.
Note: If you want to use content negotiation, read the Apache MultiViews FAQ.
Note: To build a multithreaded version of Apache your system must support threads.
This also implies to build PHP with experimental Zend Thread Safety (ZTS). Therefore not
all extensions might be available. The recommended setup is to build Apache with the
standard prefork MPM-Module.
ftp.gnu.org/non-gnu/flex
ftp.gnu.org/pub/gnu/bison
Peace ;-)
felixcca at yahoo dot ca
29-Mar-2006 06: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.
payne747 at yahoo dot com
14-Feb-2006 08:05
When compiling php 5.1.2 on Debian 3.1 (Sarge) with Apache 2.2.0, I ran into
problems with libxml2 and libxml2-config not found errors. After checking
the base install, Debian leaves out the libxml2 headers, they can be
downloaded using apt-get:
looking into your ext/ directory you may find the offensive file to be 1
byte long.
v_santhanam at nospam dot ettimadai dot amrita dot edu
12-May-2005 11:30
if you are getting the following error : "Cannot load
/usr/local/apache2/modules/libphp4.so into server: /usr/local/apache2/
modules/libphp4.so: undefined symbol: compress" , you have to add --with-
zlib to php config
sukhruprai at yahoo dot com
30-Mar-2005 03:17
For good step by step instructions read Compiling PHP and Apache 2 from
source on Linux OS:
http://www10.brinkster.com/ssruprai/comphp.asp
fggarcia at ice dot co dot cr
25-Mar-2005 05:26
I think that it's important says that the option --with-
apxs2=/usr/local/apache2/bin/apxs in the configure script it's necesary to
build the libphp5.so (in PHP5). Then in the make install command, this .so
module will be installed in the modules directory of Apache home
I see on the Web a lot of persons with the trouble of missing the libphp5.so
and this is the solution.
Regards,
Frank.
mihai dot sandu at gtstelecom dot ro
28-Feb-2005 05: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 02:21
To install mysql and mysqli with PHP5 do the following:
after doing:
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
"
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.
(Then of course 'make install' would puke on itself not having what it
needs.)
Soo, after some time looking I found that using:
libtoolize --force
and following the instructions to add the contents of 1 file to the local
file
make clean
make
Dan Scott (dan dot scott at acm dot org)
19-Jan-2005 08:36
Building PHP 5.x with Apache2 on SuSE Professional 9.1/9.2
$ ./configure --with-apxs2=/usr/sbin/apxs2
$ make
the unconventional Apache conf file layout confuses the install-sapi section
of the Makefile and the process halts with the following error:
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:
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:
--- And that's it. Everything else is just as the documentation suggests it
should be.
Jon Drukman
13-Jan-2005 04:09
We have been running Apache 2 Prefork + PHP 4 (many different versions) for
well over a year now, serving 10's of millions of pages per day on dozens of
servers. It is completely stable and reliable.
praveen dot k at masconit dot com
15-Nov-2004 01: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
praveen
nospam-1 at spam dot matt dot blissett dot me dot uk
30-Sep-2004 03:52
If you're trying to get PHP and Multiviews to work properly, try this page:
http://tranchant.plus.com/notes/multiviews
(In brief, a request for the URL http://example.net/thing, where there are
possible matches thing.php and thing.pdf, returns a 406 with many browsers
because of the application/x-httpd-php MIME type set above. The link above
gives a better method for using php, instead using these directives:
AddHandler php5-script php [or php-script for php4]
AddType text/html php
For more info see the link.)
Caudium
PHP 4 can be built as a Pike module for the Caudium webserver. Note that this is not supported with PHP
3. Follow the simple instructions below to install PHP 4 for Caudium.
You can of course compile your Caudium module with support for the various extensions available in PHP
4. See the reference pages for extension specific configure options.
Note: When compiling PHP 4 with MySQL support you must make sure that the normal
MySQL client code is used. Otherwise there might be conflicts if your Pike already has
MySQL support. You do this by specifying a MySQL install directory the --with-mysql
option.
fhttpd related notes
To build PHP as an fhttpd module, answer "yes" to "Build as an fhttpd module?" (the --with-fhttpd=DIR
option to configure) and specify the fhttpd source base directory. The default directory is
/usr/local/src/fhttpd. If you are running fhttpd, building PHP as a module will give better
performance, more control and remote execution capability.
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
webservers 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 webservers, 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.
./configure --with-mysql=/usr/local/mysql \
--with-nsapi=/opt/netscape/suitespot/ \
--enable-libgcc
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 webserver. 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):
type=magnus-internal/x-httpd-php exts=php
2. 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.
3. (PHP >= 4.3.3) The php_ini parameter is optional but with it you can place your php.ini in your
webserver config directory.
4. Configure the default object in obj.conf (for virtual server classes [version 6.0+] in their
vserver.obj.conf):
<Object name="default">
.
.
.
.#NOTE this next line should happen after all 'ObjectType' and before
all 'AddLog' lines
Service fn="php4_execute" type="magnus-internal/x-httpd-php"
[inikey=value inikey=value ...]
.
.
</Object>
5. (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"
6. 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>
7. 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.
8. 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:
<Object name="default">
AuthTrans fn=php4_auth_trans
.
.
.
</Object>
Note: The stacksize that PHP uses depends on the configuration of the webserver. If you
get crashes with very large PHP scripts, it is recommended to raise it with the Admin
Server (in the section "MAGNUS EDITOR").
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 webserver 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 3.x way with getenv() or
a similar way (register globals to environment, $_ENV). You would only get the environment of the
running webserver without any valid CGI variables!
Answer: This is because you started the webserver process from the admin server which
runs the startup script of the webserver, you wanted to start, as a CGI script (a CGI
script inside of the admin server!). This is why the environment of the started webserver
has some CGI environment variables in it. You can test this by starting the webserver 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:
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:
For both error and directory listing pages the original URI and translated URI are in the variables
$_SERVER['PATH_INFO'] and $_SERVER['PATH_TRANSLATED'].
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.
LD_LIBRARY_PATH="/usr/local/lib:/usr/lib"
vijay
13-Mar-2006 06: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....
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.
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 12: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 02: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
3. Once it's done configuring (and it should be successful should you have
all the proper packages), type:
> make
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"]
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 09:36
Quick note : By replacing "php4" with "php5", the above instructions work
perfectly when building PHP5 for an iPlanet server. EG:-
-Mark
[mark at markround dot com]
CGI and commandline setups
The default is to build PHP as a CGI program. This creates a commandline interpreter, which can be used
for CGI processing, or for non-web-related PHP scripting. If you are running a web server 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
By using the CGI setup, your server is open to several possible attacks. Please read our CGI security section
to learn how to defend yourself from those attacks.
As of PHP 4.3.0, some important additions have happened to PHP. A new SAPI named CLI also exists and
it has the same name as the CGI binary. What is installed at {PREFIX}/bin/php depends on your configure
line and this is described in detail in the manual section named Using PHP from the command line. For
further details please read that section of the manual.
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.
Benchmarking
If you have built PHP 3 as a CGI program, you may benchmark your build by typing make bench. Note
that if safe mode is on by default, the benchmark may not be able to finish if it takes longer then the 30
seconds allowed. This is because the set_time_limit() can not be used in safe mode. Use the
max_execution_time configuration setting to control this time for your own scripts. make bench ignores
the configuration file.
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'.
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 10:59
for using fastcgi external server in place of cgi or mod php with php:
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
#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.
start on target machine php with "php -b ip:port" for ear request from
mod_fastcgi.
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...
>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 10: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
This section contains notes and hints specific to installing PHP on HP-UX systems. (Contributed by
paul_mckay at clearwater-it dot co dot uk).
Note: These tips were written for PHP 4.0.4 and Apache 1.3.9.
If you have errors here, it's probably because gcc etc. are not in your PATH so add them to your
PATH.
User nobody
Group nogroup
User www
Group sys
13. This is because you can't run Apache as nobody under hp-ux. Apache and PHP should then work.
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
make
make install
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.
$ vi ./libtool
deplibs_check_method="unknown"
to
deplibs_check_method="pass_all"
$ make
Run make install. This will fail when it attempts to call apxs.
$ make install
For PHP 5:
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
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 07: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.
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;}'`
Nicolas
ichoudhury007 at yahoo dot com
30-May-2002 09:11
On HP-UX 11 ... When you are compiling PHP as DSO, you will encounter an
error during "make install"
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 02: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 08: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 10: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
22-Jan-2001 09: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 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.
# 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).
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!
"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
09-May-2003 11: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:
<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:
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.
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.
# cd /opt/sfw/gcc-3/lib/gcc-lib/i386-pc-solaris2.9/3.3.2/install-tools/
# ./mkheaders
xlark at sdf dot lonestar dot org
11-Jul-2003 07: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 06:14
./configure not run fine with /usr/ucb/tr you need to install GNU textutils
ineves at iportalmais dot pt
07-Mar-2003 03: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
This means that the ldap librarys that came with solaris, are not very fine,
you should use from openldap.org packages...
See: http://bugs.php.net/bug.php?id=16833
howardglynn at hotmail dot com
22-May-2002 10: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
03-Apr-2002 04: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 12:49
PHP 4.1.1 / Apache 1.32 Buile Issues (Solaris 2.8)
Both Apache and PHP compiled without errors and installed cleanly.
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
jakob dot nielsen at nhst dot no
08-Jan-2002 05:39
You can get all the Solaris Packages needed for the PHP installation on
http://www.sunfreeware.com/
Louis at ewens dot com
22-Jun-2001 07: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
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
22-Jan-2001 08: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.
Using APT
While you can just download the PHP source and compile it yourself, using Debian's packaging system is
the simplest and cleanest method of installing PHP. If you are not familiar with building software on Linux,
this is the way to go.
The first decision you need to make is whether you want to install Apache 1.3.x or Apache 2.x. The
corresponding PHP packages are respectively named libapache-mod-php* and libapache2-mod-php*. The
steps given below will use Apache 1.3.x. Please note that, as of this writing, there is no official Debian
packages of PHP 5. Then the steps given below will install PHP 4.
PHP is available in Debian as CGI or CLI flavour too, named respectively php4-cgi and php4-cli. If you
need them, you'll just have to reproduce the following steps with the good package names. Another
special package you'd want to install is php4-pear. It contains a minimal PEAR installation and the pear
commandline utility.
If you need more recent packages of PHP than the Debian's stable ones or if some PHP modules lacks the
Debian official repository, perhaps you should take a look at http://www.apt-get.org/. One of the results
found should be Dotdeb. This unofficial repository is maintained by Guillaume Plessis and contains Debian
packages of the most recent versions of PHP 4 and PHP 5. To use it, just add the to following two lines to
your /etc/apt/sources.lists and run apt-get update :
The last thing to consider is whether your list of packages is up to date. If you have not updated it
recently, you need to run apt-get update before anything else. This way, you will be using the most
recent stable version of the Apache and PHP packages.
Now that everything is in place, you can use the following example to install Apache and PHP:
APT will automatically install the PHP 4 module for Apache 1.3, and all its dependencies and then activate
it. If you're not asked to restart Apache during the install process, you'll have to do it manually :
# /etc/init.d/apache stop
# /etc/init.d/apache start
In the last section, PHP was installed with only core modules. This may not be what you want and you will
soon discover that you need more activated modules, like MySQL, cURL, GD, etc.
When you compile PHP from source yourself, you need to activate modules via the configure command.
With APT, you just have to install additional packages. They're all named 'php4-*' (or 'php5-*' if you
installed PHP 5 from a third party repository).
Example 4-10. Getting the list of PHP additional packages
# dpkg -l 'php4-*'
As you can see from the last output, there's a lot of PHP modules that you can install (excluding the php4-
cgi, php4-cli or php4-pear special packages). Look at them closely and choose what you need. If you
choose a module and you do not have the proper libraries, APT will automatically install all the
dependencies for you.
If you choose to add the MySQL, cURL and GD support to PHP the command will look something like this:
APT will automatically add the appropriate lines to your different php.ini
(/etc/php4/apache/php.ini, /etc/php4/cgi/php.ini, etc).
Example 4-12. These lines activate MySQL, cURL and GD into PHP
extension=mysql.so
extension=curl.so
extension=gd.so
Common Problems
• If you see the PHP source instead of the result the script should produce, APT has probably not included
/etc/apache/conf.d/php4 in your Apache 1.3 configuration. Please ensure that the following line is
present in your /etc/apache/httpd.conf file then stop/start Apache:
# Include /etc/apache/conf.d/
• If you installed an additional module and if its functions are not available in your scripts, please ensure that the
appropriate line is present in your php.ini, as seen before. APT may fail during the installation of the additional
module, due to a confusing debconf configuration.
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
23-Oct-2005 10:01
If you are using Debian 3.1
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
Table of Contents
Windows Installer
Manual Installation Steps
ActiveScript
Microsoft IIS / PWS
Apache 1.3.x on Microsoft Windows
Apache 2.0.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
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.
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 the manual installation is the best choice to have your system secure and optimised.
Windows Installer
The Windows PHP installer is available from the downloads page at /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.
http://www.tjitjing.com/blog /2006/05/php5-with-iis6-on-windows-server-
2003.html
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. )*
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.
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 08: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.
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 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();
?>
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 05: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.
Valdinei J.
21-Mar-2006 01:17
If you get problems with ISS 6 and PHP try this:
http://www.visualwin.com/PHP-ISAPI/
I've tried to install in a different folder than c:\php but when you add the
application extension mapping the ISS does not accept a path with spaces
(like c:\program files\php).
niatech
01-Mar-2006 08: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:
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.
---------------------------
# replace with your PHP4 directory
ScriptAlias /php4/ "c:/usr/php4/"
# replace with your PHP5 directory
ScriptAlias /php5/ "c:/usr/php5/"
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.
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!).
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 01: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 06: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.
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
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.
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.
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 01: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_]
steve at lonetree dott com
02-Jun-2005 05:56
Hello all. Well, I'm an experienced iis admin, but I tell you, I had a devil
of a time getting it to run correctly. My issue was that I was trying to do
everything via term services...use this link
http://www.peterguy.com/php/install_IIS6.html
to view some seriously interesting notes on this. This guy's info was SPOT
ON and worked perfectly for me. Don't forget to give Network Service group
read/execute access to your web content...
donald at netriver dot net
04-May-2005 01: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.
"Loaded DSO /..../php4apache.dll uses plain 1.3 API, this module might
crash under EAPI! (please recompile it with -DEAPI)".
If you would like the binaries or instructions on how I did it email me.
Gary
John Kerner
20-Apr-2005 03:23
This is a great instruction for installing php 5 on a windows 2003/iis 6
server. There are many other instructions out there (several listed here)
but this is by far the easiest to follow and the only one I found that
actually works with php 5 and iis 6.
http://www.tjitjing.com/code/article.php?subject=php5_iis6_install
philip
04-Mar-2005 10:51
Installation instructions for PHP+Windows with the Jigsaw web server can be
found here:
* http://www.circle.ch/servers/
doyouunderstand at gmail dot com
03-Mar-2005 04: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.
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 08: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 04: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:
At this moment, is good to make a iss restart (note this is the only resart
needed).
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.
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
09-Jan-2005 04: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 11: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:
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 04: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";
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.
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.
brian at schau dot com
09-Mar-2004 05:57
Guys,
I've just updated my page "Compiling Apache, PHP and foreign modules on a
Win32 platform" to cover the process for Microsoft Visual Studio .NET 2003
users.
http://www.schau.com/apachephp/apachephpwin32/index.html
Enjoy.
Kind regards,
Brian
ferchland at computer-kontor dot de
06-Feb-2004 08: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 01: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.
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.
yellowducklings at hotmail dot com
14-May-2003 08:29
Very readable article on installing php on windows
http://www.macromedia.com/devnet/mx/dreamweaver/articles/php_iis.html
spf at users dot sf dot net
19-Aug-2002 08: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
14-Mar-2002 09: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
31-Jul-2000 10: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!
Manual Installation Steps
This install guide will help you manually install and configure PHP with a web server on Microsoft Windows.
To get started you'll need to download the zip binary distribution from the downloads page at
/downloads.php.
Although there are many all-in-one installation kits, and we also distribute a PHP installer for Microsoft
Windows, we recommend you take the time to setup PHP yourself as this will provide you with a better
understanding of the system, and enables you to install PHP extensions easily when needed.
Upgrading from a previous PHP version: Previous editions of the manual suggest
moving various ini and DLL files into your SYSTEM (i.e. C:\WINDOWS) folder and while
this simplifies the installation procedure it makes upgrading difficult. We advise you
remove all of these files (like php.ini and PHP related DLLs from the Windows SYSTEM
folder) before moving on with a new PHP installation. Be sure to backup these files as you
might break the entire system. The old php.ini might be useful in setting up the new
PHP as well. And as you'll soon learn, the preferred method for installing PHP is to keep
all PHP related files in one directory and have this directory available to your systems
PATH.
MDAC requirements: If you use Microsoft Windows 98/NT4 download the latest version
of the Microsoft Data Access Components (MDAC) for your platform. MDAC is available at
http://msdn.microsoft.com/data/. This requirement exists because ODBC is built into the
distributed Windows binaries.
The following steps should be completed on all installations before any server specific instructions are
performed:
Extract the distribution file into a directory of your choice. If you are installing PHP 4, extract to C:\, as
the zip file expands to a foldername like php-4.3.7-Win32. If you are installing PHP 5, extract to
C:\php as the zip file doesn't expand as in PHP 4. You may choose a different location but do not have
spaces in the path (like C:\Program Files\PHP) as some web servers will crash if you do.
The directory structure extracted from the zip is different for PHP versions 4 and 5 and look like as
follows:
c:\php
|
+--cli
| |
| |-php.exe -- CLI executable - ONLY for commandline
scripting
|
+--dlls -- support DLLs required by some extensions
| |
| |-expat.dll
| |
| |-fdftk.dll
| |
| |-...
|
+--extensions -- extension DLLs for PHP
| |
| |-php_bz2.dll
| |
| |-php_cpdf.dll
| |
| |-..
|
+--mibs -- support files for SNMP
|
+--openssl -- support files for Openssl
|
+--pdf-related -- support files for PDF
|
+--sapi -- SAPI (server module support) DLLs
| |
| |-php4apache.dll
| |
| |-php4apache2.dll
| |
| |-..
|
+--PEAR -- initial copy of PEAR
|
|
|-go-pear.bat -- PEAR setup script
|
|-..
|
|-php.exe -- CGI executable
|
|-..
|
|-php.ini-dist -- default php.ini settings
|
|-php.ini-recommended -- recommended php.ini settings
|
|-php4ts.dll -- core PHP DLL
|
|-...
Or:
c:\php
|
+--dev
| |
| |-php5ts.lib
|
+--ext -- extension DLLs for PHP
| |
| |-php_bz2.dll
| |
| |-php_cpdf.dll
| |
| |-..
|
+--extras
| |
| +--mibs -- support files for SNMP
| |
| +--openssl -- support files for Openssl
| |
| +--pdf-related -- support files for PDF
| |
| |-mime.magic
|
+--pear -- initial copy of PEAR
|
|
|-go-pear.bat -- PEAR setup script
|
|-fdftk.dll
|
|-..
|
|-php-cgi.exe -- CGI executable
|
|-php-win.exe -- executes scripts without an opened command
prompt
|
|-php.exe -- CLI executable - ONLY for command line
scripting
|
|-..
|
|-php.ini-dist -- default php.ini settings
|
|-php.ini-recommended -- recommended php.ini settings
|
|-php5activescript.dll
|
|-php5apache.dll
|
|-php5apache2.dll
|
|-..
|
|-php5ts.dll -- core PHP DLL
|
|-...
Notice the differences and similarities. Both PHP 4 and PHP 5 have a CGI executable, a CLI executable,
and server modules, but they are located in different folders and/or have different names. While PHP 4
packages have the server modules in the sapi folder, PHP 5 distributions have no such directory and
instead they're in the PHP folder root. The supporting DLLs for the PHP 5 extensions are also not in a
seperate directory.
Note: In PHP 4, you should move all files located in the dll and sapi folders to the
main folder (e.g. C:\php).
Server modules provide significantly better performance and additional functionality compared to the CGI
binary. The CLI version is designed to let you use PHP for command line scripting. More information about
CLI is available in the chapter about using PHP from the command line.
Warning
The SAPI modules have been significantly improved as of the 4.1 release, however, in older systems you
may encounter server errors or other server modules failing, such as ASP.
The CGI and CLI binaries, and the web server modules all require the php4ts.dll (php5ts.dll) file
to be available to them. You have to make sure that this file can be found by your PHP installation. The
search order for this DLL is as follows:
To make php4ts.dll / php5ts.dll available you have three options: copy the file to the Windows
system directory, copy the file to the web server's directory, or add your PHP directory, C:\php to the
PATH. For better maintenance, we advise you to follow the last option, add C:\php to the PATH, because
it will be simpler to upgrade PHP in the future. Read more about how to add your PHP directory to PATH in
the corresponding FAQ entry (and then don't forget to restart the computer - logoff isn't enough).
The next step is to set up a valid configuration file for PHP, php.ini. There are two ini files distributed in
the zip file, php.ini-dist and php.ini-recommended. We advise you to use php.ini-
recommended, because we optimized the default settings in this file for performance, and security. Read
this well documented file carefully because it has changes from php.ini-dist that will drastically affect
your setup. Some examples are display_errors being off and magic_quotes_gpc being off. In addition to
reading these, study the ini settings and set every element manually yourself. If you would like to achieve
the best security, then this is the way for you, although PHP works fine with these default ini files. Copy
your chosen ini-file to a directory that PHP is able to find and rename it to php.ini. PHP searches for
php.ini in the locations described in the Section called The configuration file in Chapter 9 section.
If you are running Apache 2, the simpler option is to use the PHPIniDir directive (read the installation on
Apache 2 page), otherwise your best option is to set the PHPRC environment variable. This process is
explained in the following FAQ entry.
Note: If you're using NTFS on Windows NT, 2000, XP or 2003, make sure that the user
running the web server has read permissions to your php.ini (e.g. make it readable by
Everyone).
• Edit your new php.ini file. If you plan to use OmniHTTPd, do not follow the next step. Set the doc_root to point to
your web servers document_root. For example:
• Choose the extensions you would like to load when PHP starts. See the section about Windows extensions, about how
to set up one, and what is already built in. Note that on a new installation it is advisable to first get PHP working and
tested without any extensions before enabling them in php.ini.
• On PWS and IIS, you can set the browscap configuration setting to point to:
c:\windows\system\inetsrv\browscap.ini on Windows 9x/Me,
c:\winnt\system32\inetsrv\browscap.ini on NT/2000, and
c:\windows\system32\inetsrv\browscap.ini on XP. For an up-to-date browscap.ini,
read the following FAQ.
PHP is now setup on your system. The next step is to choose a web server, and enable it to run PHP.
Choose a webserver from the table of contents.
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 03: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".
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
13-Feb-2006 09: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.
You must verify that the versions of php5isapi.dll that you want to use are
allowed.
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.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
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
26-Dec-2005 06: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 =
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
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.
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.
mic42 at users dot sourceforge dot net
30-Nov-2004 08:09
To install PHP as CGI under the Tcl Webserver Tclhttpd follow the
instructions at:
http://wiki.tcl.tk/12130
chuacheehow at gmail dot com
08-Oct-2004 05: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 06: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:
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
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. You may download this PECL
extension DLL from the PHP Downloads page or at http://snaps.php.net/.
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.
That's all !!
Now, your code don't need XML tag at the begining. Hello work in test.phs
will be:
This section contains notes and hints specific to IIS (Microsoft Internet Information Server).
Warning
By using the CGI setup, your server is open to several possible attacks. Please read our CGI security section
to learn how to defend yourself from those attacks.
• First, read the Manual Installation Instructions. Do not skip this step as it provides crucial information for installing PHP
on Windows.
• CGI users must set the cgi.force_redirect PHP directive to 0 inside php.ini. Read the faq on cgi.force_redirect for
important details. Also, CGI users may want to set the cgi.redirect_status_env directive. When using directives, be
sure these directives aren't commented out inside php.ini.
• The PHP 4 CGI is named php.exe while in PHP 5 it's php-cgi.exe. In PHP 5, php.exe is the CLI, and not
the CGI.
• Modify the Windows PATH environment variable to include the PHP directory. This way the PHP DLL files, PHP
executables, and php.ini can all remain in the PHP directory without cluttering up the Windows system directory.
For more details, see the FAQ on Setting the PATH.
• The IIS user (usually IUSR_MACHINENAME) needs permission to read various files and directories, such as
php.ini, docroot, and the session tmp directory.
• Be sure the extension_dir and doc_root PHP directives are appropriately set in php.ini. These directives depend on
the system that PHP is being installed on. In PHP 4, the extension_dir is extensions while with PHP 5 it's ext.
So, an example PHP 5 extensions_dir value is
"c:\php\ext" and an example IIS doc_root value is
"c:\Inetpub\wwwroot".
• PHP extension DLL files, such as php_mysql.dll and php_curl.dll, are found in the zip package of the
PHP download (not the PHP installer). In PHP 5, many extensions are part of PECL and can be downloaded in the
"Collection of PECL modules" package. Files such as php_zip.dll and php_ssh2.dll. Download PHP files
here.
• When defining the executable, the 'check that file exists' box may also be checked. For a small performance penalty,
the IIS (or PWS) will check that the script file exists and sort out authentication before firing up PHP. This means that
the web server will provide sensible 404 style error messages instead of CGI errors complaining that PHP did not
output any data.
PHP may be installed as a CGI binary, or with the ISAPI module. In either case, you need to start the
Microsoft Management Console (may appear as 'Internet Services Manager', either in your Windows NT
4.0 Option Pack branch or the Control Panel=>Administrative Tools under Windows 2000/XP). Then right
click on your Web server node (this will most probably appear as 'Default Web Server'), and select
'Properties'.
• If you don't want to perform HTTP Authentication using PHP, you can (and should) skip this step. Under ISAPI Filters,
add a new ISAPI filter. Use PHP as the filter name, and supply a path to the php4isapi.dll /
php5isapi.dll.
• Under 'Home Directory', 'Virtual Directory', or 'Directory', do the following:
• Change the Execute Permissions to 'Scripts only'
• Click on the 'Configuration' button, and choose the Application Mappings tab. Click Add and set the Executable path to
the appropriate ISAPI DLL. An example PHP 5 value is: C:\php\php5isapi.dll Supply .php as the
extension. Leave 'Method exclusions' blank, and check the 'Script engine' checkbox. Now, click OK a few times.
• Stop IIS completely (NET STOP iisadmin)
• Start IIS again (NET START w3svc)
With IIS 6 (2003 Server), open up the IIS Manager, go to Web Service Extensions, choose "Add a new
Web service extension", enter in a name such as PHP, choose the Add button and for the value browse to
either the ISAPI file (php4isapi.dll or php5isapi.dll) or CGI (php.exe or php-cgi.exe) then
check "Set extension status to Allowed" and click OK.
In order to use index.php as a default content page, do the following: From within the Documents tab,
choose Add. Type in index.php and click OK. Adjust the order by choosing Move Up or Move Down. This
is similar to setting DirectoryIndex with Apache.
The steps above must be repeated for each extension that is to be associated with PHP scripts. .php is the
most common although .php3 may be required for legacy applications.
If you experience 100% CPU usage after some time, turn off the IIS setting Cache ISAPI Application.
PWS 4 does not support ISAPI, only PHP CGI should be used.
• Edit the enclosed pws-php4cgi.reg / pws-php5cgi.reg file (look into the SAPI folder for PHP 4, or in
the main folder for PHP 5) to reflect the location of your php.exe / php-cgi.exe. Backslashes should be
escaped, for example: [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\w3svc\parameters\Script Map]
".php"="C:\\php\\php.exe" (change to C:\\php\\php-cgi.exe if you are using PHP 5) Now merge this registery file into
your system; you may do this by double-clicking it.
• In the PWS Manager, right click on a given directory you want to add PHP support to, and select Properties. Check the
'Execute' checkbox, and confirm.
The recommended method for configuring these servers is to use the REG file included with the
distribution (pws-php4cgi.reg in the SAPI folder for PHP 4, or pws-php5cgi.reg in the main folder
for PHP 5). You may want to edit this file and make sure the extensions and PHP install directories match
your configuration. Or you can follow the steps below to do it manually.
Warning
These steps involve working directly with the Windows registry. One error here can leave your system in an
unstable state. We highly recommend that you back up your registry first. The PHP Development team will
not be held responsible if you damage your registry.
• Run Regedit.
• Navigate to: HKEY_LOCAL_MACHINE /System /CurrentControlSet /Services /W3Svc /Parameters /ScriptMap.
• On the edit menu select: New->String Value.
• Type in the extension you wish to use for your php scripts. For example .php
• Double click on the new string value and enter the path to
php.exe in the value data field. ex:
C:\php\php.exe "%s" %s for PHP 4, or C:\php\php-cgi.exe "%s" %s for PHP 5.
• Repeat these steps for each extension you wish to associate with PHP scripts.
The following steps do not affect the web server installation and only apply if you want your PHP scripts to
be executed when they are run from the command line (ex. run C:\myscripts\test.php) or by
double clicking on them in a directory viewer window. You may wish to skip these steps as you might
prefer the PHP files to load into a text editor when you double click on them.
PWS and IIS 3 users now have a fully operational system. IIS 3 users can use a nifty tool from Steven
Genusa to configure their script maps.
1. Most of the problems folks are experiencing on the server side are .NET
2.0 induced. If you must run .NET 2.0 then you need dll's that were compiled
with Visual Studio 8. The big push behind VS.8 and the Express editions is
to get you off of PHP and onto C#. Keep that in mind when you develop apps.
2. You can run .NET 2.0 and Visual studio on XP with PHP and IIS if you
install Visual Studio first. Visual studio installs its own dedicated
version of IIS that works with .NET 2.0 but will not run php. After VS is
installed go ahead and install the included XP version of IIS and configure
your virtual sites with PHP. If you do it the other way around, VS will
incorporate itself into the xp IIS and your PHP will probably not run.
3. Put the PHP ini file where windows wants it, in the (system root)
"c:\windows" dir. If you do that, and you are using only the ISAPI dll's,
you just need to change the ini file to point to the ext directory correctly
and it will run fine. I usually do all the pathing recommendations and set
phprc=(php directory) too. I also leave a copy of the current ini file in
the php directory root just incase php forgets to consult with the OS before
looking for something.
Most of the problems with permissions are comming from .NET 2.0. You should
never have to weaken security to get PHP to run.
4. Slightly out of scope but important nonetheless. If you do not run .NET
2.0, the ordering of your extensions (ie..mysql.dll, etc.) becomes far less
important. You may see a hang occasionally but its rare.
From http://www.geocities.com/legolas.1558/php_iis_permission_denied.htm
1. Did you disable Simple File Sharing? From any folder click Tools ->
Folder Options -> View (tab)-> (scroll the list and find "Simple File
Sharing (reccomended)") UNTICK IT
2. Locate your localhost root directory, usually C:\InetPub\wwwroot\
3. Open the Properties of the whole directory, in our case wwwroot
4. Click the Protection tab(where to manage user rights)
5. Click Add and then click Advanced (button in the bottom-left part of
the window)
6. Click Find (the only enabled button between Columns and Stop)
7. Pick the user that starts with IUSR_ (which is the IIS default user)
from the list Windows has kindly found for you
8. push OK twice
9. the new added IUSR_ will be selected, from the Authorizations list
check Edit (to allow file creation/deletion) and Write (to allow file
modify)
10. click OK one more time to get back to your native folder
EvilPuppetMaster
23-Mar-2006 07:39
After having recently gone through a long process of trial and error
installing both php4 and php5 on a single machine under IIS. I eventually
did get it working so I thought I'd share what I learnt.
Basically, as far as I can tell there is no way to get both versions working
using the ISAPI dlls unfortunately. You can however get them working using
one as ISAPI and the other as CGI. And probably both as CGI too, although I
didn't try that.
You'll need to know how to do a manual install of PHP anyway, see the
instructions for how to do that. Make sure you follow the steps about your
PATH env variable and Allowing extensions on IIS 6. Keep your php.inis in
the relevant php directory and make sure they are not in your windows or
system32 folders. And all that other hoopla.
The crucial part is your php.ini files. The problem being that both versions
will look at your PHPRC setting and get the ini file path from that. So
you'll end up with both versions running off the same INI which is no good.
The way around this is to use the CGI for one version and ISAPI for the
other.
The ISAPI dll never seems to look in it's own directory for the ini file,
but the CGI exe does. You can use that quirk to your advantage by naming the
INI file for the ISAPI version 'php-isapi.ini' and setting the PHPRC
environment variable to that path. Then for the CGI version keep the php.ini
in the same directory as php.exe.
Then set your virtual server to use either the ISAPI module for one version,
or the CGI module for the other version, and it should work. Test using
phpinfo() to ensure each version is getting it's ini file from the correct
place.
Basically it seems that the ISAPI module will look in the path set in PHPRC
first, and choose the php-isapi.ini file. The CGI module will look in PHPRC
first too, but it upon seeing no php.ini it will then move on to search it's
own directory, where it finds php.ini.
Martu
23-Mar-2006 05:07
I have fixed the 404 with this message found at google groups:
-----------------------------------------------------------
I could not get PHP pages to display in IIS 6 with Windows 2003, using the
default install of the stable binaries from php.net.
To do this,
1. Open the IIS Management console
2. Expand the server, right click on "Web Sites" and click Properties
3. Open the "ISAPI Filters" foldertab
4. Click Add
5. Enter PHP in the Filter Name box.
6. Click Browse and then Browse to your php4isapi.dll.
6. Click ok -> Apply -> ok
... Once this is completed, your PHP scripts still won't run. The problem
is that you have to define and enable PHP as a "Web Service Extension".
To do this,
1. Open the IIS Management console
2. Expand the server, and expand the "Web Services Extensions"
3. Click "Add a new Web services Extension"
4. Enter PHP in the Extension Name box.
5. In the required files box, Browse to your php directory and add
php4isapi.dll.
6. Click ok -> Apply -> ok
Last but not least, You may or may not need to do the following,
-Set the extensions path in the php.ini file if you are going to use any
extensions , i.e. php_mssql.dll
-I had to copy the php4isapi.dll from c:\php\isapi to c:\php, YMMV
-Give the webserver user (IUSR_MACHINENAME in most cases) read and execute
access to php4isapi.dll and php4ts.dll
Good Luck,
Ejay Hire
EjayH...@hotmail.com
----------------------------------------------------------
paul_noeldner at hotmail dot com
03-Oct-2005 07:58
PROBLEM
PHP $DOCUMENT_ROOT was not set in IIS.
ANALYSIS
A Google search turned up a suggestion re using ISAPI instead of CGI.
SOLUTION
I did the fix per these suggested steps from Google search:
1 Downloaded PHP5 zip
2 Added ISAPI filter PHP5ISAPI.DLL named PHP
3 Changed document type .php to point at the PHP5ISAPI.DLL file instead of
PHP.EXE.
RESULT
This worked - the php pages started picking up $DOCUMENT_ROOT as expected.
General suggestion: Don't waste time with CGI, use ISAPI.
Jamez
23-Sep-2005 05:29
PHP 5, IIS 5, Win XP:
One thing to note: if you run phpinfo() and the 'Configuration File
(php.ini) Path' points to a directory and not the actual file (ie.
C:\\windows instead of C:\\windows\\php.ini) this means that it is not using
your php.ini file, it is using default settings.
After spending hours searching forums the only thing that got it to work for
me was to create a new environment system variable called 'PHPRC' and set it
to the path where your php.ini is located (ie C:\\PHP) - simply adding
C:\\PHP to the system path variable didn't do it. You have to reboot after
this change of course. I'm not sure why this isn't more documented as from
my searching there are quite a few people who experience this problem...
hope this helps!
webwhammy.com
15-Sep-2005 04:53
After installing PHP and running an http://localhost/test.php file in my
browser, I encountered a COM Surrogate error. After some testing, I found
that it was a result of un-checking the Cache ISAPI applications checkbox.
Consequently, make sure that the Cache ISAPI applications checkbox has a
check in it. To get to the checkbox go to:
When you are at the IIS window in the left navigational panel go to:
When installing PHP 5 on IIS 6.0 and Windows 2003 I encountered problems
with this instruction. I believe the root cause is that IIS requires the
"scripts and executables" execute permission to be selected if the script
engine has a .exe extension.
However, there may have been additional problems. Even when selecting the
"scripts and executables" execute permission I continually received HTTP
Header errors. The resolution was to follow the instructions for use of
php5isapi.dll. The .dll extension can be run with the "scripts only" execute
permission. Also remember IIS 6.0 requires that you identify Web Extensions
and Allow execution of those extensions.
peter at peterguy dot com
31-Mar-2005 10:43
Installing PHP 5 on Windows Server 2003/IIS6
http://www.peterguy.com/php/install_IIS6.html
Enjoy!
-Peter
Marat
16-Mar-2005 01:50
The correct required NTFS ACL's are:
There is no 'IISEXT.VBS'.
It seems not to have to add it to the Web enhancing
(It is not an accurate intelligence ).
Moreover, when the method argument of iis6
isapimap add is omitted, it becomes an error.
Specify it following and specifying it.
Good Luck !
Person who wants ISAPI version installer
24-Feb-2005 01:34
Hint registered to IIS 6 as ISAPI without using GUI.
(It is a machine translation from Japanese to English. )
<addition example>
<deletion example>
<addition example>
C# source code
(Add 'System.DirectoryServices' to the reference)
------------------------------------------------------------
using System;
using System.Collections;
using System.DirectoryServices;
namespace IIS6ISAPIMAP
{
class StartClass
{
public static void print_man()
{
Console.WriteLine("IIS6ISAPIMAP [view|add|delete] <.ext> <ISAPI
DLL PATH> (METHOD LIST)");
}
[STAThread]
static void Main(string[] args)
{
if ( args.GetLength(0) < 1 )
{
print_man();
return;
}
System.DirectoryServices.DirectoryEntry dent
= new DirectoryEntry("IIS://localhost/W3SVC/1/root");
ArrayList orglist
= new ArrayList( dent.Properties["ScriptMaps"] ) ;
if ( args[0].ToLower() == "view" )
{
foreach(string s in orglist)
{
Console.WriteLine(s);
}
}
else if ( args[0].ToLower() == "add" )
{
if ( args.GetLength(0) < 3 )
{
print_man();
}
else
{
ArrayList newlist = new ArrayList();
string ext = args[1];
string path = args[2];
string methods = args.GetLength(0) < 4 ? "" : args[3];
string newmap = ext + "," + path + ",5," + methods;
foreach(string s in orglist)
{
string [] tokn = s.Split(',');
if ( tokn[0].ToLower() != ext.ToLower() )
{
newlist.Add( s );
}
}
newlist.Add( newmap );
dent.Properties["ScriptMaps"].Value = newlist.ToArray();
dent.CommitChanges();
}
}
else if ( args[0].ToLower() == "delete" )
{
if ( args.GetLength(0) < 2 )
{
print_man();
}
else
{
ArrayList newlist = new ArrayList();
string ext = args[1];
foreach(string s in orglist)
{
string [] tokn = s.Split(',');
if ( tokn[0].ToLower() != ext.ToLower() )
{
newlist.Add( s );
}
}
dent.Properties["ScriptMaps"].Value = newlist.ToArray();
dent.CommitChanges();
}
}
else
{
print_man();
}
dent.Dispose();
}
}
}
php at at dougdossett dot com
06-Jan-2005 11:05
I had problems upgrading to 5.0.3 isapi on my IIS 6/Windows 2003 server.
Most of the instructions I found said to give the IUSR account access to
various files/folders. In my case I needed to give access to "Network
Service" (not to be confused with just "Network").
Don't know if this will help anyone else, but thought I'd offer in case.
megawhizzz at netscape dot com
11-Oct-2004 04:19
Path references (e.g. for browscap.ini) in php.ini MUST be enclosed with
double-quotes (") instead of single-quotes(') for PHP to load correctly
under IIS
paul at heisholt dot net
30-Aug-2004 01:43
There's a bug in IIS 5.1 which may prevent you from adding an Application
Extension Mapping. If the OK button remains disabled after you've entered
the Executable and the Extension, try this workaround provided by Microsoft:
1. Right-click the individual Web site or the Web Sites folder, and then
click Properties.
2. On the Home Directory tab, click Configuration.
3. Under Application Configuration, click Add, and then click the Mappings
tab.
4. With the Add/Edit Application Extension Mapping dialog box open, click
Browse to select the .exe file or the .dll file from the local path on the
Web server.
Note:
You must type the path to a valid file in the Executable text box or the OK
button remains unavailable. The easiest way to make sure that you enter a
valid path is to select the file by using the Browse button.
5. After the path appears in the Executable text box, click in the
Executable text box to initialize the path.
6. Click in the Extension space, and then type the file name extension.
Note:
- You must enter the period (.) in front of the extension in the Extension
text box, or the OK button remains unavailable.
Source: http://support.microsoft.com/?id=317948
-paul-
webmaster at avalon dot de
12-Aug-2004 07:55
If you use IIS6 you have to add a new Webextension for PHP to work,
otherwise you will get a "404"-Page if you try to point your browser to a
"*.php" file.
In order to do this you have to open the IIS-management console and open the
"local computer".
Under "webextensions" you will find allready a list with different
extensions all being blocked by default.
To get PHP to work you have to manually add a new webextension. I only have
a german version of IIS in front of me so forgive me if i translate the
buttons wrongly.
Click on "New webextension". Enter any name you like for your new extension.
Click on "Add..." and then on "Search...". If you would like to add the DLL
just browse to your PHP-directory and you will find the php5ts.dll. If you
search for the php-cgi.exe you have to change the filetype at the bottom to
"CGI-Exe-Files". Only after changing the filetype you can see the php-
cgi.exe file and choose it for the extension.
If you check the checkbox at the bottom of the "New extension" Window it
will allow the newly added extension to be executed. Certainly you can
change the status any time you want by clicking on "Allow".
Only after that procedure you will be able to get in touch with PHP-files.
sincerely
Juergen Sommer
venimus at mail dot com
06-Jun-2004 07:57
Under IIS6 (and earlier)
After all the installation, do not forget to add "index.php" as default
page, under the Documents tab in the Web Site's Properties.
1. Right-click Web Sites, choose Properties
2. Click Documents tab
3. Click Add...
4. Type index.php, click Ok
5. Choose "index.php" from the list and move it to the top using Move Up
button.
6. Make sure "Enable default content page" is checked.
For those that do not know what is this for: If you do not provide full URL
and you have several pages in the directory which are in this list, the
server will return the topmost of them. In case you wish to open other page
of them, you have to provide its full URL. Putting "index.php" on top will
make sure no other pages will be returned as default.
jorrit at gameparty dot net
01-Jun-2004 04:33
If you experience extreme high loading times, please have a look at this
http://bugs.php.net/bug.php?id=28524
tstirrat AT optusnet DOT com DT au
20-Apr-2004 08:14
I am running Active Directory & IIS6.0
I found that after looking through the tutorial below i was still unable to
get into my site (authentication popup, 401.3 error). I set my permissions
for read & execute for IUSR_(server) and IIS_WPG for both my document root
and the php directory.. no luck.
1. You want to give the IUSR_* and IIS_WPG read & execute permission to the
PHP DIRECTORY ONLY. (I managed to remove the credentials from my document
root and it still works.
2. Open IIS Manager and go to Application Pools, then to the pool which is
relevant to your site (in my case DefaultAppPool).. on this item, right
click and choose properties.
Note: i also changed the passwords for my IUSR_* and IWAM_* accounts to be
sure they werent set to something easy by default. Its probably a good idea
to do this too.
For more detail on the issue, read articles 216828 and 218756 in the MS
Knoweledge Base.
Aaron Blew
11-Feb-2004 12:24
Under IIS 6, don't forget that you have to add all the PHP modules you'd
like to run to the PHP Web Service Extension part under the IIS management
console.
webmaster at riachao dot com
12-Aug-2003 06:49
In the installation with IIS 6.0, after you add the isapi extension, you
need to allow the extension in the Web Services Extensions, or you 'll get a
404 error.
nbrookins at cbwstores dot com
10-Apr-2003 09:16
On Windows Server 2003 (formerly .net server) with IIS 6 (final RTM - build
3790)
I noted however, that I did not need to 'allow unknown Isapi applications' ,
and I was able to keep the configuration at 'Scripts Only' instead of
'Scripts and Executables' - both settings are potentially more secure this
way.
The only configuration that is different from how I normally configure PHP
on IIS 5 is the addition of PHP as a Web Service Extension.
jdogg00 at msn dot com
03-Nov-2002 08:50
Here's a quick fyi, to get PHP installed on .Net Server w/ IIS 6 you have to
use the IIS manager to enable support for different web service extentions.
CGI ,ASP, ISAPI are all prohibited by default. In IIS manager click on the
Web Service Extentions Folder there's options to add a new extention ,
prohibit all extentions etc. I chose add new extention ,in the dialog box I
named it PHP , click add , in the next dialog browse to path of
'php4isapi.dll' hit ok then mark checkbox "Set extention status Allowed"
hit ok and all is good. This was done after I followed the install.txt for
IIS 4 or newer .
greg at wfrmls dot com
22-Jan-2001 09:12
When using WindowsNT 4.0 and IIS, the WWW home directory needs to have Read
AND Execute access rights.
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.
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 must be converted to
forward slashes, as c:/directory/file.ext. A trailing slash may also be necessary
for directories.
You should add the following lines to your Apache httpd.conf file:
This assumes PHP is installed to c:\php. Adjust the path if this is not the case.
For PHP 4:
For PHP 5:
For both:
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:
# For PHP 4
Action application/x-httpd-php "/php/php.exe"
# For PHP 5
Action application/x-httpd-php "/php/php-cgi.exe"
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
By using the CGI setup, your server is open to several possible attacks. Please read our CGI security section
to learn how to defend yourself from those 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'); ?>.
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.
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 02: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 05: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.0.x on Microsoft Windows
This section contains notes and hints specific to Apache 2.0.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: Users of Apache 2.2.x may use the documentation below except the appropriate
DLL files are instead named php4apache2_2.dll and php5apache2_2.dll. These
exist in the PHP distribution as of PHP 5.2.0. See also http://snaps.php.net/
Warning
We do not recommend using a threaded MPM in production with Apache2. Use the prefork MPM instead, or
use Apache1. For information on why, read the related FAQ entry on using Apache2 with a threaded MPM
You are highly encouraged to take a look at the Apache Documentation to get a basic understanding of
the Apache 2.0.x Server. Also consider to read the Windows specific notes for Apache 2.0.x before reading
on here.
PHP and Apache 2.0.x compatibility notes: The following versions of PHP are known
to work with the most recent version of Apache 2.0.x:
Apache 2.0 SAPI-support started with PHP 4.2.0. PHP 4.2.3 works with Apache 2.0.39,
don't use any other version of Apache with PHP 4.2.3. However, the recommended setup
is to use PHP 4.3.0 or later with the most recent version of Apache2.
All mentioned versions of PHP will work still with Apache 1.3.x.
Warning
Apache 2.0.x is designed to run on Windows NT 4.0, Windows 2000 or Windows XP. At this time, support for
Windows 9x is incomplete. Apache 2.0.x is not expected to work on those platforms at this time.
Download the most recent version of Apache 2.0.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 two ways to set up PHP to work with Apache 2.0.x on Windows. One is to use the CGI binary
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.
Note: Remember that when adding path values in the Apache configuration files on
Windows, all backslashes such as c:\directory\file.ext must be converted to
forward slashes, as c:/directory/file.ext. A trailing slash may also be necessary
for directories.
You need to insert these three lines to your Apache httpd.conf configuration file to set up the CGI
binary:
# For PHP 4
Action application/x-httpd-php "/php/php.exe"
# For PHP 5
Action application/x-httpd-php "/php/php-cgi.exe"
Warning
By using the CGI setup, your server is open to several possible attacks. Please read our CGI security section
to learn how to defend yourself from those attacks.
You need to insert these two lines to your Apache httpd.conf configuration file to set up the PHP
module for Apache 2.0:
Note: Remember to substitute your actual path to PHP for the c:/php/ in the above
examples. Take care to use either php4apache2.dll or php5apache2.dll in your
LoadModule directive and not php4apache.dll or php5apache.dll as the latter
ones are designed to run with Apache 1.3.x.
Warning
Don't mix up your installation with DLL files from different PHP versions. You have the only choice to use the
DLL's and extensions that ship with your downloaded PHP version.
I nearly lost my nerves... Couldn't find any mistakes, than I`ve downloaded
'php5apache2.dll-php5.1.x.zip' from http://www.apachelounge.com/download
and exchanged it, now it works... Thank you for the advise! It has helped
me a lot.
It works!!! :lol:
m 1 b x d at htomail dot com
10-May-2006 06:22
Indeed the references to "apachelounge" are a lifesaver!
http://www.apachelounge.com/
MX
philip at php dot net
05-May-2006 11:57
If you use Apache 2.2.x, the included DLLs (php4apache2.dll and
php5apache2.dll) will not work for you as they are specific to the Apache
2.0.x API. There is an open bug report to address this issue but if you
can't wait then go to the following URL and download an appropriate DLL for
Apache 2.2.x:
* http://apachelounge.com/
The PHP Group does not endorse this site but it appears useful, so use
it :-)
lyh@edu
04-May-2006 08:13
I had a hard time to install PHP5.1 with Apache2.2 as a module, because
whenever I tried to start apache, I always got the error that "Cannot load
C:/php/php5apache2.dll into server: The specified module could not be
found."
I have checked that php5apache2.dll does in the right directory of
"c:/php/", and I have also tried to copy some files (php5ts.dll, php.ini)
into relevant directories, such as WINDOWS/, Apache2/, but none of them
worked.
BTW, I am using a XP home and folllowed the instructions on the top part of
this page.
chris -dot- chaudruc -at- gmail -dot- co
15-Dec-2005 07:02
This took a while for me to figure out but hopefully it will save some time
for others.
Running Apache 2, PHP 5.1.1 on Windows XP and could not get mysql library to
load. Extension path was correct in php.ini and the module resided in the
correct spot.
From Zend:
"Some modules depend of other libraries, like MySQL. In this case you need
to copy libmysql.dll from your MySQL/bin installation directory to a
directory in your PATH, like C:\WINDOWS"
Frankly I've never had any difficulty with Apache and MySQL under Program
Files, PHP5 deep in the Apache tree, and all documents under My Docs.. Here
are the related Apache 2 config lines I use in case anyone is interested
(sorry if there are broken lines):
# PHP 5 module
LoadModule php5_module "c:/Program Files/Apache
Group/Apache2/php5/php5apache2.dll"
AddType application/x-httpd-php .php
PHPIniDir "C:/Program Files/Apache Group/Apache2/php5/"
msonsuz at example dot com
14-Oct-2005 06:28
When you try apache using the bin directory use the command: apache -n
"service_name" -t
Use for service_name the name u used. You can find the service_name also in
the system tray
withheld at withheld dot com
06-Aug-2005 06:40
BTW I use Win9x to develop but it's not a production server. And yes, adding
a trailing slash to the PHPIniDir directive helps.
Isaac dot Brown at ArvinMeritor dot com
17-May-2005 05: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.
wrowe at apache dot org
11-Apr-2005 05:26
Although the warning above reads "We do not recommend using a threaded MPM
in production with Apache2" - ignore that nonsense for Win32.
All Apache/Win32 builds were *always* threaded. Always choose Apache 2 over
Apache 1.3 on Windows - because major portions of Apache 2 were written from
the ground up to accept Windows.
Apache 1.3 was never designed for threads or non-posix systems. For Windows
they were squirled in with some rather ugly hacks, which will never enjoy
much improvement.
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
webservers read the note about subrequests.
• 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
• 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.
• (PHP >= 4.3.3) The php_ini parameter is optional but with it you can place your php.ini in your webserver config
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:
<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 webserver. If you
get crashes with very large PHP scripts, it is recommended to raise it with the Admin
Server (in the section "MAGNUS EDITOR").
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 webserver 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 3.x way with getenv() or
a similar way (register globals to environment, $_ENV). You would only get the environment of the
running webserver without any valid CGI variables!
Answer: This is because you started the webserver process from the admin server which
runs the startup script of the webserver, you wanted to start, as a CGI script (a CGI
script inside of the admin server!). This is why the environment of the started webserver
has some CGI environment variables in it. You can test this by starting the webserver 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:
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:
For both error and directory listing pages the original URI and translated URI are in the variables
$_SERVER['PATH_INFO'] and $_SERVER['PATH_TRANSLATED'].
The NSAPI module now supports the nsapi_virtual() function (alias: virtual()) to make subrequests on
the webserver and insert the result in the webpage. 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:
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.
Warning
By using the CGI setup, your server is open to several possible attacks. Please read our CGI security section
to learn how to defend yourself from those attacks.
You need to complete the following steps to make PHP work with OmniHTTPd. This is a CGI executable
setup. SAPI is supported by OmniHTTPd, but some tests have shown that it is not so stable to use PHP as
an ISAPI module.
Important for CGI users: Read the faq on cgi.force_redirect for important details. This
directive needs to be set to 0.
Repeat steps 2 - 6 for each extension you want to associate with PHP.
Note: Some OmniHTTPd packages come with built in PHP support. You can choose at
setup time to do a custom setup, and uncheck the PHP component. We recommend you
to use the latest PHP binaries. Some OmniHTTPd servers come with PHP 4 beta
distributions, so you should choose not to set up the built in support, but install your
own. If the server is already on your machine, use the Replace button in Step 4 and 5 to
set the new, correct information.
Sambar Server on Microsoft Windows
This section contains notes and hints specific to the Sambar Server for Windows.
This list describes how to set up the ISAPI module to work with the Sambar server on Windows.
#for PHP 4
*.php = c:\php\php4isapi.dll
#for PHP 5
*.php = c:\php\php5isapi.dll
This list describes how to set up the PHP CGI binary to work with Xitami on Windows.
Important for CGI users: Read the faq on cgi.force_redirect for important details. This
directive needs to be set to 0. If you want to use $_SERVER['PHP_SELF'] you have to
enable the cgi.fix_pathinfo directive.
Warning
By using the CGI setup, your server is open to several possible attacks. Please read our CGI security section
to learn how to defend yourself from those attacks.
• Make sure the webserver is running, and point your browser to xitamis admin console (usually
http://127.0.0.1/admin), and click on Configuration.
• Navigate to the Filters, and put the extension which PHP should parse (i.e. .php) into the field File extensions (.xxx).
• In Filter command or script put the path and name of your PHP CGI executable i.e. C:\php\php.exe for PHP 4,
or C:\php\php-cgi.exe for PHP 5.
• Press the 'Save' icon.
• Restart the server to reflect changes.
in Xitami, defaults.cfg
under CGI_ENVIRONMENT
insert CGI_REDIRECT_STATUS="-"
rjb1 at catalog dot net dot au
18-Sep-2004 07:23
I am running xitami as a business www server on ms-windows. I have a number
of long-running PHP scripts. I developed a tiny java applet to receive and
display progressive status information from these slow scripts. It
effectively facilitates SERVER PUSH from PHP scripts to IE and Netscape
browsers. Take a look: catalog.net.au/netClient.zip (Ron Boles, Melbourne,
Australia)
rjb1 at catalog dot net dot au
12-Apr-2004 05:57
PHP via ISAPI with XITAMI
I have developed a small GUI in c++, which runs XITAMI and configures the
Xitami ISAPI interface for use with PHP. It is so much faster than the PHP
cgi interface and appears to be more stable too.
Take a look here: http://catalog.net.au/xisapi/default.html
Ron Boles
Melbourne, Australia
Roshambo
16-Oct-2003 01:39
I was only able to get PHP (4.3.3) working under Xitami (2.5c0) on Windows
XP (SP1) by adding the following lines to defaults.cfg:
[Mime]
php=application/x-httpd-php
[Filter]
.php="c:/php/php.exe"
Note the quotation marks and the forward slashes in the filter section.
david at advisorymatters dot co dot uk
12-Sep-2003 04:54
Using the CGI (c:\php[version]\php.exe) with Xitami since PHP version 4.3.2
requires the following setting in php.ini before the $_SERVER['PHP_SELF']
call will return a value:
cgi.fix_pathinfo=1
I had a test.php and got the error message. I changed the defaults.cfg and
also the cgi.force_redirect to = 0. After restarting the Xitami the error
message was still there.
After a while I saved the test.php file to test2.php and found that it is
working fine...
Building from source
This chapter teaches how to compile PHP from sources on windows, using Microsoft's tools. To compile
PHP with cygwin, please refer to Chapter 4.
Requirements
To compile and build PHP you need a Microsoft Development Environment. Microsoft Visual C++ 6.0 is
recommended, though Visual C++ .NET versions will also work. Since PHP 5 the free Microsoft .NET
toolchain is also supported (you need to install Windows Platform SDK, Visual C++ Toolkit and .NET
Framework SDK).
To extract the downloaded files you will also need a ZIP extraction utility. Windows XP and newer already
include this functionality built-in.
Finally, you are going to need the source to PHP itself. You can get the latest development version using
anonymous CVS, a snapshot or the most recent released source tarball.
After downloading the required packages you have to extract them in a proper place:
• Create a working directory where all files end up after extracting, e.g:
C:\work.
• Create the directory win32build under your working directory (C:\work) and unzip win32build.zip
into it.
• Create the directorybindlib_w32 under your working directory (C:\work) and unzip
bindlib_w32.zip into it.
• Extract the downloaded PHP source code into your working directory (C:\work).
• Build the libraries you are going to need (or download the binaries if available) and place the headers and libs in the
C:\work\win32build\include and C:\work\win32build\lib directories, respectively.
• If you don't have cygwin installed with bison and flex, you also need to make the C:\work\win32build\bin
directory available in the PATH, so that thoses tools can be found by the configure script.
+--C:\work
| |
| +--bindlib_w32
| | |
| | +--arpa
| | |
| | +--conf
| | |
| | +--...
| |
| +--php-5.x.x
| | |
| | +--build
| | |
| | +--...
| | |
| | +--win32
| | |
| | +--...
| |
| +--win32build
| | |
| | +--bin
| | |
| | +--include
| | |
| | +--lib
If you aren't using Cygwin, you must also create the directories C:\usr\local\lib and then copy
bison.simple from C:\work\win32build\bin to C:\usr\local\lib.
Note: If you want to use PEAR and the comfortable command line installer, the CLI-SAPI
is mandatory. For more information about PEAR and the installer read the documentation
at the PEAR website.
Build resolv.lib
You must build the resolv.lib library. Decide whether you want to have debug symbols available
(bindlib - Win32 Debug) or not (bindlib - Win32 Release), but please remember the choice you made,
because the debug build will only link with PHP when it is also built in debug mode. Build the appropriate
configuration:
At this point, you should have a usable resolv.lib in either your C:\work\bindlib_w32\Debug or
Release subdirectories. Copy this file into your C:\work\win32build\lib directory over the file by
the same name found in there.
Building PHP using the new build system [PHP >=5 only]
This chapter explains how to compile PHP >=5 using the new build system, which is CLI-based and very
similar with the main PHP's Unix build system.
Note: This build system isn't available in PHP 4. Please refer to the Section called
Building PHP using DSW files [PHP 4] instead.
Before starting, be sure you have read the Section called Putting it all together and you have built all
needed libraries, like Libxml or ICU (needed for PHP >= 6).
First you should open a Visual Studio Command Prompt, which should be available under the Start menu.
A regular Command Prompt window shouldn't work, as probably it doesn't have the necessary
environment variables set. Then type something like cd C:\work\php-5.x.x to enter in the PHP source
dir. Now you are ready to start configuring PHP.
The second step is running the buildconf batch file to make the configure script, by scanning the folder
for config.w32 files. By default this command will also search in the following directories: pecl;
..\pecl; pecl\rpc; ..\pecl\rpc. Since PHP 5.1.0, you can change this behaviour by using the
--add-modules-dir argument (e.g. cscript /nologo win32/build/buildconf.js --add-modules-
dir=../php-gtk2 --add-modules-dir=../pecl).
The third step is configuring. To view the list of the available configuration options type cscript /nologo
configure.js --help. After choosing the options that you will enable/disable, type something like: cscript
/nologo configure.js --disable-foo --enable-fun-ext. Using --enable-foo=shared will attempt to build
the 'foo' extension as a shared, dynamically loadable module.
The last step is compiling. To achieve this just issue the command nmake. The generated files (e.g. .exe
and .dll) will be placed in either Release_TS or Debug_TS directories (if built with Thread safety), or in
the Release or Debug directories otherwise.
Optionally you may also run PHP's test suite, by typing nmake test. If you want to run just a specific
test, you may use the 'TESTS' variable (e.g. nmake /D TESTS=ext/sqlite/tests test - will only run
sqlite's tests). To delete the files that were created during the compilation, you can use the nmake clean
command.
A very useful configure option to build snapshots is --enable-snapshot-build, which add a new compiling
mode (nmake build-snap). This tries to build every extension available (as shared, by default), but it
will ignore build errors in individual extensions or SAPI.
Compiling PHP using the DSW files isn't supported as of PHP 5, as a much more flexible system was made
available. Anyway, you can still use them, but keep in mind that they are not maintained very often, so
you can have compiling problems. To compile PHP 4 for windows, this is the only available way though.
Configure MVC ++
The first step is to configure MVC++ to prepare for compiling. Launch Microsoft Visual C++, and from the
menu select Tools => Options. In the dialog, select the directories tab. Sequentially change the dropdown
to Executables, Includes, and Library files. Your entries should look like this:
Compiling
• For GUI users, launch VC++, and then select File => Open Workspace and select
C:\work\php-
4.x.x\win32\php4ts.dsw. Then select Build=>Set Active Configuration and select the desired
configuration, either php4ts - Win32 Debug_TS or php4ts - Win32 Release_TS. Finally select Build=>Rebuild All.
• For command line users, make sure that you either have the C++ environment variables registered, or have run
vcvars.bat, and then execute one of the following commands from the C:\work\php-4.x.x\win32
directory:
o msdev php4ts.dsp /MAKE "php4ts - Win32 Debug_TS"
o msdev php4ts.dsp /MAKE "php4ts - Win32 Release_TS"
o At this point, you should have a usable php.exe in either your C:\work\php-4.x.x\Debug_TS or
Release_TS subdirectories.
It is possible to do minor customization to the build process by editing the main/config.win32.h file.
For example you can change the default location of php.ini, the built-in extensions, and the default
location for your extensions.
Next you may want to build the CLI version which is designed to use PHP from the command line. The
steps are the same as for building the CGI version, except you have to select the php4ts_cli - Win32
Debug_TS or php4ts_cli - Win32 Release_TS project file. After a successful compiling run you will find the
php.exe in either the directory Release_TS\cli\ or Debug_TS\cli\.
In order to build the SAPI module (php4isapi.dll) for integrating PHP with Microsoft IIS, set your
active configuration to php4isapi-whatever-config and build the desired dll.
Installation of extensions on Windows
After installing PHP and a webserver on Windows, you will probably want to install some extensions for
added functionality. You can choose which extensions you would like to load when PHP starts by modifying
your php.ini. You can also load a module dynamically in your script using dl().
Many extensions are built into the Windows version of PHP. This means additional DLL files, and the
extension directive, are not used to load these extensions. The Windows PHP Extensions table lists
extensions that require, or used to require, additional PHP DLL files. Here's a list of built in extensions:
In PHP 4 (updated PHP 4.3.11): BCMath, Caledar, COM, Ctype, FTP, MySQL, ODBC, Overload, PCRE,
Session, Tokenizer, WDDX, XML and Zlib
In PHP 5 (updated PHP 5.0.4), the following changes exist. Built in: DOM, LibXML, Iconv, SimpleXML, SPL
and SQLite. And the following are no longer built in: MySQL and Overload.
The default location PHP searches for extensions is C:\php4\extensions in PHP 4 and C:\php5 in
PHP 5. To change this setting to reflect your setup of PHP edit your php.ini file:
• You will need to change the extension_dir setting to point to the directory where your extensions lives, or where you
have placed your php_*.dll files. For example:
extension_dir = C:\php\extensions
// ... to
extension=php_bz2.dll
• Some of the extensions need extra DLLs to work. Couple of them can be found in the distribution package, in the
C:\php\dlls\ folder in PHP 4 or in the main folder in PHP 5, but some, for example Oracle
(php_oci8.dll) require DLLs which are not bundled with the distribution package. If you are installing PHP 4,
copy the bundled DLLs from C:\php\dlls folder to the main C:\php folder. Don't forget to include C:\php
in the system PATH (this process is explained in a separate FAQ entry).
• Some of these DLLs are not bundled with the PHP distribution. See each extensions documentation page for details.
Also, read the manual section titled Installation of PECL extensions for details on PECL. An increasingly large number of
PHP extensions are found in PECL, and these extensions require a separate download.
Note: If you are running a server module version of PHP remember to restart your
webserver to reflect your changes to php.ini.
The following table describes some of the extensions available and required additional dlls.
Then You need some kind of pilot-exams, not for big planes, just a little
one.
If You use anonymous access, You'll have a builtin user to use it. Make
this user local administrator, or give minimum read access to PHP folder
(ie.: c:\php) and ORAHOME (ie. c:\ora92) folders.
If You use Windows Integrated authentication, give for Domain Users minimum
read access to PHP folder (ie.: c:\php) and ORAHOME (ie. c:\ora92) folders.
Goog luck.
sopp_ladios at hotmail dot com
19-Aug-2004 09:35
[editor note: this should be fixed in PHP 5.1.0]
I came into this problem when I tried to enable the exif extension under
windows. I knew mbstring is required but I kept getting errors even after I
enabled both.
The problem can only be fixed by moving the mbstring line above the exif
line...