PHP: Instalace - Manual
PHP  
downloads | documentation | faq | getting help | mailing lists | | php.net sites | links | my php.net 
search for in the  
<Z�le�itosti datab�z�Sestavovac� (kompila�n�) probl�my>
view the version of this page
Last updated: Thu, 15 Jul 2004

Kapitola 50. Instalace

Tato ��st se zab�v� �ast�mi ot�zkamni ohledn� zp�sobu instalace PHP. PHP je dostupn� pro v�t�inu OS (v podstat� krom� MacOS p�e OSX) a v�t�inu webovsk�ch server�.

P�i instalaci PHP postupujte podle instrukc� v souboru v p��slu�n� distribuci. U�ivatel� Windows by si tak� m�li p�e��st soubor . Existuje tak� soubor s r�zn�mi fintami pro Windows - najdete ho tady.

1. Unix/Windows: Kde by m�l b�t ulo�en soubor php.ini?
2. UNIX: Nainstaloval jsem PHP, ale v�dy, kdy� na��t�m dokument, dostanu zpr�vu 'Document Contains No Data'! O co jde?
3. UNIX: Instaloval jsem PHP z bal��k� RPM, ale Apache nezpracov�v� str�nky s PHP! O co tu jde?
4. UNIX: Instaloval jsem PHP 3 z bal��k� RPM, ale nekompiluje se s podporou datab�ze, kterou pot�ebuji! O co tu jde?
5. UNIX: P�idal jsem do Apache patch pro FrontPage Extension a PHP n�hle p�estalo pracovat. Je PHP nekompatibiln� s FrontPage Extension pro Apache?
6. UNIX/Windows: Nainstaloval jsem PHP, ale p�i pokusu na��st soubor PHP skriptu do prohl�e�e se zobraz� pouze pr�zdn� obrazovka.
7. UNIX/Windows: Nainstaloval jsem PHP a kdy� chci na��st PHP soubor do prohl�e�e, objev� se "500 Internal Server Error".
8. N�kter� opera�n� syst�my: Nainstaloval jsem PHP bez chyb, ale nyn�, kdy� zkus�m spustit Apache, ohl�s� se chyby o nedefinovan�ch symbolech:
[mybox:user /src/php4] root# apachectl configtest
 apachectl: /usr/local/apache/bin/httpd Undefined symbols:
  _compress
  _uncompress
9. Windows: Nainstaloval jsem PHP, ale p�i na�ten� str�nky do prohl�e�e se zobraz� chyba:
cgi error:
 The specified CGI application misbehaved by not
 returning a complete set of HTTP headers.
 The headers it did return are:
10. Windows: Dodr�el jsem v�echny instrukce, ale PHP a IIS st�le odm�taj� spolupracovat!

1. Unix/Windows: Kde by m�l b�t ulo�en soubor php.ini?

V UNIXu m� b�t implicitn� v adres��i /usr/local/lib. Mnoho lid� to bude cht�t p�i kompilaci zm�nit pomoc� parametru --with-config-file-path. Mohli byste ho, nap��klad, nastavit zhruba takto:
--with-config-file-path=/etc
Pak byste zkop�rovali soubor php.ini-dist z distribuce do /etc/php.ini a upravili tak, jak chcete.

Pod Windows je soubor php.ini implicint� um�st�n v adres��i syst�mu Windows.

2. UNIX: Nainstaloval jsem PHP, ale v�dy, kdy� na��t�m dokument, dostanu zpr�vu 'Document Contains No Data'! O co jde?

Pravd�pobn� to znamen�, �e PHP m� n�jak� probl�m a pad�. Pod�vejte se do protokolu chyb, zda se jedn� o tento p��pad a pak zkuste probl�m reprodukovat mal�m testem. Pokud v�te, jak pou��vat 'gdb', velmi pom��e, kdy� m��ete s va��m hl�en�m chyby poskytnout v�pis (backtrace). V�voj��i tak mohou snadn�ji lokalizovat probl�m. Pou��v�te-li PHP jako modul do serveru Apache, zkuste n�co jako:

  • Zastavte httpd procesy

  • gdb httpd

  • Zastavte httpd procesy

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

  • Potom na�t�te do prohl�e�e URL, kde se vyskytl probl�m

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

  • Dostanete-li core dump (PHP spadne), gdb by v�s o tom m�l informovat

  • napi�te: bt

  • Z�skan� v�pis (backtrace) byste m�li p�ilo�it k hl�en� chyby. To by se m�lo poslat na

