Php | Php | Web Server

June 5, 2016 | Author: Anonymous | Category: PHP
Share Embed


Short Description

the XML extensions on the solid base of libxml2 and extends the feature set adding SimpleXML and XMLReader support. Whil...

Description

http://www.php.net/manual/en/tutorial.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. Simple answer, but what does that mean? An example: Example 1-1. An introductory example

Example 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:

PHP Test Hello World 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 . 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 Word Processors: Word processors such as StarOffice Writer, Microsoft Word and Abiword are not optimal for editing PHP files. If you wish to use one for this test script, you must ensure that you save the file as plain text or PHP will not be able to read and execute the script. A Note on Windows Notepad: If you are writing your PHP scripts using Windows Notepad, you will need to ensure that your files are saved with the .php extension. (Notepad adds a .txt extension to files automatically unless you take one of the following steps to prevent it.) When you save the file and are prompted to provide a name for the file, place the filename in quotes (i.e. "hello.php"). Alternatively, you can click on the 'Text Documents' drop-down menu in the 'Save' dialog box and change the setting to "All Files". You can then enter your filename without quotes. Now that you have successfully created a working PHP script, it is time to create the most famous PHP script! Make a call to the phpinfo() function and you will see a lot of useful information about your system and setup such as available predefined variables, loaded PHP modules, and configuration settings. Take some time and review this important information. Example 2-2. Get system information from PHP



Something Useful Let us do something more useful now. We are going to check what sort of browser the visitor is using. For that, we check the user agent string the browser sends as part of the HTTP request. This information is stored in a variable. Variables always start with a dollar-sign in PHP. The variable we are interested in right now is $_SERVER['HTTP_USER_AGENT']. Note: $_SERVER is a special reserved PHP variable that contains all web server information. It is known as 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.) To display this variable, you can simply do: Example 2-3. Printing a variable (Array element)

A sample output of this script may be:

Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1) There are many types of variables available in PHP. In the above example we printed an Array element. Arrays can be very useful. $_SERVER is just one variable that PHP automatically makes available to you. A list can be seen in the Reserved Variables section of the manual or you can get a complete list of them by looking at the output of the phpinfo() function used in the example in the previous section. You can put multiple PHP statements inside a PHP tag and create little blocks of code that do more than just a single echo. For example, if you want to check for Internet Explorer you can do this: Example 2-4. Example using control structures and functions

A sample output of this script may be:

You are using Internet Explorer. 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: Example 2-5. Mixing both HTML and PHP modes

strpos() must have returned non-false You are using Internet Explorer strpos() must have returned false You are not using Internet Explorer A sample output of this script may be:

strpos() must have returned non-false You are using Internet Explorer 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: Example 2-6. A simple HTML form

Your name: Your age: There is nothing special about this form. It is a straight HTML form with no special tags of any kind. When the user fills in this form and hits the submit button, the action.php page is called. In this file you would write something like this: Example 2-7. Printing data from our form

Hi . You are years old. A sample output of this script may be:

Hi Joe. You are 22 years old. 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:

• • •

Websites and web applications (server-side scripting) Command line scripting Desktop (GUI) applications

For the first and most common form, you need three things: PHP itself, a web server and a web browser. You probably already have a web browser, and depending on your operating system setup, you may also have a web server (e.g. Apache on Linux and MacOS X; IIS on Windows). You may also rent webspace at a company. This way, you don't need to set up anything on your own, only write your PHP scripts, upload it to the server you rent, and see the results in your browser. In case of setting up the server and PHP on your own, you have two choices for the method of connecting PHP to the server. For many servers PHP has a direct module interface (also called SAPI). These servers include Apache, Microsoft Internet Information Server, Netscape and iPlanet servers. Many other servers have support for ISAPI, the Microsoft module interface (OmniHTTPd for example). If PHP has no module support for your web server, you can always use it as a CGI or FastCGI processor. This means you set up your server to use the CGI executable of PHP to process all PHP file requests on the server. If you are also interested to use PHP for command line scripting (e.g. write scripts autogenerating some images for you offline, or processing text files depending on some arguments you pass to them), you always need the command line executable. For more information, read the section about writing command line PHP applications. In this case, you need no server and no browser. With PHP you can also write desktop GUI applications using the PHP-GTK extension. This is a completely different approach than writing web pages, as you do not output any HTML, but manage windows and objects within them. For more information about PHP-GTK, please visit the site dedicated to this extension. PHP-GTK is not included in the official PHP distribution. From now on, this section deals with setting up PHP for web servers on Unix and Windows with server module interfaces and CGI executables. You will also find information on the command line executable in the following sections. PHP source code and binary distributions for Windows can be found at /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. Prerequisite knowledge and software for compiling:

• • • • • •

Basic Unix skills (being able to operate "make" and a C compiler) An ANSI C compiler flex: Version 2.5.4 bison: Version 1.28 (preferred), 1.35, or 1.75 A web server Any module specific components (such as gd, pdf libs, etc.)

The initial PHP setup and configuration process is controlled by the use of the 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.

Apache 1.3.x on Unix systems This section contains notes and hints specific to Apache installs of PHP on Unix platforms. We also have instructions and notes for Apache 2 on a separate page. You can select arguments to add to the configure on line 10 below from the list of core configure options and from extension specific options described at the respective places in the manual. The version numbers have been omitted here, to ensure the instructions are not incorrect. You will need to replace the 'xxx' here with the correct values from your files. Example 4-1. Installation Instructions (Apache Shared Module Version) for PHP

1. 2. 3. 4.

gunzip apache_xxx.tar.gz tar -xvf apache_xxx.tar gunzip php-xxx.tar.gz tar -xvf php-xxx.tar

5. 6. 7. 8. 9.

cd apache_xxx ./configure --prefix=/www --enable-module=so make make install cd ../php-xxx

10. Now, configure your PHP. This is where you customize your PHP with various options, like which extensions will be enabled. Do a ./configure --help for a list of available options. In our example we'll do a simple configure with Apache 1 and MySQL support. Your path to apxs may differ from our example. ./configure --with-mysql --with-apxs=/www/bin/apxs 11. make 12. make install If you decide to change your configure options after installation, you only need to repeat the last three steps. You only need to restart apache for the new module to take effect. A recompile of Apache is not needed. Note that unless told otherwise, 'make install' will also install PEAR, various PHP tools such as phpize, install the PHP CLI, and more. 13. Setup your php.ini file: cp php.ini-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. If you instead choose php.ini-recommended, be certain to read the list of changes within, as they affect how PHP behaves. 14. Edit your httpd.conf to load the PHP module. The path on the right hand side of the LoadModule statement must point to the path of the PHP module on your system. The make install from above may have already added this for you, but be sure to check. For PHP 4: LoadModule php4_module libexec/libphp4.so For PHP 5: LoadModule php5_module libexec/libphp5.so 15. And in the AddModule section of httpd.conf, somewhere under the

ClearModuleList, add this: For PHP 4: AddModule mod_php4.c For PHP 5: AddModule mod_php5.c 16. Tell Apache to parse certain extensions as PHP. For example, let's have Apache parse the .php extension as PHP. You could have any extension(s) parse as PHP by simply adding more, with each separated by a space. We'll add .phtml to demonstrate. AddType application/x-httpd-php .php .phtml It's also common to setup the .phps extension to show highlighted PHP source, this can be done with: AddType application/x-httpd-php-source .phps 17. Use your normal procedure for starting the Apache server. (You must stop and restart the server, not just cause the server to reload by using a HUP or USR1 signal.) Alternatively, to install PHP as a static object: Example 4-2. Installation Instructions (Static Module Installation for Apache) for PHP

1. 2. 3. 4.

gunzip -c apache_1.3.x.tar.gz | tar xf cd apache_1.3.x ./configure cd ..

5. 6. 7. 8. 9.

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

10. cd ../apache_1.3.x 11. ./configure --prefix=/www --activate-module=src/modules/php5/libphp5.a (The above line is correct! Yes, we know libphp5.a does not exist at this stage. It isn't supposed to. It will be created.) 12. make (you should now have an httpd binary which you can copy to your Apache bin dir if

it is your first install then you need to "make install" as well) 13. cd ../php-5.x.y 14. cp php.ini-dist /usr/local/lib/php.ini 15. You can edit /usr/local/lib/php.ini file to set PHP options. Edit your httpd.conf or srm.conf file and add: AddType application/x-httpd-php .php Note: Replace php-5 by php-4 and php5 by php4 in PHP 4. Depending on your Apache install and Unix variant, there are many possible ways to stop and restart the server. Below are some typical lines used in restarting the server, for different apache/unix installations. You should replace /path/to/ with the path to these applications on your systems. Example 4-3. Example commands for restarting Apache

1. Several Linux and SysV variants: /etc/rc.d/init.d/httpd restart 2. Using apachectl scripts: /path/to/apachectl stop /path/to/apachectl start 3. httpdctl and httpsdctl (Using OpenSSL), similar to apachectl: /path/to/httpsdctl stop /path/to/httpsdctl start 4. Using mod_ssl, or another SSL server, you may want to manually stop and start: /path/to/apachectl stop /path/to/apachectl startssl The locations of the apachectl and http(s)dctl binaries often vary. If your system has locate or whereis or which commands, these can assist you in finding your server control programs. Different examples of compiling PHP for apache are as follows:

./configure --with-apxs --with-pgsql This will create a libphp5.so (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.

./configure --with-apxs --with-pgsql=shared 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.

./configure --with-apache=/path/to/apache_source --with-pgsql

This will create a libmodphp5.a library, a mod_php5.c and some accompanying files and copy this into the src/modules/php5 directory in the Apache source tree. Then you compile Apache using --activatemodule=src/modules/php5/libphp5.a and the Apache build system will create libphp5.a and link it statically into the httpd binary (replace php5 by php4 in PHP 4). The PostgreSQL support is included directly into this httpd binary, so the final result here is a single httpd binary that includes all of Apache and all of PHP.

./configure --with-apache=/path/to/apache_source --with-pgsql=shared Same as before, except instead of including PostgreSQL support directly into the final httpd you will get a pgsql.so shared library that you can load into PHP from either the php.ini file or directly using dl(). When choosing to build PHP in different ways, you should consider the advantages and drawbacks of each method. Building as a shared object will mean that you can compile apache separately, and don't have to recompile everything as you add to, or change, PHP. Building PHP into apache (static method) means that PHP will load and run faster. For more information, see the Apache 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 --withapxs=/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.

add a note User Contributed Notes

Installation on Unix systems flconseil at yahoo dot fr 07-Mar-2006 06:15

Building Apache 2 and PHP 5.1.2 : On AIX 5.2 : http://flaupretre.free.fr/redir.php?key=build_apa_aix On HP-UX 11i (11.11) : http://flaupretre.free.fr/redir.php? key=build_apa_hpux 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, PROBLEM:

./configure PHP --with-oci8

fails with unresolved references such as __rpc_thread_destroy@GLIBC_2_2_3_... ONE SOLUTOIN FOR SOLVING PHP ./configure RESULTING IN __rcp_thread_destroy@GLIBC_2_2_3_... AND UNRESOLVED REFERENCES WITH ORACLE OCI8 KEYWORDS: PHP OCI OCI8 NET8 ./configure __rpc_thred_destroy UNRESOLVED

REFERENCES 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. have an actual Oracle Installation.

This assumes you

1. Set ORACLE_HOME Example using Oracle 9i Relase 2 -- 9.2.0.5: ORACLE_HOME=/opt/app/oracle/product/9iR2 2. Set LD_LIBRARY_PATH with: LD_LIBRARY_PATH=$ORACLE_HOME/lib: \ $ORACLE_HOME/rdbms/lib:\ $LD_LIBRARY_PATH 3. On Unix / Linux, don't forget to export these environment variables: export ORACLE_HOME LD_LIBRARY_PATH 4. Now, build PHP with the following: ./configure --with-apxs2= --withoci8=$ORACLE_HOME --enable-sigchild 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. Hope this helps. phptard at gmail dot com 23-Mar-2005 04:17

after a long night of wrestling with mysql4.0 under linux compiled with the intel compiler, i've gotten php5.0.3 to compile with mysql libraries for this flavor of mysql: 1: download the mysql for linux/intel compiler and install 2: download the rpm for the intel compiler libraries and install 3: configure php with LDFLAGS="-lirc -lgcc_s" and EXTRA_LIBS="-lirc -lgcc_s" Example: LDFLAGS="-lirc -lgcc_s" LD_LIBRARY_PATH="-L/usr/lib64" LD_PATH="L/usr/lib64" LDPATH="-L/usr/lib64" EXTRA_LIBS="-lirc -lgcc_s" ./configure --with-apxs2=/usr/local/apache/bin/apxs --with-ssl=/usr/local/ssl --withoutsqlite --with-zlib-dir=/usr --with-mysql=/usr/local/mysql 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: LDFLAGS="-lirc -lgcc_s" EXTRA_LIBS="-lirc -lgcc_s" ./configure --withapxs2=/usr/local/apache/bin/apxs --with-mysql=/usr/local/mysql 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 --withapache samael99 at web dot de 24-Jun-2004 06:51

Quick hint for people using RH8: if make gives you this error FT_ENCODING_MS_SYMBOL undeclared change on line in this file /usr/include/freetype2/freetype/freetype.h Search for ft_encoding_symbol - change it to ft_encoding_ms_symbol Now this problem is dealt with, go ahead with make. 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 [root@graf-spee local]# pkg-config --libs openssl -L/usr/kerberos/lib -lssl -lcrypto -lresolv -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err -ldl -lz These could be added to your make command thus. I have not tested it out, but should work with some tweaking make EXTRA_LDFLAGS=`pkg-config --libs openssl` EXTRA_CFLAGS=`pkg-config --cflags openssl` thansen at terra dot com dot br 30-Dec-2003 08:36

The configure directives --with-apxs2 and --with-apxs2filter are not compatible one with other, even though the configure script will not complain about that. Each one affect the way Apache will call the php parser: If you choose the first one, you must use the traditional include: AddType application/x-httpd-php php at httpd.conf, to call the parser. If you use the --with-apxs2filter, the include will be: SetOutputFilter PHP SetInputFilter PHP , and php will be called as a filter to .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=) 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:

• •

PHP 4.3.0 or later available at /downloads.php.

• •

a prerelease version downloadable from http://qa.php.net/.

the latest stable development version. Get the source code http://snaps.php.net/php5latest.tar.gz or download binaries for Windows http://snaps.php.net/win32/php5-win32-latest.zip. you have always the option to obtain PHP through anonymous CVS.

These versions of PHP are compatible to Apache 2.0.40 and later. 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. Example 4-4. Installation Instructions (Apache 2 Shared Module Version)

1. 2. 3. 4. 5. 6. 7. 8.

gzip -d httpd-2_0_NN.tar.gz tar xvf httpd-2_0_NN.tar gunzip php-NN.tar.gz tar -xvf php-NN.tar cd httpd-2_0_NN ./configure --enable-so make make install Now you have Apache 2.0.NN available under /usr/local/apache2, configured with loadable module support and the standard MPM prefork. To test the installation use your normal procedure for starting the Apache server, e.g.: /usr/local/apache2/bin/apachectl start and stop the server to go on with the configuration for PHP: /usr/local/apache2/bin/apachectl stop.

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. ./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql 11. make 12. make install If you decide to change your configure options after installation, you only need to repeat the last three steps. You only need to restart apache for the new module to take effect. A recompile of Apache is not needed. Note that unless told otherwise, 'make install' will also install PEAR, various PHP tools such as phpize, install the PHP CLI, and more. 13. Setup your php.ini 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. If you instead choose php.ini-recommended, be certain to read the list of changes within, as they affect how PHP behaves. 14. Edit your httpd.conf to load the PHP module. The path on the right hand side of the LoadModule statement must point to the path of the PHP module on your system. The make install from above may have already added this for you, but be sure to check. For PHP 4: LoadModule php4_module modules/libphp4.so For PHP 5: LoadModule php5_module modules/libphp5.so 15. Tell Apache to parse certain extensions as PHP. For example, let's have Apache parse the .php extension as PHP. You could have any extension(s) parse as PHP by simply adding more, with each separated by a space. We'll add .phtml to demonstrate. AddType application/x-httpd-php .php .phtml

It's also common to setup the .phps extension to show highlighted PHP source, this can be done with: AddType application/x-httpd-php-source .phps 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 --withmpm=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.

add a note User Contributed Notes

Apache 2.0 on Unix systems jaya 05-Jul-2006 11:41

PHP 5.1.4 INSTALLATION on Solaris 9 (Sparc) Solaris9 Packages Installed: Verify required package installation: root# pkginfo SUNWbtool SUNWsprot SUNWtoo SUNWhea SUNWarc \ SUNWlibm SUNWlibms SUNWdfbh SUNWxglh SUNWcg6h Uninstall Default Apache Packages: root# /etc/init.d/apache stop root# pkginfo |grep Apache root# pkgrm SUNWaclg SUNWapchd SUNWapchr SUNWapchu Create installation Directory: root# mkdir /phpdata/ Download Required Packages from Sunfreeware: Install libiconv-1.8 and gcc3.3.2 packages root# pkgadd -d ./libiconv-1.8-sol9-sparc-local root# pkgadd -d ./gcc-3.3.2-sol9-sparc-local set LD_LIBRARY_PATH, CC and PATH variables root# LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib/sparcv9/:\ /usr/lib:/usr/openwin/lib:/opt/local/lib:/usr/local/ssl/lib:\ /usr/local/apr/lib:/opt/mysql/mysql/lib root# CC=gcc root# PATH=$PATH:/usr/ucb:/usr/local/bin/ root# export LD_LIBRARY_PATH CC PATH Install apr-1.2.2 and aprutil-1.2.2 packages root# gzcat apr-1.2.2.tar.gz |tar xvf root# cd apr-1.2.2

root# root# root# root#

./configure make make install cd ..

root# root# root# root# root#

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

Install gawk-3.1.4, expat-1.95.5, db-4.2.52.NC, gdbm-1.8.3, libgcc-3.3 and libxml2-2.6.16 packages root# cd .. root# pkgadd -d ./gawk-3.1.4-sol9-sparc-local root# pkgadd -d ./expat-1.95.5-sol9-sparc-local root# pkgadd -d ./db-4.2.52.NC-sol9-sparc-local root# pkgadd -d ./gdbm-1.8.3-sol9-sparc-local root# pkgadd -d ./libgcc-3.3-sol9-sparc-local root# pkgadd -d ./libxml2-2.6.16-sol9-sparc-local Install GNU make package root# gzcat make-3.81.tar.gz |tar xvf root# cd make-3.81 root# ./configure root# make root# make install root# cd .. Install mysql-standard-5.0.22 package Search for user mysql root# grep mysql /etc/passwd root# grep mysql /etc/group If not found create user and group mysql root# groupadd mysql root# useradd -G mysql mysql root# pkgadd -d ./mysql-standard-5.0.22-solaris9-sparc.pkg.gz Install openssl-0.9.7g package root# gzcat openssl-0.9.7g.tar.gz |tar xvf root# cd openssl-0.9.7g root# ./config shared root# make root# make install root# cd .. Install Apache2 package root# gzcat httpd-2.2.0.tar.gz |tar xvf root# cd httpd-2.2.0 root# ./configure --enable-so root# /usr/local/bin/make root# /usr/local/bin/make install root# cd .. Install php-5.1.4 package root# gzcat php-5.1.4.tar.gz |tar xvf root# cd php-5.1.4 root# ./configure --with-apxs2=/usr/local/apache2/bin/apxs\ --with-ldap --with-mysql=/opt/mysql/mysql/ root# /usr/local/bin/make root# /usr/local/bin/make install root# cp php.ini-dist /usr/local/lib/php.ini Edit httpd.conf to load the PHP module and to parse certain extensions as PHP root# vi /usr/local/apache2/conf/httpd.conf LoadModule php5_module modules/libphp5.so AddType application/x-httpd-php .php .phtml

Start Apache root# /usr/local/apache2/bin/apachectl start Add environmental variables below HTTPD root# vi /usr/local/apache2/bin/apachectl LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib/sparcv9/: /usr/lib:/usr/openwin/lib:/opt/local/lib:/usr/local/ssl/lib: /usr/local/apr/lib:/opt/mysql/mysql/lib PATH=/bin:/sbin:/usr/ccs/bin:/usr/sbin:/usr/openwin/bin:\ /usr/ucb:/usr/local/bin/ export LD_LIBRARY_PATH PATH Create Apache Startup Script pillepop2003 at yahoo dot de 19-Apr-2006 09:18

For unix (especially opensuse 10.0) you can find bison and flex here: 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 phprelated 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: apt-get install libxml2 libxml2-dev PHP should then compile fine. frank@ethisoft 28-Sep-2005 02:30

Using Apache2 & PHP5 work perfectly fine & safe together. - all core modules are safe in Zend Engine 2 - third-party-libraries should be avoided - semaphores and shared memory enables you to ensure yourself that your application/website is thread-safe also with non-thread-safe PHP modules! happyboy at php dot org 03-Aug-2005 04:30

FILE TRUNCATED!! during the make process should u receive an error declaring ext/ctype/ctype.lo (or another file) is truncated then you need to 'make clean' prior to a healthy 'make' and 'make install.' looking into your ext/ directory you may find the offensive file to be 1 byte long. 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 --withzlib 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 --withapxs2=/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: ./configure --with-mysql=/path/to/mysql_config --withmysqli=/path/to/mysql_config do this: " if you want to use both the old mysql and the new mysqli interface, load the Makefile into your editor and search for the line beginning with EXTRA_LIBS; it includes -lmysqlclient twice; remove the second instance " then you can: make make install ..... Pleasse note: you must have mysql-dev installed (RPM or source) or you will not have the mysql_config file at all. The standard, server, and client installations of MySQL do not include it. I read somewhere that the mysql and mysqli paths must be identical. Quoted from Michael Kofler at the following link: http://www.kofler.cc/forum/forumthread.php?rootID=3571 jmartinNO at SPAMcolumbiaservices dot net 24-Jan-2005 03:44

