PHP  
downloads | documentation | faq | getting help | mailing lists | | php.net sites | links | my php.net 
search for in the  
<Database issuesProbleme bei der Compilierung>
view the version of this page
Last updated: Sat, 19 Apr 2003

Kapitel 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!
11. When running PHP as CGI with IIS, PWS, OmniHTTPD or Xitami, I get the following error: Security Alert! PHP CGI cannot be accessed directly..
12. How do I know if my php.ini is being found and read? It seems like it isn't as my changes aren't being implemented.

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.

--with-config-file-scan-dir=PATH

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 httpd.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. Also, you will want to read this faq.

11. When running PHP as CGI with IIS, PWS, OmniHTTPD or Xitami, I get the following error: Security Alert! PHP CGI cannot be accessed directly..

You must set the cgi.force_redirect directive to 0. It defaults to 1 so be sure the directive isn't commented out (with a ;). Like all directives, this is set in php.ini

Because the default is 1, it's critical that you're 100% sure that the correct php.ini file is being read. Read this faq for details.

12. How do I know if my php.ini is being found and read? It seems like it isn't as my changes aren't being implemented.

To be sure your php.ini is being read by PHP, make a call to phpinfo() and near the top will be a listing called Configuration File (php.ini). This will tell you where PHP is looking for php.ini and whether or not it's being read. If just a directory PATH exists than it's not being read and you should put your php.ini in that directory. If php.ini is included within the PATH than it is being read.

If php.ini is being read and you're running PHP as a module then be sure to restart PHP after making changes to php.ini



User Contributed Notes
Installation
add a note
dauriaa at cmu dot edu
01-Dec-1999 11: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

nate at desert-solutions dot com
29-Jun-2000 05: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.
fischer_dj at mailcity dot com
24-Aug-2000 04:29

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


joel at joelryan dot com
14-Oct-2000 12: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...

rggonzalez at iname dot com
10-Nov-2000 12: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]

tanis22 at hotmail dot com
13-Nov-2001 06: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

anonymoose at hotmail dot com
16-Jan-2002 09: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.

dion at iimp dot net
21-Jan-2002 08:21

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

Have fun... Dion

tracy lam at null dot com
15-Mar-2002 05: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 ^_^

rodent at mighty dot co dot za
17-Apr-2002 11: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.

mikes at in-tune dot com
03-May-2002 04: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.

monroe at peoplego dot com
18-May-2002 05: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

sangapum at hotmail dot com
24-May-2002 11: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.

thalescm at uol dot com dot br
31-May-2002 09: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...

jwchong77 at yahoo dot com
26-Aug-2002 06: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...

wubbe dot gelling at johnson-pump dot com
19-Feb-2003 08:33

The most important issue to get php (4.3.x) working with IIS (5.1) is to set your php.ini file correctly. After a default installation of the latest win32 php package just edit the following lines in php.ini (working and reproduced under WinXP):

;cgi.force_redirect = 1
error_reporting  =  E_ALL
register_globals = Off

To:

cgi.force_redirect = 0
error_reporting = E_ALL & ~E_NOTICE
register_globals = On

For this solution no single .dll file has to be moved!

peter dot mosinskisNOSPAM at csuci dot edu
06-Mar-2003 07:36

Running Win2K AS + IIS5.0 + PHP 4.3.1, I ran into a nasty problem that I mistakenly thought had to do with something in the php.ini configuration. When I would try to submit a form using the HTTP method GET it would work, but I would get a "404 Page Not Found" error using the POST method.

All my permissions were set correctly, the php.ini was configured correctly. It had to do with URLScan being installed on IIS (see below)

Page 404 File Not Found Error When Using POST method in PHP (and Perl, and otherwise)
-------------------------------------------

This is related to the Microsoft URLScan utility. If you have this problem, the IIS administrator has probably run the IIS Lockdown tool as well as configured URLScan to reject this type of HTTP method when sent in a URL. These tools are meant to enhance web server security.

URLScan configuration files can be found in the \WINNT\system32\inetsrv\urlscan folder on the web server. Specifically, the file to modify is urlscan.ini.

The changes to make are as follows:
1. Make sure UseAllowVerbs=1 under [options]
2. Under the [AllowVerbs] section, list your allowed HTTP methods to include:
   GET
   POST

For more information on the IIS Lockdown tool and URLScan, visit

Jason Klein / Datility Networks
06-Apr-2003 07:07

Windows 2000 + Apache 1.3.27 + PHP 4.3.1 win32

I was receiving the console output below after adding php specific configuration lines to the apache httpd.conf file.  

c:\devel\httpd\Apache\>apache -w -n "Apache" -k restart
[warn] module mod_php4.c is already added, skipping
The Apache service is restarting
The Apache service has restarted
[error] Cannot remove module mod_php4.c: not found in module list

The following lines had been added immediately after the last existing "LoadModule" line in the apache httpd.conf file.

LoadModule php4_module /devel/php/sapi/php4apache.dll
AddType application/x-httpd-php .php
AddModule mod_php4.c

To resolve issue, I moved the php "AddModule" line immediately after the last existing "AddModule" line.  It seems that this line must be added after the "ClearModuleList" line.

I also noticed that if I add the "LoadModule" and "AddType" lines to the VERY END of the httpd.conf file, the "AddModule" line is not necessary at all.

Our developer seemed to have no problems after that. Hopes this helps someone else!

add a note

<Database issuesProbleme bei der Compilierung>
 Last updated: Sat, 19 Apr 2003
show source | credits | mirror sites 
Copyright © 2001-2003 The PHP Group
All rights reserved.
This mirror generously provided by: /
Last updated: Mon May 12 21:12:21 2003 CEST