Pokud v� skript pou��v� funkce pro regul�rn� v�razy (ereg() a dal��), m�li byste se ujistit, �e jste zkompilovali PHP a Apache se stejn�m bal��kem pro regul�rn� v�razy. S PHP a Apachem 1.3.x by se to m�lo d�t automaticky.

3. UNIX: Instaloval jsem PHP z bal��k� RPM, ale Apache nezpracov�v� str�nky s PHP! O co tu jde?

Za p�edpokladu, �e se oboj�, jak Apache, tak PHP, instalovalo z bal��k� RPM, bude t�eba "odkomentovat" nebo p�idat do souboru http.conf n�kter� z n�sleduj�c�ch ��dk� (nebo v�echny):
# 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     /* pro PHP 3 */
LoadModule php4_module        modules/libphp4.so     /* pro PHP 4 */
LoadModule perl_module        modules/libperl.so
P�idejte tak�:
AddType application/x-httpd-php3 .php3    /* pro PHP 3 */
AddType application/x-httpd-php .php      /* pro PHP 4 */
... do glob�ln�ch vlastnost� nebo do vlastnost� virtu�ln� dom�ny (VirtualDomain) by se m�la p�idat podpora PHP.

4. UNIX: Instaloval jsem PHP 3 z bal��k� RPM, ale nekompiluje se s podporou datab�ze, kterou pot�ebuji! O co tu jde?

Kv�li tomu, jak se PHP 3 budovalo, nen� snadn� sestavit kompletn� flexibiln� RPM bal��ek s PHP. Probl�m je vy�e�en v PHP 4. Pro PHP 3 nyn� doporu�ujeme pou��vat mechanismus popsan� v souboru INSTALL.REDHAT v distribuci PHP. Pokud trv�te na pou�it� RPM verze PHP 3, �t�te d�l...

RPM pakova�e jsou nastaveny na tvorbu RPM bal��k� k instalaci bez podpory datab�z� kv�li zjednodu�en� instalac� a proto, �e RPM pou��v� adres�� /usr/ nam�sto standardn�ho /usr/local/. Mus�t sd�lit RPM souboru spec, kter� datab�ze podporovat a um�st�n� adres��e nejvy��� �rovn� datab�zov�ho serveru.

Tento p��klad vysv�tluje proces p�id�n� podpory popul�rn�ho datab�zov�ho serveru MySQL, pro instalaci PHP jako modulu do Apache.

V�echny tyto informace smaoz�ejm� mohou b�t upraveny pro libovoln� datab�zov� server, kter� PHP podporuje. Pro tento p��klad budeme p�edpokl�dat, �e jste instalovali MySQL a Apache pln� z bal��k� RPM.

  • Nejd��ve odstra�te mod_php3 :
    rpm -e mod_php3

  • Potom vezm�te zdrojov� bal��ek RPM a spus�te na n�m, NE --rebuild
    rpm -Uvh mod_php3-3.0.5-2.src.rpm

  • Upravte soubor /usr/src/redhat/SPECS/mod_php3.spec

    V sekci %build p�idejte datab�zovou podporu, kterou chcete, a nastavte cestu.

    Pro MySQL byste p�idali
    --with-mysql=/usr \
    Sekce %build bude vypadat p�ibli�n� takto:
    ./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

  • Pot�, co jsou provedeny tyto zm�ny, zkompilujte bal��ek takto:
    rpm -bb /usr/src/redhat/SPECS/mod_php3.spec

  • Potom bal��ek nainstalujte:
    rpm -ivh /usr/src/redhat/RPMS/i386/mod_php3-3.0.5-2.i386.rpm

Ujist�te se, �e jste restartovali Apache, a nyn� ji� m�te PHP 3 s podporou MySQL. Uv�domte si, �e je pravd�podobn� mnohem jednodu��� zkompilovat distribu�n� bal��ek tar a dr�et se instrukc� v souboru INSTALL.REDHAT z distribuce.

5. UNIX: P�idal jsem do Apache patch pro FrontPage Extension a PHP n�hle p�estalo pracovat. Je PHP nekompatibiln� s FrontPage Extension pro Apache?

Ne, PHP pracuje dob�e i s FrontPage Extension. Probl�m je v tom, �e FrontPage patch modifikuje n�kter� struktury Apache, na kter� PHP spol�h�. P�ekompilov�n� PHP (pou�it�m 'make clean ; make') po instalaci FP patche by m�lo probl�m vy�e�it.

6. UNIX/Windows: Nainstaloval jsem PHP, ale p�i pokusu na��st soubor PHP skriptu do prohl�e�e se zobraz� pouze pr�zdn� obrazovka.