Well I was getting the following error when trying to run make (shared module for Apache 2.0.52) *** Warning: inter-library dependencies are not known to be supported. *** All declared inter-library dependencies are being dropped. (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 cat /some/dir/file1 >> localfile Would produce the desired results when you run: 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 SuSE uses a rather fragmented set of Apache configuration files stored in /etc/apache2/. When you configure PHP 5.x with: $ ./configure --with-apxs2=/usr/sbin/apxs2 $ make everything builds just fine; but when you issue: $ su -c "make install" the unconventional Apache conf file layout confuses the install-sapi section of the Makefile and the process halts with the following error: apxs:Error: Config file /etc/apache2/httpd2-prefork.conf not found. make: *** [install-sapi] Error 1 At this point only the PHP SAPI library has been copied into place; the rest of the files (like PEAR scripts, PHP-CLI, etc) have not been installed. But never fear! You can overcome this problem with the following steps: 1. Edit Makefile and change the following line to remove "install-sapi": install_targets = install-sapi install-cli install-pear install-build install-headers install-programs 2. Issue the make install command again: $ su -c "make install" 3. Add the PHP module & type instructions to the Apache configuration. As root, create a new file, /etc/apache2/conf.d/php5.conf that contains the following lines: LoadModule php5_module /usr/lib/apache2/libphp5.so AddType application/x-httpd-php php --- And that's it. Everything else is just as the documentation suggests it should be. 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 "multiviews Options Indexes FollowSymLinks MultiViews"

the directives u can set it to root directory so now when u type pn test it will search in precendence for test.php, test.html if any ..... its working for me with apache2.0.47 and php 4.3.9 on solaris praveen 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. Example 4-5. Caudium Installation Instructions

1.

Make sure you have Caudium installed prior to attempting to install PHP 4. For PHP 4 to work correctly, you will need Pike 7.0.268 or newer. For the sake of this example we assume that Caudium is installed in /opt/caudium/server/. 2. Change directory to php-x.y.z (where x.y.z is the version number). 3. ./configure --with-caudium=/opt/caudium/server 4. make 5. make install 6. Restart Caudium if it's currently running. 7. Log into the graphical configuration interface and go to the virtual server where you want to add PHP 4 support. 8. Click Add Module and locate and then add the PHP 4 Script Support module. 9. If the documentation says that the 'PHP 4 interpreter isn't available', make sure that you restarted the server. If you did check /opt/caudium/logs/debug/default.1 for any errors related to PHP4.so. Also make sure that caudium/server/lib/[pike-version]/PHP4.so is present. 10. Configure the PHP Script Support module if needed. 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. Note: Support for fhttpd is no longer available as of PHP 4.3.0.

Sun, iPlanet and Netscape servers on Sun Solaris This section contains notes and hints specific to Sun Java System Web Server, Sun ONE Web Server, iPlanet and Netscape server installs of PHP on Sun Solaris. From PHP 4.3.3 on you can use PHP scripts with the NSAPI module to generate custom directory listings and error pages. Additional functions for Apache compatibility are also available. For support in current 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.

1.

Install the following packages from http://www.sunfreeware.com/ or another download site:

autoconf-2.13 automake-1.4 bison-1_25-sol26-sparc-local flex-2_5_4a-sol26-sparc-local gcc-2_95_2-sol26-sparc-local gzip-1.2.4-sol26-sparc-local m4-1_4-sol26-sparc-local make-3_76_1-sol26-sparc-local mysql-3.23.24-beta (if you want mysql support) perl-5_005_03-sol26-sparc-local tar-1.13 (GNU tar)

2.

Make sure your path includes the proper directories PATH=.:/usr/local/bin:/usr/sbin:/usr/bin:/usr/ccs/bin and make it available to your system export PATH.

3. gunzip php-x.x.x.tar.gz (if you have a .gz dist, otherwise go to 4). 4. tar xvf php-x.x.x.tar 5. Change to your extracted PHP directory: cd ../php-x.x.x 6. For the following step, make sure /opt/netscape/suitespot/ is where your netscape server is installed. Otherwise, change to the correct path and run:

./configure --with-mysql=/usr/local/mysql \ --with-nsapi=/opt/netscape/suitespot/ \ --enable-libgcc

7.

Run make followed by make install.

After performing the base install and reading the appropriate readme file, you may need to perform some additional configuration steps. Configuration Instructions for Sun/iPlanet/Netscape. Firstly you may need to add some paths to the LD_LIBRARY_PATH environment for the server to find all the shared libs. This can best done in the start script for your webserver. The start script is often located in: /path/to/server/httpsservername/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.

Init fn="load-modules" funcs="php4_init,php4_execute,php4_auth_trans" shlib="/opt/netscape/suitespot/bin/libphp4.so" Init fn="php4_init" LateInit="yes" errorString="Failed to initialize PHP!" [php_ini="/path/to/php.ini"]

3. 4.

(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 [version 6.0+] in their vserver.obj.conf):

. . . .#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 ...] . .

5.

6.

(PHP >= 4.3.3) As additional parameters you can add some special php.ini-values, for example you can set a docroot="/path/to/docroot" specific to the context php4_execute is called. For boolean ini-keys please use 0/1 as value, not "On","Off",... (this will not work correctly), e.g. zlib.output_compression=1 instead of zlib.output_compression="On" This is only needed if you want to configure a directory that only consists of PHP scripts (same like a cgi-bin directory):

ObjectType fn="force-type" type="magnus-internal/x-httpd-php" Service fn=php4_execute [inikey=value inikey=value ...]

7. 8.

After that you can configure a directory in the Administration server and assign it the style xhttpd-php. All files in it will get executed as PHP. This is nice to hide PHP usage by renaming files to .html. 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:

AuthTrans fn=php4_auth_trans . . . 9.

To use PHP Authentication on a single directory, add the following:

AuthTrans fn=php4_auth_trans 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").

CGI environment and recommended modifications in php.ini Important when writing PHP scripts is the fact that Sun JSWS/Sun ONE WS/iPlanet/Netscape is a multithreaded web server. Because of that all requests are running in the same process space (the space of the 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! Note: Why are there (invalid) CGI variables in the environment? 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:

Error fn="php4_execute" code=XXX script="/path/to/script.php" [inikey=value inikey=value...] where XXX is the HTTP error code. Please delete any other Error directives which could interfere with yours. If you want to place a page for all errors that could exist, leave the code parameter out. Your script can get the HTTP status code with $_SERVER['ERROR_TYPE']. Another possibility is to generate self-made directory listings. Just create a PHP script which displays a directory listing and replace the corresponding default Service line for type="magnus-internal/directory" in obj.conf with the following:

Service fn="php4_execute" type="magnus-internal/directory" script="/path/to/script.php" [inikey=value inikey=value...] For both error and directory listing pages the original URI and translated URI are in the variables $_SERVER['PATH_INFO'] and $_SERVER['PATH_TRANSLATED'].

Note about nsapi_virtual() and subrequests (PHP >= 4.3.3)

The NSAPI module now supports the nsapi_virtual() function (alias: virtual()) to make subrequests on the webserver and insert the result in the webpage. This function uses some undocumented features from the NSAPI library. On Unix the module automatically looks for the needed functions and uses them if available. If not, nsapi_virtual() is disabled. Note: But be warned: Support for nsapi_virtual() is EXPERIMENTAL!!!

add a note User Contributed Notes

Sun, iPlanet and Netscape servers on Sun Solaris ericbackstrom at hotmail dot com 27-Mar-2006 03:09

Using gcc 3.3 I had problems compiling PHP for 64 bits, I had to replace mysql/64 bits with mysql/32 bits (Solaris cannot mix 32 bits and 64 bits libraries), so I specified the following compiler flag: CFLAGS="-m32";export CFLAGS; I also had problems with PHP 5.1.2 in sapi/nsapi/nsapi.c source code, It had incorrect comments and file paths :S When trying to install PHP with mysql support I found I had these problems too: http://bugs.php.net/bug.php?id=34516... So don't mix sun ld and gcc ld because you will get into troubles. I built mysql libraries myself in a separated directory. And don't forget to set your LD_LIBRARY_PATH to something like: LD_LIBRARY_PATH="/usr/local/lib:/usr/lib" vijay 13-Mar-2006 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.... [12/Mar/2006:11:01:48] failure (15936): Failed to read kernel statistics structures (No such device or address) This happens only if I start my server loading PHP module. FYI - When I configured my php I had it use oracle instant client libraries. One fix I found was to comment out this line in my magnus.conf file. #Init fn="stats-init" profiling="on" But I don't think i can do this on my prodcution machine. Any ideas to come around this issue? Thanks Vijay jedokahn at yahoo dot com at 23-Nov-2004 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 1. Download http://us3.php.net/get/php-5.0.1.tar.bz2/from/a/mirror and extract into the directory of your choice. (5.0.1 was the only version I could get to make install correctly) 2. CD into the extracted PHP directory and type: > ./configure --with-nsapi=/opt/SUNWwbsvr --enable-libgcc --disable-libxml (Your web server directory may vary from the above's default.) 3. Once it's done configuring (and it should be successful should you have all the proper packages), type: > make 4. When its done compiling, it's time to install as root: # make install 5. Now, configuration of your web server begins: # cd /opt/SUNWwbsvr/https-[yourWebServer]/config 6. vi mime.types (or other editor) to add this line into it: type=magnus-internal/x-httpd-php exts=php 7. vi magnus.conf to add the following 2 lines to end of it: (NOTE: the 2nd line could be optional) Init fn="load-modules" funcs="php5_init,php5_execute,php5_auth_trans" shlib="/opt/SUNWwbsvr/bin/libphp5.so" Init fn="php5_init" LateInit="yes" errorString="Failed to initialize PHP!" [php_ini="/path/to/php.ini"] 8. vi obj.conf to add the following line to . Make sure this happens after all "ObjectType" entries and before any "AddLog" entries: (NOTE: for virtual servers, edit vserver.obj.conf) Service fn="php5_execute" type="magnus-internal/x-httpd-php" [inikey=value inikey=value ...] 9. Now, start up your web server. Also, make sure to log into the admin server and click the "Apply" button in there. You will also have set "index.php" as an index filename in your virtual server's Document Preferences. 10. Congrats! Now, you have PHP installed! Of course, there are other features you could enable (MySQL, XML, etc.), but I haven't tested against those. Just consult the following page for hints: http://www.php.net/manual/en/install.unix.sun.php mark at markround dot com 19-Aug-2004 09:36

Quick note : By replacing "php4" with "php5", the above instructions work perfectly when building PHP5 for an iPlanet server. EG:Init fn="load-modules" funcs="php5_init,php5_execute,php5_auth_trans" etc. Works fine here on 6.0SP2, Solaris 9 Sparc. -Mark [mark at markround dot com]

CGI and 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. Note: make bench is only available for PHP 3.

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'.

add a note User Contributed Notes

CGI and commandline setups info at ch2o dot info 17-Jun-2005 07:59

additionnal information to fastcgi... the compilation of fastcgi library is not nessesary, php include a modified version of this library, and fastcgi module have this own implementation of the protocole fastcgi... on the first server (where apache are!) the uid and gid of apache instance of the fastcgi module must be the same on the php file to execute... without that they dont work... the module refuse to send the request to the fastcgi php server... info at ch2o dot info 13-Jun-2005 10:59

for using fastcgi external server in place of cgi or mod php with php: to compile fastcgi librairie:

wget http://www.fastcgi.com/dist/fcgi-2.4.0.tar.gz tar xzvf fcgi-2.4.0.tar.gz cd fcgi-2.4.0 ./configure make gmake install to compile the fastcgi apache module: wget http://www.fastcgi.com/dist/mod_fastcgi-2.4.2.tar.gz tar xvzf mod_fastcgi-2.4.2.tar.gz cd mod_fastcgi-2.4.2 path/to/apache/bin/apxs -i -A -n fastcgi -o mod_fastcgi.la -c *.c after you must modify the http.conf to add that: # load fcgi module LoadModule fastcgi_module

modules/mod_fastcgi.so

# authorization to execute fcgi Options ExecCGI SetHandler fastcgi-script

on tree "/fcgi-bin/"

# define fastcgi external serveur for virtual path "/fcgi-bin/phpfcgi" to execute on targetmachinehost with targetport FastCgiExternalServer /fcgi-bin/phpfcgi -host targetmachinehostname:targetport # mime type definietion for some extention AddType application/x-httpd-fastphp .php .cphp .php4 #define apache cgi regirection with the virtual action script /fcgibin/phpfcgi associated with the defined mime type. Action application/x-httpd-fastphp /fcgi-bin/phpfcgi start apache. compile php with --enable-cgi

and --enable-fastcgi=/to/lib/fastcgi

start on target machine php with "php -b ip:port" for ear request from mod_fastcgi. some aditional thing are in sapi/cgi/README.FastCGI of php src tree. the document root of the apache machine must be synchronous with the php target machine... with the same tree... and with that solution you can mixe php5 and php4 with different extention of apache directory limitation to one or another version... with performance like mod_php! kptrs at yahoo dot com 06-Jun-2004 04:37

Dug out from the discussion at the site below is a good tip: if you are working with an existing PHP installation which did not build either the commandline or CGI servers, you can use the lynx non-graphical web browser to get the web server to execute php scripts from the command line (or cron jobs, etc): lynx -dump http://whatever >If you wish to use PHP as a scripting language, a good article to read is >http://www.phpbuilder.com/columns/darrell20000319.php3

>note that the article is aimed at *nix not win32, but most of it still applies phil at philkern dot de 03-Jan-2003 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 mount -t binfmt_misc none /proc/sys/fs/binfmt_misc echo ":PHP:E::php::/usr/bin/php4:" > /proc/sys/fs/binfmt_misc/register --And please remember that the package management would override the file on the next distribution upgrade :) cv at corbach dot de 20-Feb-2002 08:18

Up to and including 4.1.1 you have to set doc_root to an non empty value if you configure PHP for CGI usage with --enable-discard-path.

HP-UX specific installation notes This section contains notes and hints specific to installing PHP on HP-UX systems. (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.

1.

You need gzip, download a binary distribution from

http://hpux.connect.org.uk/ftp/hpux/Gnu/gzip-1.2.4a/gzip-1.2.4a-sd10.20.depot.Z uncompress the file and install using swinstall.

2.

You need gcc, download a binary distribution from

http://gatekeep.cs.utah.edu/ftp/hpux/Gnu/gcc-2.95.2/gcc-2.95.2-sd10.20.depot.gz. uncompress this file and install gcc using swinstall.

3.

You need the GNU binutils, you can download a binary distribution from

http://hpux.connect.org.uk/ftp/hpux/Gnu/binutils-2.9.1/binutils-2.9.1sd-10.20.depot.gz. uncompress this file and install binutils using swinstall.

4.

You now need bison, you can download a binary distribution from

http://hpux.connect.org.uk/ftp/hpux/Gnu/bison-1.28/bison-1.28-sd10.20.depot.gz, install as above.

5.

You now need flex, you need to download the source from one of the http://www.gnu.org mirrors. It is in the non-gnu directory of the ftp site. Download the file, gunzip, then tar -xvf it. Go into the newly created flex directory and run ./configure, followed by make, and then make install. If you have errors here, it's probably because gcc etc. are not in your PATH so add them to your PATH.

6.

7. 8. 9.

Download the PHP and apache sources. gunzip and tar -xvf them. We need to hack a couple of files so that they can compile OK. Firstly the configure file needs to be hacked because it seems to lose track of the fact that you are a hpux machine, there will be a better way of doing this but a cheap and cheerful hack is to put lt_target=hpux10.20 on line 47286 of the configure script.

Next, the Apache GuessOS file needs to be hacked. Under apache_1.3.9/src/helpers change line 89 from echo "hp${HPUXMACH}-hpux${HPUXVER}"; exit 0 to: echo "hp$ {HPUXMACH}-hp-hpux${HPUXVER}"; exit 0 10. You cannot install PHP as a shared object under HP-UX so you must compile it as a static, just follow the instructions at the Apache page.

11.

PHP and Apache should have compiled OK, but Apache won't start. you need to create a new user for Apache, e.g. www, or apache. You then change lines 252 and 253 of the conf/httpd.conf in Apache so that instead of

User nobody Group nogroup 12. you have something like

User www Group sys 13. This is because you can't run Apache as nobody under hp-ux. Apache and PHP should then work.

add a note User Contributed Notes

HP-UX specific installation notes Vinayak 23-Mar-2006 04:14

Installing PHP 5.x with Apache 2.x on HP UX 11i and configuring PHP 5.x with Oracle 9i

I am very glad to share this information to configure PHP 5.x work with Apache 2.x and Oracle 9i on HP UX 11i. Step 1: Install Apache 2.x with DSO support: -------------------------------------------This is a stratight forward Apache installation with --enable-so option gzip -d httpd-2_0_NN.tar.gz tar xvf httpd-2_0_NN.tar cd httpd-2_0_NN ./configure \ --prefix=/var/apps/apache2 \ --enable-so \ --enable-mods-shared=most \ --libexecdir=/var/apps/apache2/libexec You can add other options as required. make make install Step 2: Install and configure PHP 5.x with Oracle 9i ---------------------------------------------------Edit the ./configure file to change "$OCI8_DIR/lib" as "$OCI8_DIR/lib32" By default, with Oracle 9i, "$OCI8_DIR/lib" will be poiting to Oracle 64 bit libraries in "$OCI8_DIR/lib64" directory. Unfortunately, PHP 5.x does not work with 64 bit oracle shared libraries. Run configure.. $ ./configure \ --prefix=/var/apps/php \ --with-apxs2=/var/apps/apache2/bin/apxs \ --with-oci8=/oracle/app/product/9.0.2 \ --disable-libxml \ --enable-libgcc \ --enable-ftp \ --enable-calendar \ --enable-track-vars \ --enable-trans-sid \ --enable-sigchild \ --libexecdir=/var/apps/apache2/libexec \ --with-config-file-path=/var/apps/apache2/conf --enable-libgcc \ --enable-sigchild \ You can add other options as required. You can use the --help option to configure to get a complete list. After configure runs, you must edit the file libtool. $ vi ./libtool At line 184, you should change the line from: deplibs_check_method="unknown" to deplibs_check_method="pass_all" so that PHP and mod_php are properly compiled. 3. Compile and install the files.

Run make. This should complete normally. $ make Run make install. This will fail when it attempts to call apxs. $ make install Step 3: Configure Apache 2.x ---------------------------Edit httpd.conf file to include For PHP 5: LoadModule php5_module modules/libphp5.so AddType application/x-httpd-php .php .phtml

Set environment variables in $APACHE_ROOT/bin/envvars file SHLIB_PATH="/var/apps/apache2/lib:$SHLIB_PATH" export SHLIB_PATH LD_LIBRARY_PATH=$ORACLE_HOME/app/product/9.0.2 /lib32 export LD_LIBRARY_PATH LD_PRELOAD=/usr/lib/libpthread.sl:$ORACLE_HOME/app/ product/9.0.2/JRE/lib/PA_RISC/native_threads/libjava.sl export LD_PRELOAD After lot of hard work, by following the above procedure, we were able to make PHP 5.x is work with Apache 2.x and Oracle 9i on HP UX 11i OS. Hope this will save your time!! flconseil at yahoo dot fr 23-Jan-2006 06:47

If hpws is not an option for you, or if you want to build Apache and PHP with your own options and extensions, I have written a step by step tutorial. It explains how to build Apache 2.0 and PHP 5 from scratch on HP-UX 11i (11.11), including most modules and extensions (zlib, SSL, LDAP, iconv, expat, xml, xslt, gd, png, Xpm, jpeg, freetype, bzip2, curl, MySQL, PostgreSQL, Oracle, AdoDB) : http://flaupretre.free.fr/redir.php?key=build_apa_php Marcus dot Reimann at reimann-systemberatung dot de 29-Aug-2003 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 HPWebserver with an old PHP-Version) and unpack the tar-file in a workingdirectory. Use the following parameters for configure PHP: ./configure --with-apxs2=/opt/hpws/apache/bin/apxs --prefix=/opt/hpws/apache/php [and so on...] If configure prints the error "expr: An integer value was expected.", than you have to edit the Script "configure". Replace the line: APACHE_VERSION=`expr $4 \* 1000000 + $5 \* 1000 + $6`

with the following (correct and very long) line: APACHE_VERSION=`$APXS_HTTPD -v | head -1 | cut -f3 -d' ' | cut -f2 -d'/' | awk 'BEGIN { FS = "."; } { printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'` Why? The output of "httpd -v" prints the following string: Server version: HP-UX_Apache-based_Web_Server/2.0.46 Server built: Jun 26 2003 04:41:28 But the configure-Script can't deal with this string. jason dot sheets at hp dot com 27-Feb-2003 02:45

In order to use PHP 4.3.0 on HP-UX 11 I've found I must compile it statically with Apache, it does not build as a module. jsheets at shadotech dot com 30-Sep-2002 11:42

To clarify the my $dso_ext = "so"; comment, you can find my $dso_ext = "so"; in your apxs script you need to change that line to my $dso_ext = "sl"; otherwise make install will fail. nikrou at ifrance dot com 08-Aug-2002 04:32

On HP-UX 11.00, there's a problem to compiling PHP as a DSO module. The script apxs is looking fot libphp4.so instead of libphp4.sl. Change the line in the script (search "extension"). Write : my $dso_ext = "sl"; instead of : my $dso_ext = "so"; // old line Nicolas ichoudhury007 at yahoo dot com 30-May-2002 09:11

On HP-UX 11 ... When you are compiling PHP as DSO, you will encounter an error during "make install" /usr/local/apache/bin/apxs -i -a -n php4 libs/libphp4.sl apxs:Error: file libs/libphp4.sl is not a DSO *** Error exit code 1 ---- This is because installation is looking for libphp4.so instead of sl. You can rename or link as libphp4.so and run james at nospam dot hp dot com 28-Jan-2002 07:46

To build for HP-UX 10.X/11.X (and some other UNIX variants) with '--enablesockets', you'll get an error about 'u_int' being redefined in /usr/include/netinet/in.h and ext/sockets/sockets.c will fail to compile. The problem is this line from main/php_config.h: #define in_addr_t u_int The above define is a problem because HP-UX (and some other UNIXs) typedef in_addr_t. A good workaround is to replace this define in main/php_config.h with the lines from the HP-UX 11.X netinet/in.h header file (which will work for 10.X as well): #ifndef _IN_ADDR_T #define _IN_ADDR_T #ifdef __LP64__ typedef unsigned int in_addr_t; #else typedef unsigned long in_addr_t; #endif #endif spam at adhocinc dot com 11-Oct-2001 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 " to the php.h file. Compilation was

successful after that was added, with no other issues. apache 1.3.20, bison 1.28, flex 2.5.4.a.

Used gcc 2.95.3,

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 Using binary packages to install PHP on OpenBSD is the recommended and simplest method. The core package has been separated from the various modules, and each can be installed and removed independently from the others. The files you need can be found on your OpenBSD CD or on the FTP site. The main package you need to install is php4-core-4.3.8.tgz, which contains the basic engine (plus gettext and iconv). Next, take a look at the module packages, such as php4-mysql-4.3.8.tgz or php4-imap-4.3.8.tgz. You need to use the phpxs command to activate and deactivate these modules in your php.ini. Example 4-6. OpenBSD Package Install Example

# pkg_add php4-core-4.3.8.tgz # /usr/local/sbin/phpxs -s # cp /usr/local/share/doc/php4/php.ini-recommended /var/www/conf/php.ini (add in mysql) # pkg_add php4-mysql-4.3.8.tgz # /usr/local/sbin/phpxs -a mysql (add in imap) # pkg_add php4-imap-4.3.8.tgz # /usr/local/sbin/phpxs -a imap (remove mysql as a test) # pkg_delete php4-mysql-4.3.8 # /usr/local/sbin/phpxs -r mysql (install the PEAR libraries) # pkg_add php4-pear-4.3.8.tgz Read the packages(7) manual page for more information about binary packages on OpenBSD.

Using Ports You can also compile up PHP from source using the ports tree. However, this is only recommended for users familiar with OpenBSD. The PHP 4 port is split into two sub-directories: core and extensions. The extensions directory generates sub-packages for all of the supported PHP modules. If you find you do not want to create some of these modules, use the no_* FLAVOR. For example, to skip building the imap module, set the FLAVOR to no_imap.

Common Problems •

The default install of Apache runs inside a chroot(2) jail, which will restrict PHP scripts to accessing files under /var/www. You will therefore need to create a /var/www/tmp directory for PHP session files to be stored, or use an alternative session backend. In addition, database sockets need to be placed inside the jail or listen on the localhost interface. If you use network functions, some files from /etc such as /etc/resolv.conf and

/etc/services will need to be moved into /var/www/etc. The OpenBSD PEAR package automatically installs into the correct chroot directories, so no special modification is needed there. More information on the OpenBSD Apache is available in the OpenBSD FAQ.



The OpenBSD 3.6 package for the gd extension requires XFree86 to be installed. If you do not wish to use some of the font features that require X11, install the php4-gd-4.3.8-no_x11.tgz package instead.

Older Releases Older releases of OpenBSD used the FLAVORS system to compile up a statically linked PHP. Since it is hard to generate binary packages using this method, it is now deprecated. You can still use the old stable

ports trees if you wish, but they are unsupported by the OpenBSD team. If you have any comments about this, the current maintainer for the port is Anil Madhavapeddy (avsm at openbsd dot org).

add a note User Contributed Notes

OpenBSD installation notes hg at ostc dot de 15-May-2005 10:45

Also you should add "-a /var/www/dev/log" to the syslogd_flags for propper logging of php-extensions like imap.so and create a /var/www/etc/master.passwd with an www-user-entry and run pwd_mkdb -d /var/www/etc /var/www/etc/master.passwd for propper use of libc-client.a functions in imap.so. openbsd-fanatic 10-May-2005 01:51

I am user that is just migrating to open source and thought I would take openbsd for a spin. This article, by Gregory L. Magnusson, really helped me to get a working apache-php-mysql server going on openbsd. http://www.devx.com/security/Article/28059/0/page/1 ameen(at)dausha(dot)net 02-Nov-2003 07:47

I just finished spinning my wheels with PHP/Apache on OpenBSD 3.3, and it took a Google to fix my problem. I followed the instructions by (0429196301 at netcabo dot pt) written on Sep 19, 2003 and kept being fed a segmentation fault when I tried to start httpd. Then I read the page cited below that suggested playing with the order of the LoadModules, and put the PHP first. I followed that recommendation and httpd started without problems! Page that saved me: http://archives.neohapsis.com/archives/openbsd/2002-04/3074.html "Change around the order of the Apache modules, this is one of the drawbacks to the module API for Apache 1.3 is that the order is very important. I would try making the PHP 4 module first, Perl module second and FP module last. " sanchero [at] gvsu [dot] edu 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: AddModule mod_ssl.c AddModule mod_php4.c This causes mod_php4 to load only when starting Apache w/SSL, so if this isn't what you want add the mod_php4 line again above (or below) this section, like so: AddModule mod_php4.c AddModule mod_ssl.c AddModule mod_php4.c

mkheaders.conf SHELL=/bin/sh SYSTEM_HEADER_DIR="/usr/include" OTHER_FIXINCLUDES_DIRS=""

FIXPROTO_DEFINES="-D_XOPEN_SOURCE" STMP_FIXPROTO="stmp-fixproto" STMP_FIXINC="stmp-fixinc" ^D # ./mkheaders xlark at sdf dot lonestar dot org 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 ./configure --prefix=/opt/php --with-apxs=/opt/apache/bin/apxs --withpgsql=/opt/pgsql --with-imap=/usr/src/soft/imap-2002b --with-ldap --withimap-ssl=/usr/local/ssl It compiles, but when i try to run it says something like: bash-2.05# /opt/apache/bin/apachectl start Syntax error on line 205 of /opt/apache/conf/httpd.conf: Cannot load /opt/apache/libexec/libphp4.so into server: ld.so.1: /opt/apache/bin/httpd: fatal: relocation error: file /opt/apache/libexec/libphp4.so: symbol ldap_start_tls_s: referenced symbol not found /opt/apache/bin/apachectl start: httpd could not be started This means that the ldap librarys that came with solaris, are not very fine, you should use from openldap.org packages... it is using this library: bash-2.05# ldd /opt/apache/libexec/libphp4.so ... libldap.so.5 => /usr/lib/libldap.so.5 his one is from solaris installation. (sorry about my english) nicos at php dot net 06-Jan-2003 07:49

Note that you also need GNU sed or you'll have some errors lile "Output line too long." m at hackerz dot uk dot co 15-Oct-2002 09:49

Compiled Ok on Solaris 9 after the addition of Bison Flex automake and autoconf, adding /usr/local/bin to the path and linking /usr/ccs/bin/ar to /usr/local/bin/ar. php at woodNO-SPAMstea dot com 26-Jun-2002 11:15

Howard Glynn's post from May 22 is right on - if you're running Solaris 8, make sure you get the latest Recommended patch cluster. I've been struggling with that library problem that happens when you start Apache for several weeks, tweaking the config, setting LD_LIBRARY_PATH, etc. I couldn't believe that the PHP developers wouldn't have the Solaris build right - seems like a fairly important OS. But the latest Solaris patch cluster fixed the problem, so I guess it was my fault for not being up to date. I'm running PHP 4.2.1 now with Apache 2.0.36, works great.

ltfrench at vt dot edu 09-Jun-2002 02:09

To get PHP 4.2.0 or better to make on Solaris 8 (using gcc and gnu autoconf) you need to: ln -s /usr/local/bin/gcc /usr/local/bin/cc See: http://bugs.php.net/bug.php?id=16833 howardglynn at hotmail dot com 22-May-2002 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) Apache build options: ./configure --prefix=/usr/local/etc/apache --enable-module=rewrite --enableshared=rewrite PHP build options: ./configure --with-mysql=/usr/local/etc/mysql --withapxs=/usr/local/etc/apache/bin/apxs Both Apache and PHP compiled without errors and installed cleanly. The Error when starting Apache: Syntax error on line 208 of /usr/local/etc/apache/conf/httpd.conf: Cannot load /usr/local/etc/apache/libexec/libphp4.so into server: ld.so.1: /usr/local/etc/apache/bin/httpd: fatal: relocation error: file /usr/local/etc/apache/libexec/libphp4.so: symbol dn_skipname: referenced symbol not found ./apachectl start: httpd could not be started Line 208 in the httpd.conf file is: LoadModule php4_module libexec/libphp4.so The solution: For some reason, even though LD_LIBRARY_PATH was being set properly, it wasn't being read fully. You will need to create a runtime linking environment by doing this: #crle -c /var/ld/ld.config -l /usr/lib:/usr/local/lib:/usr/local/etc/mysql/lib Shane Kinsch NetraCorp LLC / SecurNET Consulting 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 Change the /usr/local/mysql/ prefix to where ever your MySQL installation is. Make sure to add on the /lib/mysql extension to your own path though. Do your normal "apachectl start" command to start Apache and voila, no more error. Apachectl can be found in the bin directory of your Apache installation. cullin at cometsystems dot com 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 : Example 4-7. The two Dotdeb related lines

deb http://packages.dotdeb.org stable all deb-src http://packages.dotdeb.org stable all 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: Example 4-8. Debian Install Example with Apache 1.3

# apt-get install libapache-mod-php4 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 : Example 4-9. Stopping and starting Apache once PHP 4 is installed

# /etc/init.d/apache stop # /etc/init.d/apache start

Better control on configuration 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 php4cgi, 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: Example 4-11. Install PHP with MySQL, cURL and GD

# apt-get install php4-mysql php4-curl php4-gd 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 You'll only have to stop/start Apache as previously to activate the modules.

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:

Example 4-13. This line activates PHP 4 into 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.

add a note User Contributed Notes

Debian GNU/Linux installation notes Ben A. 17-Dec-2005 10:53

Although there are no PHP 5 packages for Debian 3.1 (aka "stable" or "sarge"), there are currently PHP 5 packages for "testing"/"etch" and "unstable"/"sid". Installation works the same way. Also, the same process can be used for Ubuntu, but note that some of the packages may be in the "universe" section instead of "main". jimmychan at example dot com 23-Oct-2005 10:01

If you are using Debian 3.1 It is total, the php.ini is under /etc/php4/apache2

Since Debian 3.1 default apache is 2.0.x version, this one just said how to change the php.ini under apache 1.3.x If you need enable the ext. need manaul edit php.ini, and comment out # of what the ext. that you want to enable Of course, you much first install the ext. first by like that apt-get install php4-gd php4-mysql ......

Chapter 6. Installation on Windows systems 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.

add a note User Contributed Notes

Installation on Windows systems

max dot floden at tjitjing dot com 30-May-2006 03:07

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/blog /2006/05/php5-with-iis6-on-windows-server2003.html (Updated with new/corrected url to original note by John Kerner on 20-Apr2005 03:23 Had to put a space after blog in url to be able to post note - it does wrap fine due to all dashes but refuses to be submitted) winterspan - AT - g m a i l . /C/O/M 19-May-2006 09:57

READ HERE If installing PHP 5.x on Windows Server 2003 / IIS 6.x ... It was extremely frustrating getting this to work, so hopefully my struggle will allow others to do this the *easy* way. BEFORE installing PHP 5 from a web tutorial (a good one found here: http://www.peterguy.com/php/install_IIS6.html) You need to READ THESE TIPS: #Necessary Permissions For WinServer 2003 / IIS6.0# These are the permission settings I found to work well with good security: NTFS permissions (right-click file or folder, select preferences, go to security tab) 1) PHP Install folder -> You need to give NT account: 'Network Service' read/execute permissions on the 'php' install folder (e.g., C:\\PHP). If you have a TMP or SESSION folder within the main PHP folder, you need to give account 'Network Service' read/execute AND write access on those folders. *(You DO NOT need to give the anonymous internet user account: 'IUSR_[name]' ANY permissions on the PHP INSTALL files themselves. )* 2) You DO need to give account: 'IUSR_name' Read/execute permissions on the actual WWW root folder and web .php files (if you want to apply to all sites) or each websites WWW root and .php files if running multiple sites. 3) Within the IIS 6.0 console itself, in the website's preferences (right click on ind. site or 'websites' node to apply to all sites -> select preferences) on the 'Directory Security' tab -> click edit, and if you wish to allow anonymous access to your site, check the anonymous access box and be sure to enter account: 'IUSR_name'. 4) *MOST IMPORTANT* As mentioned by a few others, install php and configure the php.ini WITH NO EXTENSIONS AT FIRST. The reason being if one of the extensions fail, the error dialog will pop up OUTSIDE of a terminal services window (remote desktop). So you will NOT BE ABLE to click on the error, and the websites php file you are trying to load in your browser will hang indefinately (after having this happen for 12 hours I almost went insane trying to figure out the problem) LOL. Then when you have successfully loaded a test php page in the browser, go back to the php.ini file and add extensions in one at a time. If YOU have any tips I haven't included, email me. Again, I am not a professional, still a student in learning. :) Now that you have read that, go back to the link I placed near the top, and follow his tutorial for general installation/setup. Nestor Custodio 04-May-2006 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. That is, use C:\\PROGRA~1\\PHP\\php5isapi.dll instead of "C:\\Program Files\\PHP\\php5isapi.dll". cjbj at hotmail dot com 02-May-2006 04:54

Notes on configuring IIS and PHP to use Oracle are at http://blogs.oracle.com/opal/2006/05/01#a24 Cam McVey 20-Apr-2006 03:48

If you are using Application Pool Isolation and you're trying to get PHP to run as CGI and you're getting 403 errors, try looking at this article (watch the word wrap): http://www.servertastic.com/articles/2005/11/ unable-to-run-perl-or-php-in-application-pool-isolation/ SmugWimp at smugwimp dot com 20-Apr-2006 02:29

If you make changes to your PHP.ini file, consider the following. (I'm running IIS5 on W2K server. I don't know about 2K3) PHP will not "take" the changes until the webserver is restarted, and that doesn't mean through the MMC. Usually folks just reboot. But you can also use the following commands, for a much faster "turnaround". At a command line prompt, type: iisreset /stop and that will stop the webserver service.

Then type:

net start w3svc and that will start the webserver service again. MUCH faster than a reboot, and you can check your changes faster as a result with the old: in your page somewhere. I wish I could remember where I read this tip; it isn't anything I came up with... ratkinson at tbs-ltd dot co dot uk 04-Apr-2006 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: - create a new Application Pool - right click the new pool and select "properties" - click on the "Identity" tab - change the permissions from "Network Service" to a user on the Web Server who has access to call the Application (COM) server. - right click the application pool - click "start" - right click your web site - click on the "Home Directory" tab - change the application pool to the new application pool you've just created. - restart IIS Hopefully this will save someone some time and headaches. mach 28-Feb-2006 06:15

I've installed Apache + PHP on a Windows machine of which I'm not an administrator. I found out it was necessary to change the permissions of the httpd.conf file on C:\Program Files\Apache Group\Apache\conf in order to have everything working. Since I'm also using cygwin this was simply done with: >chmod 755 httpd.conf. lukasz at szostak dot biz 15-Jan-2006 07:50

You can have multiple versions of PHP running on the same Apache server. I have seen many different solutions pointing at achieving this, but most of them required installing additional instances of Apache, redirecting ports/hosts, etc., which was not satisfying for me. Finally, I have come up with the simplest solution I've seen so far, limited to reconfiguring Apache's httpd.conf. My goal is to have PHP5 as the default scripting language for .php files in my DocumentRoot (which is in my case d:/htdocs), and PHP4 for specified DocumentRoot subdirectories. Here it is (Apache's httpd.conf contents): --------------------------# replace with your PHP4 directory ScriptAlias /php4/ "c:/usr/php4/" # replace with your PHP5 directory ScriptAlias /php5/ "c:/usr/php5/" AddType application/x-httpd-php .php Action application/x-httpd-php "/php5/php-cgi.exe" # populate this for every directory with PHP4 code Action application/x-httpd-php "/php4/php.exe" # directory where your PHP4 php.ini file is located at SetEnv PHPRC "c:/usr/php4" # remember to put this section below the above

# directory where your PHP5 php.ini file is located at SetEnv PHPRC "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. Remember to put your php.ini files in directories specified in lines "SetEnv PHPRC...", and make sure that there's no php.ini files in other directories (such as c:\windows in Windows). And finally, as you can see, I run PHP in CGI mode. This has its advantages and limitations. If you have to run PHP as Apache module, then... sorry you have to use other solution (the best advice as always is: Google it!). Hope this helps someone. phil at pelanne dot com 05-Jan-2006 09:22

For those of you trying to install PHP 4 and PHP 5 concurrently on a windows 2003 box, there is just one rule you need to adhere to in order to make it work: - Don't have either of them in c:\php\. - Don't have a php.ini in your system32 directory. Put PHP 4 into a directory called c:\php4\. Put its php.ini in there, and make sure all the paths reflect the c:\php4 directory. Likewise, put PHP 5 into a directory called c:\php5\. Put its php.ini in there, and make sure all the paths reflect the c:\php5 directory. Add them as allowed script mappings in your iis extensions area, and have fun! cormierma_at_csdcso.on.ca 21-Dec-2005 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. Then I go to Control Panel>Administrative Tools>Services and restart the IIS Admin Service. Everything worked like a charm... william keith 28-Sep-2005 03:51

Dirt Simple Install Guide For PHP5/W2K Servers For those of us out there who still have 2K servers, this is a great 3 min step by step to get you up and running.

http://www.onlamp.com/pub/a/php/2000/12/14/php_admin.html Thanks to it's author, Darrell Brogdon! thedeadraptor2000 at yahoo dot com 30-Aug-2005 08:02

Note regarding PHP4 Installation on IIS5 + Win2K Tip: Don't install PHP4 on Directories with spaces in between. I've had problems Installing PHP 4.0.0 on IIS5, Win2k's default web server, spanish version (I live in Colombia). I've had HTTP 500 Errors and I followed all instructions step by step, but nothing seemed to work. I solved the problem eventually, and I think it had something to do with the fact that I have installed PHP4 manually and placed it in the directory "C:\Archivos de programa\php-4.4.0-Win32" ('Archivos de programa' stands for 'Program Files'), a directory with spaces in between. When I added the application mappings for "C:\Archivos de programa\php4.4.0-Win32/sapi/php4isapi.php", An error would ocurr and a message along with it: "Escriba una ruta de acceso valida", as in "Write a valid access rute", as in "I can't find the file". I thought i had it when I encapsulated it with Doublequotes ("), but that didn't work either. As a final long shot, I copied the php4isapi.dll to the windows/system32 directory and 'WALA!' It worked. I'm not sure, but i suspect that it had to do with spaces in between directory names, so avoid those, or copy the isapi module to another directory. Hope this helps someone! Doug Brower 26-Aug-2005 07:44

Kudos to John Kerner's recommendation (above) to use: http://www.tjitjing.com/code/article.php?subject=php5_iis6_install for installation on Windows. I followed the instructions with Windows XP Professional on a dev machine, rather than Windows 2003 Server as described in the note. Only difference was to omit his step 4.a. Worked like a champ! wappa at hotmail dotandthekangaroo com 04-Aug-2005 08:16

Don't forget if you are getting ACL exceptions to reading the test php page you have created you MUST share the PHP directory or the resources PHP uses to "everyone" but remember use restricted access for security. jp at iticonsulting dot nl 23-Jul-2005 09:42

If you get 404 page not found on Windows/IIS5, have a look at C:\SYSTEM32\INETSRV\URLSCAN There is a .ini file there that prevents some files from being served by IIS, even if they exist, instead IIS will give a 404. The urlscan logfile (same place) should give you some insight into what parameter is preventing a page from loading, if any. Feroz Zahid 08-Jun-2005 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. 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. Its simple, just: 1. Move your php.ini file from your c:\windows\ directory directly to your php directory (by default that would be c:\php\) 2. Make sure you don't have a php.ini file in any other location that would supercede the c:\php\php.ini file. Using phpinfo(); is useful here. 3. Have your alternate version of php (either a different version or a different php.ini) have its own install directory, like c:\php4RG\ or c:\php405\. 4. In the Home Directory Configuration for your website, specify the .php extension to use a different script, pointing it at the alternate directory. gary at garyslittlecompany dot com 26-Apr-2005 01:57

php compiled with eapi on windows. that would work for the

Spend hours trying to find something

"Loaded DSO /..../php4apache.dll uses plain 1.3 API, this module might crash under EAPI! (please recompile it with -DEAPI)". Finally compiled it. 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. Probably some other solutions would've worked as well, but in my frusterated state of mind, this explanation was the clearest. My problem was that in addition to adding the the Web service extension, I was not adding the ISAPI extensions for the websites in IIS Manager manaully. ALSO, remember to reboot after the changes on the site listed above. It's the only thing he forgot to mention, and depending on your setup, you may need to reboot to register the dll moves and changes made. (IIS restart will not re-register dlls). Steve N 02-Feb-2005 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: Php.ini runtime changes: Create a new application pool in iis: iis->select server->application pools->new application pool Use default settings; go to the application pool you've created, properties-> check the "Recycle worker process" option, and give it a small value (10 is nice :) ). Now go to your site (or virtual directory site)-> properties-> change the application pool to the newly configured appPool. At this moment, is good to make a iss restart (note this is the only resart needed). Your site is now semi-runtime changed :) You can try it with the usal php info() test. Change something in the

php.ini and check the number of requests it takes to use the new configuration. The downside of this approach (wich is still better than to use phpcgi.exe): the process is recycled, so all the configuration in php.ini is read every N requests - with php-cgi.exe, this would happen for every request, so.. is a good solution. Again, be carefull when using this in a production environment, since the load can increase (not sure how much, but it will certainly increase). And keep in the new appPool JUST the php sites that require runtime changes in php.ini ! -----You've helped me, so I help you ;) Tks chris at move dash media dot com 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: Note: Watch for wordwrap http://www.microsoft.com/resources/documentation/ WindowsServ/2003/standard/proddocs/en-us/Default.asp? url=/resources/documentation/WindowsServ/2003/standard/ proddocs/en-us/sec_acc_wpenable.asp Otherwise you will recieve 403 errors. Sean Boulter 15-Apr-2004 02:00

This fixes the "The directory name is invalid" error. In IIS 5.1 on Windows XP Pro, Go into the Internet Information Services, and into the properties of the virtual directory where the problem occurs. On The 'Virtual Directory' tab, click on the 'Configuration...' button. Select the '.php' extension, and press 'Edit'. On the bottom, Check the 'Check that file exists' checkbox. Luis D 27-Mar-2004 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"; Once the "new web service extension" opens: 1- Add the wanna call and always 2-Click on (default)

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

extension status to allowed" click OK and thats it!!! If you missed the checkmark moment cause you are just so impatient, like me, then simply select the extension on the web service extensions windows and click ALLOW. This is a very simple process and it will work everytime. I hope this helps, as I have found several things in this forums that are incredibly helpfull!! PS: For the non programmer, it is a good practice to install mysql and a free php forum like bb2 to test how well your php IIS and mysql is working. 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. The page is located at: 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. You have several options to remedy the problem: an obvious one is to make it run as the "Local System", but that may be too much power for some administrators' tastes. The other option is at the IIS Manager, go to the computer's "Application Pools" folder, and go to the properties dialog box of the "DefaultAppPool", and then to the "Identity" tab, and select the "Configurable" identity of "IWAM_[COMPUTER_NAME]" as the security context. This will make the application pool run the way it did in the previous versions. This solved the repeated problems of the 403 errors. However, do not forget to give permission to "IUSR_[COMPUTER_NAME]" and "IWAM_[COMPUTER_NAME]" appropriate directory permissions for your web directories as stated above. 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) webserver 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: - 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. - 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 webdefault-directory a virtual directory with all possible rights. 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: Example 6-1. PHP 4 package structure

c:\php | +--cli | | | |-php.exe scripting | +--dlls | | | |-expat.dll | | | |-fdftk.dll | | | |-... | +--extensions | | | |-php_bz2.dll | | | |-php_cpdf.dll

-- CLI executable - ONLY for commandline

-- support DLLs required by some extensions

-- extension DLLs for PHP

| | | |-.. | +--mibs | +--openssl | +--pdf-related | +--sapi | | | |-php4apache.dll | | | |-php4apache2.dll | | | |-.. | +--PEAR | | |-go-pear.bat | |-.. | |-php.exe | |-.. | |-php.ini-dist | |-php.ini-recommended | |-php4ts.dll | |-...

-- support files for SNMP -- support files for Openssl -- support files for PDF -- SAPI (server module support) DLLs

-- initial copy of PEAR

-- PEAR setup script

-- CGI executable

-- default php.ini settings -- recommended php.ini settings -- core PHP DLL

Or: Example 6-2. PHP 5 package structure

c:\php | +--dev | | | |-php5ts.lib | +--ext | | | |-php_bz2.dll | |

-- extension DLLs for PHP

| |-php_cpdf.dll | | | |-.. | +--extras | | | +--mibs | | | +--openssl | | | +--pdf-related | | | |-mime.magic | +--pear | | |-go-pear.bat | |-fdftk.dll | |-.. | |-php-cgi.exe | |-php-win.exe prompt | |-php.exe scripting | |-.. | |-php.ini-dist | |-php.ini-recommended | |-php5activescript.dll | |-php5apache.dll | |-php5apache2.dll | |-.. | |-php5ts.dll | |-...

-- support files for SNMP -- support files for Openssl -- support files for PDF

-- initial copy of PEAR

-- PEAR setup script

-- CGI executable -- executes scripts without an opened command

-- CLI executable - ONLY for command line

-- default php.ini settings -- recommended php.ini settings

-- 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). Here is a list of server modules shipped with PHP 4 and PHP 5:



sapi/php4activescript.dll (php5activescript.dll) - ActiveScript engine, allowing you to

• • •

sapi/php4apache.dll (php5apache.dll) - Apache 1.3.x module. sapi/php4apache2.dll (php5apache2.dll) - Apache 2.0.x module. sapi/php4isapi.dll (php5isapi.dll) - ISAPI Module for ISAPI compliant web servers like IIS

• •

sapi/php4nsapi.dll (php5nsapi.dll) - Sun/iPlanet/Netscape server module. sapi/php4pi3web.dll (no equivalent in PHP 5) - Pi3Web server module.

embed PHP in your Windows applications.

4.0/PWS 4.0 or newer.

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:



The same directory from where (e.g.



php.exe is called, or in case you use a SAPI module, the web server's directory C:\Program Files\Apache Group\Apache2\bin).

Any directory in your Windows PATH environment variable.

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.inirecommended, 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). The following steps are optional:



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:

doc_root = c:\inetpub\wwwroot // for IIS/PWS

doc_root = c:\apache\htdocs // for Apache •

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.

add a note User Contributed Notes

Manual Installation Steps Jason Greene 04-May-2006 06:06

If you are running websites within an Application Pool (which is now the default for IIS6 under 2K3) you need to make sure that your PHP directory (e.g. C:\PHP) has read permissions for the user assigned to the Application Pool. 1. In the IIS snap-in, choose Application Pools 2. Right-click on DefaultAppPool (or other, if you have one defined) and choose Properties 3. Click the Identity tab 4. Make a note of the user name set as the security account for this application pool (e.g. "Network Service") 5. Browse to your PHP directory and grant that user read permissions for the entire directory. In my case, I had to add permissions for the user "NETWORK SERVICE" to get PHP scripts to work. Otherwise I received 401/403 authorization errors when trying to load them in a remote browser. Note also that first tried adding IUSR permissions to the PHP directory, but that had no effect. Ben 06-Apr-2006 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". By default, on my machine, the permissions were set to "None" not allowing php to run. Also, for more security it might be wise to Add the new extension just to your default site instead of the whole Web Sites folder in IIS. This would only apply if you were hosting multiple sites and had a site you didn't want scripts to run on. Tom 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. If you can't afford to do that (installing on a live server for example), you can use the setx.exe tool from the Windows Resource Kit (google it). Like so:

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

1. Add new extension (.php) * Expand the local computer in the left pane * Right-click on "Web Sites" in the left pane, then click "Properties" in the menu that pops up * Flip top the "Home Directory" tab * Click "Configuration" * Flip to the "Mappings" tab * Click "Add..." * Enter the full path to php5isapi.dll in the "Executable" textbox (Browse... to find it more easily if you need to) * Enter ".php" in the "Extension" textbox * Select radial button "Limit to", enter "GET,POST,HEAD" * Click "OK" all the way out 2. Verify php5isapi.dll is allowed You must verify that the versions of php5isapi.dll that you want to use are allowed. 2.1. In Internet Information Services (IIS) Manager, in the left-hand column, click the Web Services Extensions node and verify php5isapi.dll is allowed and all other Web Service Extensions are prohibited. 2.2. If the version of php5isapi.dll that you want to use does not appear in the list, follow the instructions to enable it and then repeat this procedure: Go into IIS Below all of the websites is a folder: Web Service Extensions In blue, to the lower left, is a choice: Add A New Web Service Extension Add PHP/PHP5ISAPI.dll Choose To ALLOW it. 2.3 If the version of php5isapi.dll you want to use appears on the list but is not allowed, right click the version of php5isapi.dll you want to allow and click Allow. 3. Configuring IIS for 32-Bit Emulation Mode (THIS IS MOST IMPORTANT!!!!) 3.1. If you are installing IIS on x64-based editions of Windows Server 2003 or Windows Server 2003 R2, IIS must be configured to run in 32 bit emulation mode. Perform the following procedure on each front-end Web server running an x64-based edition of Windows Server 2003. Configure Internet Information Services (IIS) for 32-bit mode 1. Click Start, and then click Run. 2. In the Open box, type cmd, and then click OK. 3. In the command prompt window, navigate to the %drive %:\Inetpub\Adminscripts folder, where %drive% is the drive in which Windows Server 2003 is installed. 4. In the Adminscripts folder, type the following command: cscript adsutil.vbs set w3svc/AppPools/Enable32bitAppOnWin64 1 Note The value "1" for Enable32bitAppOnWin64 specifies 32-bit mode, whereas the value "0" specifies 64-bit mode. 5. Press ENTER. 6. Type iisreset and then press ENTER. 7. Close the command prompt window. 8. Re-star System. Note The Run WWW service in IIS 5.0 isolation mode check box is only selected if you have upgraded to IIS 6.0 on Windows Server 2003 from IIS 5.0

on Windows 2000. New installations of IIS 6.0 use IIS 6.0 worker process isolation mode by default. patatraboum at nospam dot com 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 = Then restart IIS to reload php.ini some dude @ some place 04-Nov-2005 08:57

on two recent installation attempts on iis6 on win2k3 i followed the php manual and windows configuration steps exactly and php would still not run. on the first install i had to give the USER account (not IUSR) read execute permissions to this file, c:\php\sapi\php4isapi.dll. using filemon i saw that it was being accessed and access was denied. steps: - right click on this file > properties > security > add > location (select the server -not domain if listed) > advanced > find now > Users (usually the last item) > click OK - select Read & Execute > apply also a complete computer restart was required in each install Bill dot Rook at Gmail dot com 18-Sep-2005 10:09

doc_root = ".;c:\inetpub\wwwroot" does seem to work with virtual websites. This might be a better option then commenting out the line. Jason 09-Sep-2005 04:54

For me atleast, the steps for installing php 5 on IIS 6 on windows 2003 seemed to get buried with the other setups. I found it difficult to quickly look through and make sure I covered every step. So I created a clean step by step tutorial with screenshots: http://psdforums.com/article.php?a=9 atomictaco at atomic-taco dot com 10-Jul-2005 09:17

In response to phpmanual at pbb dot dds dot nl: You are absolutly correct. I found this out while trying to install PHP4 with Apache2 on XPPro. Here are 3 general guidelines that I have found to be correct: - Path may not have spaces. Change C:\Program Files to C:\Progra~1 If you don't understand this, go to start-->run-->command (not cmd). Type cd\ and hit enter. Then type dir. You should see all your directory names there. - Paths should not be enclosed by quotes. - Use forward slashes (/) and not backslashes (\) thierry dot bo at nxextxcxoxuxrxrxixexr dot com 20-Dec-2004 04:50

With PHP 4.3.x and apache 1.3.x on windows, PHPRC is used only if php is installed as cgi. With module, no matter using setenv in httpd.conf or PHPRC as windows environment variable, it is not used. cpz at akik-ffm dot de 19-Dec-2004 10:24

In the above, "the web server's directory" means the directory where the server executable lives, for example for the Apache installation on my XP box this is "\program files\apache group\apache2\bin" and NOT just "\program files\apache group\apache2". But it's probably best to tell your web server where PHP's ini file is stored, for example via PHPIniDir for Apache's http.conf. 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: "C:\Program Files\php5\php5isapi.dll" -- doesn't work C:\php5\php5isapi.dll -- works "C:\php5\php5isapi.dll" -- doesn't work C:\Progra~1\php5\php5isapi.dll -- works "C:\Progra~1\php5\php5isapi.dll" -- doesn't work C:\Program Files\php5\php5isapi.dll -- doesn't work, because it's not accepted by Internet Information Services I don't know if this all is a problem with Internet Information Services or with PHP, but it would be nice if it was more documented in the PHP manual. php dot user dot com 29-Aug-2004 01:43

After having the same problem as specifed below with "No input file specified". I changed the doc_root as mentioned. This is fine if all php scripts are going to be run from the c:\inetpub\wwwroot directory. To enable it for multiple websites where the root directories are all different simply leave the doc_root attribute in the php.ini file blank. This is for the isapi version not cgi implementation. It also means you don't have to set IUSR or IWAM access to the PHP root directory.

ActiveScript This section contains notes specific to the ActiveScript installation. ActiveScript is a windows only SAPI that enables you to use PHP script in any ActiveScript compliant host, like Windows Script Host, ASP/ASP.NET, Windows Script Components or Microsoft Scriptlet control. As of PHP 5.0.1, ActiveScript has been moved to the PECL repository. You may download this PECL extension DLL from the PHP Downloads page or at http://snaps.php.net/. Note: You should read the manual installation steps first! After installing PHP, you should download the ActiveScript DLL (php5activescript.dll) and place it in the main PHP folder (e.g. C:\php). After having all the files needed, you must register the DLL on your system. To achieve this, open a Command Prompt window (located in the Start Menu). Then go to your PHP directory by typing something like cd C:\php. To register the DLL just type regsvr32 php5activescript.dll. To test if ActiveScript is working, create a new file, named test.wsf (the extension is very important) and type:

$WScript->Echo("Hello World!"); 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 phpactivescript.ini and place it in that folder, if you wish to load extensions, etc.

add a note User Contributed Notes

ActiveScript garfiel_fr at tiscali dot fr 11-May-2005 09:06

There is another way to execute a PHP ActiveScript: 1/ In explorer, open menu "Tools/Folder Options" 2/ Go to tab "File Type" 3/ Click on "New" button and enter a file extension ( PHS for my sample ), you can also select "PHPScript" in "Advanced" button. Then OK, a new file extension is registered. 4/ In tab "File Type" select the new extension and click on button "Advanced". A new dialog box is open. 5/ Click on "New" button and fill edit box with: Action: Run Application to use: C:\WIN2K\system32\wscript.exe //E:PHPScript "%1" "%2" That's all !! Now, your code don't need XML tag at the begining. Hello work in test.phs

will be: $WScript->Echo("Bonjour le monde !");

Microsoft IIS / PWS 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.

General considerations for all installations of PHP with IIS or PWS •

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 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.exe while in PHP 5 it's php-cgi.exe. In PHP 5, php.exe is the CLI, and not

the system that PHP is being installed on. In PHP 4, the extension_dir is

php.ini. These directives depend on 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.

Windows NT/200x/XP and IIS 4 or newer 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 want to use the CGI binary, do the following:

• • •

Under 'Home Directory', 'Virtual Directory', or 'Directory', do the following:



Set up the appropriate security. (This is done in Internet Service Manager), and if your NT Server uses NTFS file system, add execute rights for I_USR_ to the directory that contains php.exe / php-cgi.exe.

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 CGI file. An example PHP 5 value is: C:\php\php-cgi.exe Supply .php as the extension. Leave 'Method exclusions' blank, and check the 'Script engine' checkbox. Now, click OK a few times.

To use the ISAPI module, do the following:



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:



Stop IIS completely (NET STOP iisadmin)

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.



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.

Windows and PWS 4 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.

Windows and PWS/IIS 3 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.



Repeat these steps for each extension you wish to associate with PHP scripts.

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.

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.

• • • • • • • • • •

Navigate to: HKEY_CLASSES_ROOT On the edit menu select: New->Key. Name the key to the extension you setup in the previous section. ex: .php Highlight the new key and in the right side pane, double click the "default value" and enter phpfile. Repeat the last step for each extension you set up in the previous section. Now create another New->Key under HKEY_CLASSES_ROOT and name it phpfile. Highlight the new key phpfile and in the right side pane, double click the "default value" and enter PHP Script. Right click on the phpfile key and select New->Key, name it Shell. Right click on the Shell key and select New->Key, name it open. Right click on the open key and select New->Key, name it command.



Highlight the new key command and in the right side pane, double click the "default value" and enter the path to php.exe. ex: c:\php\php.exe -q %1. (don't forget the %1).

• •

Exit Regedit. If using PWS on Windows, reboot to reload the registry.

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.

add a note User Contributed Notes

Microsoft IIS / PWS sschefer at scheferonline dot net 28-May-2006 11:56

I have sucessfully installed PHP 4 and 5 on every windows server version since 2000 (not NT4) and XP. It is simple but there are a couple of prerequisites that I've never seen mentioned. 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. Hope this helps someone. Steve legolas558_AT_users dot sourceforge.net 12-May-2006 09:07

How to solve the nasty "permission denied" under IIS (Windows xp) 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 will look at your PHPRC setting and get the ini file path you'll end up with both versions running off the same INI The way around this is to use the CGI for one version and other.

that both versions from that. So which is no good. ISAPI for the

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. Here is the solution I found. The default install registers the .php extension as belonging to c:\php\php.exe. This is correct, but it's faster to use the ISAPI extension. To 1. 2. 3. 4. 5. 6. 6.

do this, Open the IIS Management console Expand the server, right click on "Web Sites" and click Properties Open the "ISAPI Filters" foldertab Click Add Enter PHP in the Filter Name box. Click Browse and then Browse to your php4isapi.dll. 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 [email protected] ---------------------------------------------------------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: Control Panel>Administrative Tools>Internet Information Services When you are at the IIS window in the left navigational panel go to: Local Computer>Web Sites>Default Web Site Right-click on your default web site and select Properties. A Properties window appears. Select the Home Directory tab. Click on the Configuration... button. A Configuration window appears. Below the Mappings tab is the Cache ISAPI applications checkbox.

Again, make sure that the Cache ISAPI applications checkbox has a check in it. I hope this helps anybody else with a similar problem. Mac Rinehart 07-Sep-2005 09:14

"Click on the 'Configuration' button, and choose the Application Mappings tab. Click Add and set the Executable path to the appropriate CGI file. An example PHP 5 value is: C:\php\php-cgi.exe Supply .php as the extension. Leave 'Method exclusions' blank, and check the 'Script engine' checkbox. Now, click OK a few times." 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 It has come to my attention that the link to my PHP installation guide in my posting of 07-Feb-2005 11:49 is a Bad Link. We don't like Bad Links. Here's the correct one: http://www.peterguy.com/php/install_IIS6.html Enjoy! -Peter Marat 16-Mar-2005 01:50

The correct required NTFS ACL's are: - for the folder holding your PHP files: [Read] IUSR_servername [Read] IWAM_servername -for the folder holding the PHP executables: [Read] IUSR_servername Person who wants ISAPI version installer 25-Feb-2005 01:59

Supplementation to the previous hint The environment is Windows 2003 Server/IIS 6/PHP 5. About IIS 6 of Windows XP. 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. iis6isapimap add .PHP C:\PHP\php5isapi.dll GET,POST,HEAD 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. ) [Method of addition to Web enhancing] 'IISEXT.VBS' is attached to IIS 6. iisext /AddFile C:\PHP\php5isapi.dll 1 PHP 1 "PHP: Hypertext Preprocessor" iisext /RmFile

C:\PHP\php5isapi.dll

[Method of adding extension to Application Mappings] To our regret, there is no good method in the standard. :-( The source code of C# program that is registered and deleted is presented in the mapping. (It is hoped that someone writes VBScript or the JScript version) iis6isapimap add .PHP C:\PHP\php5isapi.dll < deletion example> iis6isapimap delete .PHP 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] (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"). 1. In IIS Admin, go to Application Pools 2. Right click on the pool your site is running under and click properties. 3. Go to the Identity tab and see what user is selected. 4. Give that user permissions to your php files/directory. 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. 7. When the OK button becomes active, click OK to continue. Source: http://support.microsoft.com/?id=317948 -paulwebmaster 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 phpcgi.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. Ofcourse you can add other pages as default. 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. However, here's how i solved the problem. (I believe this solution is relevant to fixing the active directory issue) 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. 3. Now navigate to the identity tab. 4. My Worker process was set to Predefined: Network Service. I changed this to Configurable: IWAM_(server name) (which if you noticed is in the user group 'IIS_WPG') 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. Hope this solves someones frustration. giunta dot gaetano at sea-aeroportimilano dot it 12-Feb-2004 05:32

If some extensions (such as OCI or Turck mmcache in FastCGI mode) have trouble functioning with PHP+IIS, make sure that "Allow IIS to Control Password" is unchecked in the preferences panel for anonymous user access. 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 got PHP working by using one of the tips above (thanks!). 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. Note: Please read the manual installation steps first! There are two ways to set up PHP to work with Apache 1.3.x on Windows. One is to use the CGI binary (php.exe for PHP 4 and php-cgi.exe for PHP 5), the other is to use the Apache Module DLL. In either case you need to edit your httpd.conf to configure Apache to work with PHP, and then restart the server. It is worth noting here that now the SAPI module has been made more stable under Windows, we recommend it's use above the CGI binary, since it is more transparent and secure. Although there can be a few variations of configuring PHP under Apache, these are simple enough to be used by the newcomer. Please consult the Apache Documentation for further configuration directives. After changing the configuration file, remember to restart the server, for example, NET STOP APACHE followed by NET START APACHE, if you run Apache as a Windows Service, or use your regular shortcuts. Note: Remember that when adding path values in the Apache configuration files on Windows, all backslashes such as c:\directory\file.ext must be converted to forward slashes, as c:/directory/file.ext. A trailing slash may also be necessary for directories.

Installing as an Apache module You should add the following lines to your Apache httpd.conf file: Example 6-3. PHP as an Apache 1.3.x module This assumes PHP is installed to c:\php. Adjust the path if this is not the case. For PHP 4:

# Add to the end of the LoadModule section # Don't forget to copy this file from the sapi directory! LoadModule php4_module "C:/php/php4apache.dll" # Add to the end of the AddModule section AddModule mod_php4.c For PHP 5:

# Add to the end of the LoadModule section LoadModule php5_module "C:/php/php5apache.dll" # Add to the end of the AddModule section AddModule mod_php5.c For both:

# Add this line inside the conditional brace AddType application/x-httpd-php .php

# For syntax highlighted .phps files, also add AddType application/x-httpd-php-source .phps

Installing as a CGI binary If you unzipped the PHP package to C:\php\ as described in the Manual Installation Steps section, you need to insert these lines to your Apache configuration file to set up the CGI binary: Example 6-4. PHP and Apache 1.3.x as CGI

ScriptAlias /php/ "c:/php/" AddType application/x-httpd-php .php # For PHP 4 Action application/x-httpd-php "/php/php.exe" # For PHP 5 Action application/x-httpd-php "/php/php-cgi.exe" # specify the directory where php.ini is SetEnv PHPRC C:/php Note that the second line in the list above can be found in the actual versions of httpd.conf, but it is commented out. Remember also to substitute the c:/php/ for your actual path to PHP. Warning 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: .

add a note User Contributed Notes

Apache 1.3.x on Microsoft Windows BCarr 20-Jan-2006 01:35

To Besta and 'j dot b..dot sk': 'Add Module mod_php4.c' or 'AddModule mod_php5.c' may or may not be necessary depending on your environment and version of Apache. In my situation, this add module DID NOT work or it wasn't necessary. The LoadModule was enough to do the trick. I tried it with PHP4 on Apache 1.3.34 and Apache 2.0. All in all, your notes have been helpful. j dot b at inmail dot sk 27-Sep-2005 12:42

DO NOT FORGET to add "index.php" into DirectoryIndex index.html

Thanks.

so you get index.php processed;multiple values separate by space: DirectoryIndex index.html index.php 27-Aug-2005 01:51

On contrary to user "Besta"'s post AddModule mod_php5.c should be added to the addmodule section. I installed php5 and apache 1.3.3 and without the above line it is not recognizing the .php files Besta 07-Aug-2005 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: You should read the manual installation steps first! 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:

• •

PHP 4.3.0 or later available at /downloads.php.

• •

a prerelease version downloadable from http://qa.php.net/.

the latest stable development version. Get the source code http://snaps.php.net/php5latest.tar.gz or download binaries for Windows http://snaps.php.net/win32/php5-win32-latest.zip. you have always the option to obtain PHP through anonymous CVS.

These versions of PHP are compatible to Apache 2.0.40 and later. 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.

Installing as a CGI binary You need to insert these three lines to your Apache httpd.conf configuration file to set up the CGI binary: Example 6-5. PHP and Apache 2.0 as CGI

ScriptAlias /php/ "c:/php/"

AddType application/x-httpd-php .php # For PHP 4 Action application/x-httpd-php "/php/php.exe" # For PHP 5 Action application/x-httpd-php "/php/php-cgi.exe" 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.

Installing as an Apache module You need to insert these two lines to your Apache httpd.conf configuration file to set up the PHP module for Apache 2.0: Example 6-6. PHP and Apache 2.0 as Module

# For PHP 4 do something like this: LoadModule php4_module "c:/php/php4apache2.dll" # Don't forget to copy the php4apache2.dll file from the sapi directory! AddType application/x-httpd-php .php # For PHP 5 do something like this: LoadModule php5_module "c:/php/php5apache2.dll" AddType application/x-httpd-php .php # configure the path to php.ini PHPIniDir "C:/php" Note: Remember to substitute your actual path to PHP for the c:/php/ in the above examples. Take care to use either 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. Note: If you want to use content negotiation, read related FAQ. 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.

add a note User Contributed Notes

Apache 2.0.x on Microsoft Windows elga1 at gmx dot de 10-Jul-2006 05:37

"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 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! With regards to installation : Apache 2.2.2 and php v5.1.2 / 5.1.3 / 5.1.4 http://www.apachelounge.com/ Excellent site for these installation issues. 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. I then found a post http://www.apachelounge.com/forum/ viewtopic.php?t=139&view=next&sid=b8df0fe80ac524939e2553ad7ee49123 and tried as suggested by downloading a zip file created by Steffen, and followed the instructions. The apache2.2 now works fine. 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. Discovered that libmysql.dll in the root php directory needs to be moved to C:\WINDOWS or be included in Windows paths in order for this module to load. 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" Copied over the file and mysql functionality was enabled. 12-Dec-2005 03:12

There are often strong suggestions that Apache/MySQL/PHP should be set up in the Windows root folder, and dire warnings against using folders with spaces in the name. But as a relatively non-technical user, I hate cluttering my Windows XP root directory with folders that should be under Program Files,

and of keeping any documents other than in "My Documents" (even though I agree that MS's folder tree is ugly). 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): ServerRoot "C:/Program Files/Apache Group/Apache2" DocumentRoot "C:/Documents and settings/UserNm/My Documents/Websites" # 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 finding php.ini finding

machines are having troubles with the PHPIniDir derective not the php.ini (or so they think). Directories that do contain a file are returned as empty and it defaults to the next method of 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.

CGI setup on Sun, iPlanet and Netscape servers To install PHP as a CGI handler, do the following:

• •

Copy

php4ts.dll to your systemroot (the directory where you installed Windows)

Make a file association from the command line. Type the following two lines:

assoc .php=PHPScript ftype PHPScript=c:\php\php.exe %1 %* •

In the Netscape Enterprise Administration Server create a dummy shellcgi directory and remove it just after (this step creates 5 important lines in obj.conf and allow the web server to handle shellcgi scripts).



In the Netscape Enterprise Administration Server create a new mime type (Category: type, Content-Type: magnusinternal/shellcgi, File Suffix:php).



Do it for each web server instance you want PHP to run

More details about setting up PHP as a CGI executable can be found here: http://benoit.noss.free.fr/php/install-php.html

NSAPI setup on Sun, iPlanet and Netscape servers To install PHP with NSAPI, do the following:

• •

Copy

php4ts.dll to your systemroot (the directory where you installed Windows)

Make a file association from the command line. Type the following two lines:

assoc .php=PHPScript ftype PHPScript=c:\php\php.exe %1 %* •

In the Netscape Enterprise Administration Server create a new mime type (Category: type, Content-Type: magnusinternal/x-httpd-php, File Suffix: php).



Edit magnus.conf (for servers >= 6) or the lines after mime types init.

obj.conf (for servers < 6) and add the following: You should place

Init fn="load-modules" funcs="php4_init,php4_execute,php4_auth_trans" shlib="c:/php/sapi/php4nsapi.dll" Init fn="php4_init" LateInit="yes" errorString="Failed to initialise PHP!" [php_ini="c:/path/to/php.ini"] •

(PHP >= 4.3.3) The php_ini parameter is optional but with it you can place your directory.



Configure the default object in

php.ini in your webserver config

obj.conf (for virtual server classes [Sun Web Server 6.0+] in their vserver.obj.conf): In the section, place this line necessarily after all 'ObjectType' and before all 'AddLog' lines:

Service fn="php4_execute" type="magnus-internal/x-httpd-php" [inikey=value inikey=value ...]



(PHP >= 4.3.3) As additional parameters you can add some special php.ini-values, for example you can set a docroot="/path/to/docroot" specific to the context php4_execute is called. For boolean ini-keys please use 0/1 as value, not "On","Off",... (this will not work correctly), e.g. zlib.output_compression=1 instead of zlib.output_compression="On"



This is only needed if you want to configure a directory that only consists of PHP scripts (same like a cgi-bin directory):

ObjectType fn="force-type" type="magnus-internal/x-httpd-php" Service fn=php4_execute [inikey=value inikey=value ...] •

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").

CGI environment and recommended modifications in php.ini Important when writing PHP scripts is the fact that Sun JSWS/Sun ONE WS/iPlanet/Netscape is a multithreaded web server. Because of that all requests are running in the same process space (the space of the 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! Note: Why are there (invalid) CGI variables in the environment? 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:

Error fn="php4_execute" code=XXX script="/path/to/script.php" [inikey=value inikey=value...] where XXX is the HTTP error code. Please delete any other Error directives which could interfere with yours. If you want to place a page for all errors that could exist, leave the code parameter out. Your script can get the HTTP status code with $_SERVER['ERROR_TYPE'].

Another possibility is to generate self-made directory listings. Just create a PHP script which displays a directory listing and replace the corresponding default Service line for type="magnus-internal/directory" in obj.conf with the following:

Service fn="php4_execute" type="magnus-internal/directory" script="/path/to/script.php" [inikey=value inikey=value...] For both error and directory listing pages the original URI and translated URI are in the variables $_SERVER['PATH_INFO'] and $_SERVER['PATH_TRANSLATED'].

Note about nsapi_virtual() and subrequests (PHP >= 4.3.3) The NSAPI module now supports the nsapi_virtual() function (alias: virtual()) to make subrequests on the 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:

Init fn=php4_init ... server_lib="ns-httpdXX.dll" where XX is the correct DLL version number. To get it, look in the server-root for the correct DLL name. The DLL with the biggest filesize is the right one. You can check the status by using the phpinfo() function. Note: But be warned: Support for nsapi_virtual() is EXPERIMENTAL!!!

OmniHTTPd Server This section contains notes and hints specific to OmniHTTPd on Windows. Note: You should read the manual installation steps first! 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. 1.

Install OmniHTTPd server.

2. 3. 4.

Right click on the blue OmniHTTPd icon in the system tray and select Properties

5. 6.

On the Mime tab, enter: virtual = wwwserver/stdcgi | actual = .php, and use the Add button.

Click on Web Server Global Settings On the 'External' tab, enter: virtual = .php | actual = c:\php\php.exe (use php-cgi.exe if installing PHP 5), and use the Add button. Click OK

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. Note: You should read the manual installation steps first! This list describes how to set up the ISAPI module to work with the Sambar server on Windows.

• •

Find the file called Open

mappings.ini (in the config directory) in the Sambar install directory. mappings.ini and add the following line under [ISAPI]:

Example 6-7. ISAPI configuration of Sambar

#for PHP 4 *.php = c:\php\php4isapi.dll #for PHP 5 *.php = c:\php\php5isapi.dll • •

(This line assumes that PHP was installed in

c:\php.)

Now restart the Sambar server for the changes to take effect.

Xitami on Microsoft Windows This section contains notes and hints specific to Xitami on Windows. Note: You should read the manual installation steps first! 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. or

• •

C:\php\php.exe for PHP 4,

C:\php\php-cgi.exe for PHP 5.

Press the 'Save' icon. Restart the server to reflect changes.

add a note User Contributed Notes

Xitami on Microsoft Windows ae_engine at yahoo dot com 02-Nov-2004 06:07

I have successfully configured Xitami using cgi.redirect in PHP set cgi.redirect = 1 set cgi.redirect_status = CGI_REDIRECT_STATUS; 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 Note that $_SERVER['SCRIPT_NAME'] still works. janko dot slavic at email dot si 30-Nov-2002 02:51

[Editors Note] You can force IE to disregard a cached page by pressing the Control key and click the Refresh button. Please, do not forget the IE caches files. 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. Before you get started, you have to download:

• •

the win32 buildtools from the PHP site at /extra/win32build.zip.



If you plan to compile PHP as a Apache module you will also need the Apache sources.

the source code for the DNS name resolver used by PHP from /extra/bindlib_w32.zip. This is a replacement for the resolv.lib library included in win32build.zip.

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.

Putting it all together 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:



Create the directory

• • •

Create the directory into it.

C:\work. win32build under your working directory (C:\work) and unzip win32build.zip

bindlib_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.

Following this steps your directory structure looks like this:

+--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:



For GUI users, launch VC++, by double-clicking in 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:

o o

C:\work\bindlib_w32\bindlib.dsw. Then select

msdev bindlib.dsp /MAKE "bindlib - Win32 Debug" msdev bindlib.dsp /MAKE "bindlib - Win32 Release"

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-modulesdir=../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.

Building PHP using DSW files [PHP 4] 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:

• • •

Executable files:

C:\work\win32build\bin, Cygwin users: C:\cygwin\bin Include files: C:\work\win32build\include Library files: C:\work\win32build\lib

Compiling The best way to get started is to build the CGI version:



For GUI users, launch VC++, and then select File => Open Workspace and select

C:\work\php4.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 o o

msdev php4ts.dsp /MAKE "php4ts - Win32 Debug_TS" msdev php4ts.dsp /MAKE "php4ts - Win32 Release_TS" 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(). The DLLs for PHP extensions are prefixed with php_. 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 •

Enable the extension(s) in

php.ini you want to use by uncommenting the extension=php_*.dll lines in php.ini. This is done by deleting the leading ; from the extension you want to load. Example 6-8. Enable Bzip2 extension for PHP-Windows

// change the following line from ... ;extension=php_bz2.dll // ... 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 in the system PATH (this process is explained in a separate FAQ entry).



C:\php

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. Table 6-1. PHP Extensions Extension

Description

Notes

php_bz2.dll

bzip2 compression functions

None

php_calendar.dll

Calendar conversion functions

Built in since PHP 4.0.3

php_cpdf.dll

ClibPDF functions

None

php_crack.dll

Crack functions

None

Extension

Description

Notes

php_ctype.dll

ctype family functions

Built in since PHP 4.3.0

php_curl.dll

CURL, Client URL library functions

Requires: libeay32.dll, ssleay32.dll (bundled)

php_cybercash.dll

Cybercash payment functions

PHP = 5.0.0, requires libmysql.dll (libmysqli.dll in PHP = 5.0.0

php_sockets.dll

Socket functions

None

php_sybase_ct.dll

Sybase functions

Requires: Sybase client libraries

php_tidy.dll

Tidy functions

PHP >= 5.0.0

php_tokenizer.dll

Tokenizer functions

Built in since PHP 4.3.0

php_w32api.dll

W32api functions

None

php_xmlrpc.dll

XML-RPC functions

PHP >= 4.2.1 requires: iconv.dll (bundled)

php_xslt.dll

XSLT functions

PHP = 4.2.1 requires sablot.dll, expat.dll, iconv.dll (bundled).

php_yaz.dll

YAZ functions

Requires: yaz.dll (bundled)

php_zip.dll

Zip File functions

Read only access

php_zlib.dll

ZLib compression functions

Built in since PHP 4.3.0

add a note User Contributed Notes

Installation of extensions on Windows hevesir at t-mobile dot hu 07-Apr-2006 01:54

If You try to install PHP5 to IIS6 with Oracle.... Then You need some kind of pilot-exams, not for big planes, just a little one. So: After installations (php.ini is correct see above ie.: extenstion = php_oci8.dll etc) 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] The order of the extensions listed in php.ini is causing problems... one must check that a particular extension A is enabled and above extension B if B requires A to be enabled. The original ordering doesnt make sure that this always happens (ie, A is above B) 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...

View more...

Comments

Copyright © 2017 DATENPDF Inc.