PHP  
downloads | documentation | faq | getting help | mailing lists | | php.net sites | links 
search for in the  
previousDatabase issuesBuild Problemsnext
Last updated: Tue, 09 Jul 2002
view the printer friendly version or the printer friendly version with notes or change language to English | Brazilian Portuguese | Chinese | Czech | Dutch | Finnish | German | Hungarian | Italian | Japanese | Korean | Polish | Romanian | Russian | Spanish | Swedish | Turkish

Chapitre 48. Installation

This section holds common questions about the way to install PHP. PHP is available for almost any OS (except maybe for MacOS before OSX), and almost any web server.

To install PHP, follow the instructions in the file located in the distribution. Windows users should also read the file. There are also some helpful hints for Windows users here.

1. Unix/Windows: Where should my php.ini file be located?
2. Unix: I installed PHP, but every time I load a document, I get the message 'Document Contains No Data'! What's going on here?
3. Unix: I installed PHP using RPMS, but Apache isn't processing the PHP pages! What's going on here?
4. Unix: I installed PHP 3 using RPMS, but it doesn't compile with the database support I need! What's going on here?
5. Unix: I patched Apache with the FrontPage extensions patch, and suddenly PHP stopped working. Is PHP incompatible with the Apache FrontPage extensions?
6. Unix/Windows: I have installed PHP, but when I try to access a PHP script file via my browser, I get a blank screen.
7. Unix/Windows: I have installed PHP, but when try to access a PHP script file via my browser, I get a server 500 error.
8. Some operating systems: I have installed PHP without errors, but when I try to start apache I get undefined symbol errors:
[mybox:user /src/php4] root# apachectl configtest
 apachectl: /usr/local/apache/bin/httpd Undefined symbols:
  _compress
  _uncompress
9. Windows: I have installed PHP, but when I to access a PHP script file via my browser, I get the error:
cgi error:
 The specified CGI application misbehaved by not
 returning a complete set of HTTP headers.
 The headers it did return are:
10. Windows: I've followed all the instructions, but still can't get PHP and IIS to work together!

1. Unix/Windows: Where should my php.ini file be located?

By default on UNIX it should be in /usr/local/lib which is <install-path>/lib. Most people will want to change this at compile-time with the --with-config-file-path flag. You would, for example, set it with something like:

--with-config-file-path=/etc
And then you would copy php.ini-dist from the distribution to /etc/php.ini and edit it to make any local changes you want.

On Windows the default path for the php.ini file is the Windows directory. If you're using the Apache webserver, php.ini is first searched in the Apaches install directory, e.g. c:\program files\apache group\apache. This way you can have different php.ini files for different versions of Apache on the same machine.

See also the chapter about the configuration file.

2. Unix: I installed PHP, but every time I load a document, I get the message 'Document Contains No Data'! What's going on here?

This probably means that PHP is having some sort of problem and is core-dumping. Look in your server error log to see if this is the case, and then try to reproduce the problem with a small test case. If you know how to use 'gdb', it is very helpful when you can provide a backtrace with your bug report to help the developers pinpoint the problem. If you are using PHP as an Apache module try something like:

  • Stop your httpd processes

  • gdb httpd

  • Stop your httpd processes

  • > run -X -f /path/to/httpd.conf

  • Then fetch the URL causing the problem with your browser

  • > run -X -f /path/to/httpd.conf

  • If you are getting a core dump, gdb should inform you of this now

  • type: bt

  • You should include your backtrace in your bug report. This should be submitted to

If your script uses the regular expression functions (ereg() and friends), you should make sure that you compiled PHP and Apache with the same regular expression package. This should happen automatically with PHP and Apache 1.3.x

3. Unix: I installed PHP using RPMS, but Apache isn't processing the PHP pages! What's going on here?

Assuming you installed both Apache and PHP from RPM packages, you need to uncomment or add some or all of the following lines in your http.conf file:

# Extra Modules
AddModule mod_php.c
AddModule mod_php3.c
AddModule mod_perl.c