V prohl�e�i vyberte funkci 'zobrazit zdrojov� k�d', nejsp� uvid�te zdrojov� k�d va�eho PHP skriptu. To znamen�, �e server nepos�l� skript k interpretaci. Chyba je n�kde v konfiguraci serveru - rad�ji dvakr�t zkontrolujte konfiguraci podle instrukc� k instalaci PHP.

7. UNIX/Windows: Nainstaloval jsem PHP a kdy� chci na��st PHP soubor do prohl�e�e, objev� se "500 Internal Server Error".

P�i pokusu spustit PHP do�lo k n�jak� chyb�. Abyste vid�li detailn�j�� chybovou zpr�vu, z p��kazov� ��dky, p�ejd�te do adres��e se souborem PHP (pod Windows php.exe) a spus�te php -i. Pokud p�i b�hu PHP dojde k chyb�, bude zobrazena odpov�daj�c� chybovou zpr�va, kter� v�m �ekne, co se m� d�l ud�lat. Pokud z�sk�te obrazovku plnou HTML k�du (v�stup funkce phpinfo()), pak PHP funguje a v� probl�m m��e souviset s konfigurac� serveru, kterou je pak t�eba dob�e zkontrolovat.

8. N�kter� opera�n� syst�my: Nainstaloval jsem PHP bez chyb, ale nyn�, kdy� zkus�m spustit Apache, ohl�s� se chyby o nedefinovan�ch symbolech:
[mybox:user /src/php4] root# apachectl configtest
 apachectl: /usr/local/apache/bin/httpd Undefined symbols:
  _compress
  _uncompress

To aktu�ln� nem� nic spole�n�ho s PHP, ale s knihovnami klienta MySQL. N�kter� pot�ebuj� --with-zlib, jin� nikoli. T�mto se zab�v� tak� MySQL FAQ.

9. Windows: Nainstaloval jsem PHP, ale p�i na�ten� str�nky do prohl�e�e se zobraz� chyba:
cgi error:
 The specified CGI application misbehaved by not
 returning a complete set of HTTP headers.
 The headers it did return are:

Tato chybov� zpr�va znamen�, �e z PHP nemohou vych�zet ��dn� data. Abyste vid�li detailn�j�� chybovou zpr�vu, z p��kazov� ��dky, p�ejd�te do adres��e se souborem PHP (pod Windows php.exe) a spus�te php -i. Pokud p�i b�hu PHP dojde k chyb�, bude zobrazena odpov�daj�c� chybovou zpr�va, kter� v�m �ekne, co se m� d�l ud�lat. Pokud z�sk�te obrazovku plnou HTML k�du (v�stup funkce phpinfo()), PHP funguje.

Jestli�e PHP pracuje v p��kazov� ��dce, zkuste to znovu z prohl�e�e. Pokud to st�le nefunguje, m��e to b�t jedn�m z t�chto d�vod�:

  • Nastaven� p��stupov�ch pr�v k souboru se skriptem, k php.exe, php4ts.dll, php.ini nebo n�jak�mu roz���en� PHP, kter� se pokou��te na��st, je takov�, �e k nim anonymn� internetov� u�ivatel ISUR_<machinename> nem� p��stup.

  • Soubor se skriptem neexistuje (nebo p��padn� nen� tam, kde si mysl�te, �e je, relativn� ke ko�enov�mu adres��i webu). Uv�domte si, �e na IIS m��ete tuto chybu zachytit za�krtnut�m volby 'check file exists' p�i nastavov�n� skriptov�ch slu�eb v Internet Services Manageru. Pokud skript neexistuje, server vr�t� chybu 404. Dal�� v�hodou je to, �e IIS provede na souboru se skriptem v�echny pot�ebn� autentikace zalo�en� NTLanMan.

10. Windows: Dodr�el jsem v�echny instrukce, ale PHP a IIS st�le odm�taj� spolupracovat!

Ujist�te se, �e ka�d� u�ivatel, kter� pot�ebuje spou�t�t PHP skripty m� pr�va pro spou�t�n� php.exe! IIS pou��v� anonymn�ho u�ivatele, kter� se p�id� p�i instalaci IIS. Tento u�ivatel pot�ebuje pr�va k php.exe. Tak� ka�d� autentikovan� u�ivatel bude pot�ebovat pr�va na spou�t�n� php.exe. A IIS4 mus�te sd�lit, �e PHP je skriptovac� engine.



add a note add a note User Contributed Notes
Instalace
furrycod at hotmail dot com
07-Sep-2004 04:35
Great WAMP 1.4.4 (Apache 1.*, MySql 4.*, PHP 4.*) installation article at