# Extra Modules
LoadModule php_module         modules/mod_php.so
LoadModule php3_module        modules/libphp3.so     /* for PHP 3 */
LoadModule php4_module        modules/libphp4.so     /* for PHP 4 */
LoadModule perl_module        modules/libperl.so
And add:
AddType application/x-httpd-php3 .php3    /* for PHP 3 */
AddType application/x-httpd-php .php      /* for PHP 4 */
... to the global properties, or to the properties of the VirtualDomain you want to have PHP support added to.

4. Unix: I installed PHP 3 using RPMS, but it doesn't compile with the database support I need! What's going on here?

Due to the way PHP 3 built, it is not easy to build a complete flexible PHP RPM. This issue is addressed in PHP 4. For PHP 3, we currently suggest you use the mechanism described in the INSTALL.REDHAT file in the PHP distribution. If you insist on using an RPM version of PHP 3, read on...

The RPM packagers are setting up the RPMS to install without database support to simplify installations and because RPMS use /usr/ instead of the standard /usr/local/ directory for files. You need to tell the RPM spec file which databases to support and the location of the top-level of your database server.

This example will explain the process of adding support for the popular MySQL database server, using the mod installation for Apache.

Of course all of this information can be adjusted for any database server that PHP supports. We will assume you installed MySQL and Apache completely with RPMS for this example as well.

  • First remove mod_php3 :

    rpm -e mod_php3

  • Then get the source rpm and INSTALL it, NOT --rebuild

    rpm -Uvh mod_php3-3.0.5-2.src.rpm

  • Then edit the /usr/src/redhat/SPECS/mod_php3.spec file

    In the %build section add the database support you want, and the path.

    For MySQL you would add

    --with-mysql=/usr \
    The %build section will look something like this:
    ./configure --prefix=/usr \
    	--with-apxs=/usr/sbin/apxs \
    	--with-config-file-path=/usr/lib \
    	--enable-debug=no \
    	--enable-safe-mode \
    	--with-exec-dir=/usr/bin \
    	--with-mysql=/usr \
    	--with-system-regex

  • Once this modification is made then build the binary rpm as follows:

    rpm -bb /usr/src/redhat/SPECS/mod_php3.spec

  • Then install the rpm

    rpm -ivh /usr/src/redhat/RPMS/i386/mod_php3-3.0.5-2.i386.rpm

Make sure you restart Apache, and you now have PHP 3 with MySQL support using RPM's. Note that it is probably much easier to just build from the distribution tarball of PHP 3 and follow the instructions in INSTALL.REDHAT found in that distribution.

5. Unix: I patched Apache with the FrontPage extensions patch, and suddenly PHP stopped working. Is PHP incompatible with the Apache FrontPage extensions?

No, PHP works fine with the FrontPage extensions. The problem is that the FrontPage patch modifies several Apache structures, that PHP relies on. Recompiling PHP (using 'make clean ; make') after the FP patch is applied would solve the problem.

6. Unix/Windows: I have installed PHP, but when I try to access a PHP script file via my browser, I get a blank screen.

Do a 'view source' in the web browser and you will probably find that you can see the source code of your PHP script. This means that the web server did not send the script to PHP for interpretation. Something is wrong with the server configuration - double check the server configuration against the PHP installation instructions.

7. Unix/Windows: I have installed PHP, but when try to access a PHP script file via my browser, I get a server 500 error.

Something went wrong when the server tried to run PHP. To get to see a sensible error message, from the command line, change to the directory containing the PHP executable (php.exe on Windows) and run php -i. If PHP has any problems running, then a suitable error message will be displayed which will give you a clue as to what needs to be done next. If you get a screen full of html codes (the output of the phpinfo() function) then PHP is working, and your problem may be related to your server configuration which you should double check.

8. Some operating systems: I have installed PHP without errors, but when I try to start apache I get undefined symbol errors:

[mybox:user /src/php4] root# apachectl configtest
 apachectl: /usr/local/apache/bin/httpd Undefined symbols:
  _compress
  _uncompress

This has actually nothing to do with PHP, but with the MySQL client libraries. Some need --with-zlib, others do not. This is also covered in the MySQL FAQ.

9. Windows: I have installed PHP, but when I to access a PHP script file via my browser, I get the error:

cgi error:
 The specified CGI application misbehaved by not
 returning a complete set of HTTP headers.
 The headers it did return are:

This error message means that PHP failed to output anything at all. To get to see a sensible error message, from the command line, change to the directory containing the PHP executable (php.exe on Windows) and run php -i. If PHP has any problems running, then a suitable error message will be displayed which will give you a clue as to what needs to be done next. If you get a screen full of html codes (the output of the phpinfo() function) then PHP is working.

Once PHP is working at the command line, try accessing the script via the browser again. If it still fails then it could be one of the following:

  • File permissions on your PHP script, php.exe, php4ts.dll, php.ini or any PHP extensions you are trying to load are such that the anonymous internet user ISUR_<machinename> cannot access them.

  • The script file does not exist (or possibly isn't where you think it is relative to your web root directory). Note that for IIS you can trap this error by ticking the 'check file exists' box when setting up the script mappings in the Internet Services Manager. If a script file does not exist then the server will return a 404 error instead. There is also the additional benefit that IIS will do any authentication required for you based on the NTLanMan permissions on your script file.

10. Windows: I've followed all the instructions, but still can't get PHP and IIS to work together!

Make sure any user who needs to run a PHP script has the rights to run php.exe! IIS uses an anonymous user which is added at the time IIS is installed. This user needs rights to php.exe. Also, any authenticated user will also need rights to execute php.exe. And for IIS4 you need to tell it that PHP is a script engine.

User Contributed Notes
Installation
add a note about notes
[email protected]
01-Dec-1999 10:49

An "Invalid URI in request GET /test.php3 HTTP/1.0" may be triggered when you specify a drive letter in the

Action application/x-httpd-php3 "d:/php.exe"

You may circumvent this bug by specifying a ScriptAlias /php/ d:/php/


and later referencing the alias in the httpd.conf file as

Action application/x-httpd-php3 /php/php.exe


If you still run into errors, perhaps more conclusive suggestions are available at
<Br>
" Request Error ( HTTP 400 ) Troubleshooting

[email protected]
26-Jan-2000 10:26

Re: win2k...

Make sure the following is true:

1) That the directory has Script & Execute permission in IIS' admin

2) ISUSER_<machinename> has Read and Execute permissions

3) the Everybody group has execute(but not write) permissions in the file system (Windows Explorer)


I had similar problems with plain ol' perl scripts, made those changes and all worked well. (using Windows 2000 Server RTM version)


I havent installed PHP on that box, as I am using Linux for PHP work, but it should help ...

[email protected]
29-Jun-2000 04:35

I got errors involving the GD library, such as function being declared twice. I had the 1.8.2 version of GD installed (the one that has no GIF support, only PNG) in a seperate dir than the standard 1.3-6 that comes with redhat, and it was trying to link with those. So i deleted the 1.8.2 version, dumped config.cache, reran config, recompiled and all that and it worked. Just a note if anyone has that problem.
[email protected]
05-Aug-2000 02:18

Just a reflection of my PHP4 install process in RedHat 6.2 (hopefully somebody with my level of experience will find this useful):



Configure couldn't find apxs. This is because RedHat didn't install it as part of the server option install. Go figure. The solution to a missing apxs script is to install the apache-devel-1.3.12-2.i386.rpm from your RedHat 6.2 install CD, which will put apxs in the right spot with the right parameters inside.



Another problem I had was that since I'd upgraded PostgreSQL, and was trying to compile PHP4 with PostgreSQL support, Apache couldn't find /usr/local/pgsql/lib/libpq.so.2.1 (needed to load modules/libphp4.so with PostgreSQL support) and so wouldn't start (when I did ./httpd restart in /etc/rc.d/init.d). The answer was to add /usr/local/pgsql/lib to the list of places that library files are kept, in the file /etc/ld.so.conf, and then run ldconfig -v to update the list of libraries.