This article details how to install these onto a USB stick--which means changing *nothing* on the host PC, such as registry entries, environment variables, files in the Windows path, NT services, ini files, etc.

The USB stick install seems awkward, but I installed WAMP to my harddrive using this article as a guide (essentially replacing E:\ with C:\), and it works fine.  No more trying to decide where the *real* php.ini or my.ini file is that needs to be changed.
18-Aug-2004 01:10
if your php scripts are under folder c:\inetpub\wwwroot, then you must change the doc_root in php.ini to "c:\inetpub\wwwroot" instead of "c:\inetpub" as in installation manual.
masternuthin diespammer at yahoo dot com
23-Jun-2004 10:33
PHP 4.3.7.7 and IIS 6 (w2k3 standard)

Followed note from nigel dot salt at hotmail dot com
but had to modify "Script Map" to "ScriptMap"

Also, had to follow note from jimo at mail dot azhsv dot com

after all that - it worked.
jeff_graham at datacenterservices dot net
01-Feb-2004 09:51
As stated within the note "jimo at mail dot azhsv dot com
29-Nov-2003 04:33
PHP 4 and IIS 6.0 (Windows Server 2003)," I found the same steps were requiered for installation of PhP 5 beta 3 on my Windows 2003 server (Standard Edition)
nigel dot salt at hotmail dot com
14-Dec-2003 01:00
Finally got IIS 5 and PHP 5 to talk. 

What worked for me was:

1) Set
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\
W3SVC\Parameters\Script Map]
".php"="your path to php\\php.exe"

2) ensure there is not a php.ini in the windows system folder and that there is one wherever you've put PHP

3) edit php.ini and set cgi force redirect to 0 and cgi.rfc2616_headers = 1

4) Put the PHP scripts in their own folder underneath the inetpub root

5) Open the IIS console, right click your new php folder
In the Directory tab
 set application name to the name of the folder
 set executable and script as permission
 set application protection to low
Click configuration and check that .php is mapped to wherever you put
PHP

Restart IIS

Try a very simple PHP page and it should work

Nigel
jimo at mail dot azhsv dot com
30-Nov-2003 03:33
PHP 4 and IIS 6.0 (Windows Server 2003)

Had difficulty getting PHP 4.3.3 to work with Win2003 Ent Server for use with SquirrelMail.  Problem found and believed solved.  Appears to be something New with IIS 6.0 (More security by Micro$oft)  Was getting 404 error and php was not being run as a cgi even though it was in extensions and IIS user had rights to execute it. (php from command line operated correctly)

If you are installing on Windows Server 2003 (only have Enterprise Edition � Not sure if this applies to standard edition), and you have done the normal procedures for inclusion of PHP scripts (either ISAPI or CGI) in IIS, you will still get a 404 error when attempting to execute those scripts even though IIS has rights and the extension points to the correct file.  To alleviate this problem, perform the following:

1.    Open a command prompt window
2.    Change to C:\windows\system32
3.    Execute the command:  cscript  iisext.vbs /AddFile c:\php\php.exe 1 php 0 php
4.    Execute the command:  cscript iisext.vbs /EnFile c:\php\php.exe
5.    To check for correct execution of the above,
6.    Execute the command:  cscript IisExt.vbs /ListFile � the php extension should be listed

If you try just step 4 without step 3 you get an error that the file is not in the list (and won�t be there till you do step 3 above)

After this, IIS seems to like the php extension and work normally.

For additional reference, see the below 3 Micro$oft KB Articles:
HOWTO: Enable and Disable ISAPI Extensions and CGI Applications in IIS 6.0 (MS KB Article 328360)

HOWTO List Web Server Extensions and Extension Files in IIS 6.0 (MS KB Article 328505)

HOWTO Add and Remove Web Service Extension Files in IIS 6.0 (MS KB Article 328419)
peter dot mosinskisNOSPAM at csuci dot edu
06-Mar-2003 08: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
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
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.
tanis22 at hotmail dot com
13-Nov-2001 07: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
rggonzalez at iname dot com
10-Nov-2000 01: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]
fischer_dj at mailcity dot com
24-Aug-2000 04:29
I've added detailed PWS, Perl, & PHP4 installation instructions for Win98 at FAQts.


<Z�le�itosti datab�z�Sestavovac� (kompila�n�) probl�my>
 Last updated: Thu, 15 Jul 2004
show source | credits | sitemap | contact | advertising | mirror sites 
Copyright © 2001-2004 The PHP Group
All rights reserved.
This unofficial mirror is operated at: /
Last updated: Sun Nov 14 23:09:54 2004 Local time zone must be set--see zic manual page