Then, of course (in RedHat 6.2), cd /etc/rc.d/init.d and then do ./httpd restart .



For me, the rest is smooth sailing. Except for the SQL errors.



Note that this advice is from a somewhat newbie (to Linux, PHP and PostgreSQL) perspective, so your mileage may vary. Exercise extreme caution.


[email protected]
24-Aug-2000 03:29

I've added detailed PWS, Perl, & PHP4 installation instructions for Win98 at FAQts.


[email protected]
21-Sep-2000 11:41

Hi all,

If you are looking for PHP 4 RPMs, just have a look at .

Troels does a fantastic job and maintains the RPMs that are updated regularly.

These RPMs provide plug-n-play installation for users of up-to-date Red Hat Linux systems.

Enjoy !

[email protected]
13-Oct-2000 11:26

After running these steps, you can type the following to see where httpd is running from:

ps fax | grep "httpd"

Mine was /var/lib/apache/sbin/httpd while I was compiling to /var/lib/apache_1.13.14/src/httpd. I think it ultimately ended up in /usr/local/apache/bin/httpd.

In the FAQ, if you haven't gotten there yet, it says you can also run the following to see if php is installed:

/path/to/httpd -l

You should see mod_php4.c in the list. If you don't, run the install instructions above AGAIN. I had to do this 7 or 8 times. Maybe I'm just tired today...

[email protected]
09-Nov-2000 11:40

Notes on installing PHP (3.x.x or 4.x.x) on a RedHat 6.x Linux box using glibc 2.1.x. When you install it as a DSO module for Apache (--with-apxs) with the standard RPM's from RedHat for Apache and MySQL, the httpd daemon dies without giving any error message, and without sending any message to the console.

From a comment by Rasmus Ledorf: this is caused "probably due to a glibc-2.1.x bug related to dynamically loading a library
linked against pthreads into a binary that isn't linked against
pthreads. Try it using --without-mysql and see if it works. If it does
then you know it is a mysql-related problem. To fix it you will need the
non-threaded mysql client rpm available from www.mysql.com".

You can also download the source code for MySQL and recompiled it statically, using this configuration options:

--with-client-ldflags=-all-static
--with-mysqld-ldflags=-all-static

You must then re-run the ./configure; make; make install in your PHP source tree to get the PHP shared module working with the new MySQL support.

Regards,
Rodolfo Gonzalez.
[email protected]

[email protected]
19-Dec-2000 05:14

There seems to be little or no information on how to build the php binary (specifically in Linux) - it's useful for CGI and shell scripting.

What you need to do is to run:

./configure --without-apache --without-apxs --with-other-options

It will tell you that as you are building it without Apache support, it is building it as a CGI binary.

Then do make ; make install and it should then be installed (/usr/local/bin/php by default)

[email protected]
02-Oct-2001 12:06

Regarding MacOS availability, Tenon Intersystems has a nice product called "WebTen" that runs under MacOS (7-9) in what they call a "UNIX Virtual Machine" and allows a quite nice implementation of Apache and PHP under MacOS's prior to OS X.



[email protected]
13-Nov-2001 05:01

I figured out why i get this error with just a virtual directory and not the root:

8. Windows: I have installed PHP, but when I to access a PHP script file via my browser, I get the error: cgi error:
The specified CGI application misbehaved by not
returning a complete set of HTTP headers.
The headers it did return are:
---------------------
Look at the php.ini file and look for

doc_root =

set it to nothing so that it does not only look for that directory. I hope it helps people with IIS and PHP

[email protected]
16-Jan-2002 08:43

Just to let others know, I was having a problem with PHP 4.1.1 on WinXP with Apache 1.3.22 as a module. Every time I wanted to load a .php file it was giving me a save-as dialog box. What fixed it for me (and wasn't in any documentation I could find) was adding an additional line in the Apache conf file after loading it as a module. The line should fall under AddModule category, like so:

AddModule mod_php4.c

Hope that help others having similar problems.

[email protected]
21-Jan-2002 07:21

A good place to go for a nice easy to follow tutorial on setting up PHP under Windows is

Have fun... Dion

[email protected]
25-Jan-2002 05:25

go to..


tracy [email protected]
15-Mar-2002 04:02

the --with-mysql= /path/to/mysql
as my own experience, the "/path/to/mysql" should be the path which include the "./lib" and "./include" sub directory.

i configure the php v4 in my freebsd 4.5 box. use the following shell command:
./configure --with-imap --with-gettext --with-apxs=/usr/local/apache/bin/apxs --with-dbf --with-mysql=/usr/local
(where "/usr/local" have sub-dir "/usr/local/lib" and "/usr/local/include")
just for your reference, Dont just copy ^_^

[email protected]
17-Apr-2002 10:46

On windows 2000 installation I've had PHP simply hanging when running a PHP script.

To see exactly what is going wrong with PHP in the context of the IUSR_MACHINENAME account create a shortcut on your desktop to point to cmd.exe.

Right click on the shortcut, and select properties.

Then check the 'run as a different user' checkbox of the property pages of the shortcut.

Double click then shortcut, and you will be prompted for a user account to run the cmd.exe shell under.

Enter IUSR_MACHINENAME (replace machine name with the machine name of your system), and enter the password for the account.

If you don't know the password for the IUSR account you might need to go change it in Administrative Tools->Computer Management.

Enter the password, and you will be dropped into a command prompt.

Now run c:\php\php.exe -i and see if you can catch any error messages.

On my system it had a problem accessing c:\winnt\system32\browscap.ini which I was then able to sort out.

Running PHP as the Administrator user didn't give this problem, so being able to impersonate the IIS account was a very useful diagnostic tool.

[email protected]
29-Apr-2002 07:07

Perhaps this will save someone the hours that it cost me to figure out how to go from a CGI version of PHP (through 4.2) to a module version on Apache 2 for Win2K:

I've had a CGI versions of PHP 4 through several releases of Apache and the setup for that is really easy (assuming they both individually work):

0. Review php.ini (engine = On, et. al)
1. Move php4ts.dll into appropriate windows subdirectory (for me it's System32).

The remaining 4 items are changes/additions to Apache's httpd.conf file:
2. Put index.php as the first argument to DirectoryIndex if you want Apache to automatically pick up index.php files

Now add the following 3 lines:
3. AddType application/x-httpd-php .php
4. Action application/x-httpd-php "/php4/php.exe"
5. ScriptAlias /php4/ "c:/winapps/php/4.2/sapi/"

3 is so Apache will know .php files are special. 4 is so Apache will know what special program to run when it realizes it has a (.php) special file. 5 is so that Apache will know what directory that special program (php.exe) lives in.

To go from the CGI to the Module version should be even simpler, right? But there is a HUGE gotcha. It's one of those You can't get there from here syndromes if you are using Apache 2.0.28 (or earlier, I presume). I needed to upgrade to 2.0.35 so that the required php (4.2) provided apache2filter.dll file would work with Apache2.

So the final steps are as follows:
Do steps 0-3 as written above.
If you are upgrading, not installing, then back out steps 4 and 5 from above.
4) Add a line to the httpd.conf file:
LoadModule php4_module c:/winapps/php/4.2/experimental/apache2filter.dll
NOTE that this is not the php4apache.dll file of yore in the sapi directory (which I presume would work if you were doing this with Apache 1.3.x)

[email protected]
03-May-2002 03:39

The online documentation fails to mention that extension can be built shared. i.e. --with-EXTENSION=shared,[<DIR>]. In particular, mySql (on redhat), would only configure, compile and load (into Apache) correctly when I specified --with-mysql=shared,/usr.

The only documentation I found on using shared was in the "configure" file itself.

[email protected]
18-May-2002 04:32

INSTALLATION ON OPENBSD 3.1 VIA PORTS COLLECTION
Would have succeed but no mysql support.
I commented out the FLAVORS+= dbase filepro mysql mysql_bundled postgresql iodbc in the /usr/ports/www/php4/Makefile and in the configure options added
--with-mysql=/usr/local and it worked.

Good Luck

[email protected]
24-May-2002 10:30

-= Apache 1.3.24 [Win32] with PHP 4.2.1 =-

-- 500 Internal Server Error --

Okay.. this goes out to the ID Ten T users.. if you have done everything correctly (following instructions) and are having trouble running php from the ../cgi-bin/ directory... remove it from the /cgi-bin/ directory.. php can be run from anywhere in your ../htdocs directory!!

If for some reason you do want a script in that directory badly, then you will have to configure your Apache config file differently for cgi options.

[email protected]
31-May-2002 08:46

Several users that tried to install PHP4 under Windows with the servers Apache, PWS or Xitami receives this message when trying to open a php script file:

"Security Alert! PHP CGI cannot be accessed directly.
This PHP CGI binary was compiled with force-cgi-redirect enabled. This means that a page will only be served up if the REDIRECT_STATUS CGI variable is set. This variable is set, for example, by Apache's Action directive redirect.

You may disable this restriction by recompiling the PHP binary with the --disable-force-cgi-redirect switch. If you do this and you have your PHP CGI binary accessible somewhere in your web tree, people will be able to circumvent .htaccess security by loading files through the PHP parser. A good way around this is to define doc_root in your php.ini file to something other than your top-level DOCUMENT_ROOT. This way you can separate the part of your web space which uses PHP from the normal part using .htaccess security. If you do not have any .htaccess restrictions anywhere on your site you can leave doc_root undefined. If you are running IIS, you may safely set cgi.force_redirect=0 in php.ini."

I warned it to the PHP-DOC list and nobody knew how to help me. But once somebody from there said me to try to set the Apache Server not to run PHP as a script, or something like that. I just know that the unique lines that I had to put in the httpd.conf of Apache was:

AddType application/x-httpd-php .php

ScriptAlias /php/ "c:/arquivos de programas/php/"
AddType application/x-httpd-php .php
Action application/x-httpd-php "/php/php.exe"

And it worked! But I couldn't resolve this problem with PWS or Xitami. And now I want to run it with Xitami. Can anybody help me? If so, please send me an e-mail: [email protected]
Thanks a lot...

[email protected]
29-Jun-2002 04:28

Q: With the new (php 4.2.0) version of PHP we couldn't pass
form/query string etc., variables from one file to the other.(eg: form
submissions). Do we need to set any variables in PHP.ini or some where to
enable such behaviour for this PHP version. Any clues to solve this issue
will be highly appreciated.

A: you should turn on the register_globals variable in php.ini

This however seems to create some security risks.. The docs say you should use the $HTTP_*_VARS[], wich i couldn't figure out since I couldn't find any documentation about this.

You could also use cookies or a DB to store the values ofcourse.....

[email protected]
11-Jul-2002 06:17

To get PHP to work under PWS when you get the error message about security, you need to add the line <b>cgi.force_redirect=0</b> to the top of your php.ini file right below [php].
[email protected]
26-Aug-2002 05:26

Very good PHP and MySQL installation guide in Windows and Linux system.

For those who has problem with IIS and PHP installation like I did, just go to


this article also include MySQL installation on Windows and Linux system.

I just follow his SIMPLE and DETAIL step by step guide.. then very things working in 5 minutes...

add a note about notes
previousDatabase issuesBuild Problemsnext
Last updated: Tue, 09 Jul 2002
show source | credits | stats | mirror sites
Copyright © 2001, 2002 The PHP Group
All rights reserved.
This mirror generously provided by:
Last updated: Thu Aug 29 20:06:18 2002 CEST