downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

Servidores Sun, iPlanet e Netscape no Microsoft Windows> <Apache 1.3.x no Microsoft Windows
Last updated: Fri, 13 Nov 2009

view this page in

Apache 2.0.x no Microsoft Windows

Essa seção contem notas e dicas específicas para instalação do Apache 2.0.x com o PHP nos sistemas Microsoft Windows.Também há instruções e notas para o Apache 1.3.x em uma página separada.

Nota: Por favor, leia os passos da instalação manual primeiro!

Nota: Suporte a Apache 2.2.x
Usuários do Apache 2.2.x devem usar a documentação abaixo exceto que o nome do arquivo da dll apropriada é php5apache2_2.dll e lea só existe a partir do 5.2.0. Veja também » http://snaps.php.net/

Aviso

Nós não recomendamos a utilização de um threaded MPM em produção com o Apache2. Use ao invés prefork MPM, ou use Apache1. para informações sobre o motivo, leia este faq sobre usando Apache2 com um threaded MPM

Encorajamos que você olhe a » Documentação do Apache para entender o básico do Servidor Apache 2.0.x. Também considere ler as » notas específicas para o Windows para o Apache 2.0.x antes de continuar.

Nota: Notas de compatibilidade do PHP e Apache 2.0.x
As seguintes versões do PHP são compatíveis com a versão mais recente do Apache 2.0.x:

Essas versões do PHP são compatíveis com Apache 2.0.40 ou superior.
Suporte a SAPI do Apache 2.0 começou no PHP 4.2.0. PHP 4.2.3 funciona com Apache 2.0.39, não use qualquer outra versão de Apache com PHP 4.2.3. No entando, a configuração recomendada é usar o 4.3.0 ou superior com a versão mais recente do Apache2.
Todas as versões mencionadas do PHP ainda funcionarão com Apache 1.3.x.

Aviso

Apache 2.0.x foi desenhado para rodar no Windows NT 4.0, Windows 2000 ou Windows XP. Até o momento, suporte para Windows 9x está incompleto. Apache 2.0.x não tem planos para funcionar nessas plataformas.

Baixe a versão mais recente do » Apache 2.0.x e uma versão apropriada do PHP. Siga os Passos da Instalação Manual e volte para continuar com a integração do PHP e Apache.

Existem duas maneiras de configurar o PHP para funcionar com Apache 2.0.x no Windows. Uma é usar o binário CGI e a outra é usar o DLL do módulo do Apache. Em ambos os casos você precisa editar o arquivo httpd.conf para configurar o Apache para funcionar com o PHP e, então, reiniciar o servidor.

Nota: Lembre-se que quando acrescentando valores de caminhos nos arquivos de configuração do Apache para Windows, todas as contrabarras como em c:\directory\file.ext precisam ser convertidas para barras, como em c:/directory/file.ext. Uma barra ao final também é necessária para diretórios.

Instalando como um binário CGI

Você precisa inserir essas três linhas para o arquivo httpd.conf de configuração do Apache para configura o binário CGI:

Exemplo #1 PHP e Apache 2.0 como CGI

ScriptAlias /php/ "c:/php/"
AddType application/x-httpd-php .php

# Para o PHP 4
Action application/x-httpd-php "/php/php.exe"

# Para o PHP 5
Action application/x-httpd-php "/php/php-cgi.exe"

Aviso

Um servidor dispoto em modo CGI está aberto para várias vulnerabilidades possíveis. Por favor, leia nossa seção de segurança CGI para aprender em como se defender de tais ataques.

Instalando como um módulo do Apache

Você precisa inserir essas duas linhas ao arquivo de configuração de Apache httpd.conf para configurar o módulo PHP para o Apache 2.0:

Exemplo #2 PHP e Apache 2.0 como Módulo

# Para o PHP 4 faça algo assim:
LoadModule php4_module "c:/php/php4apache2.dll"
# Não esqueça de copiar o arquivo php4apache2.dll do diretório sapi para o principal do PHP!
AddType application/x-httpd-php .php

# Para o PHP 5 faça algo assim:
LoadModule php5_module "c:/php/php5apache2.dll"
AddType application/x-httpd-php .php

# configure o caminho para o arquivo php.ini
PHPIniDir "C:/php"

Nota: Lembre-se de substituir o caminho c:/php/ para o caminho onde você instalou o PHP na sua máquina. Tome o cuidade de usar ou php4apache2.dll ou php5apache2.dll na sua diretiva LoadModule e não php4apache.dll ou php5apache.dll já que essas últimas são feitas para rodar com o Apache 1.3.x.

Nota: Se você quiser negociação de conteúdo, leia o FAQ relacionado.

Aviso

Não misture sua instalação com arquivos DLL de versões diferentes do PHP. Você só pode escolher usar as DLL's e extensões inclusas na versão do PHP que você baixou.



add a note add a note User Contributed Notes
Apache 2.0.x no Microsoft Windows
nicolas dot grasset at gmail dot com
07-Jul-2009 03:08
Here is how I created a silent install for Apache2.2 and PHP5.2.10 on Windows XP (running on a MacBook Pro):

Download Apache2 and PHP5 installer files in a directory and update the msi file names in the following commands.

To have PHP installer find Apache2, do not forget APACHEDIR!

msiexec /i apache_2.2.11-win32-x86-no_ssl.msi /passive ALLUSERS=1 SERVERADMIN=admin@localhost SERVERNAME=localhost SERVERDOMAIN=localhost SERVERPORT=80 INSTALLDIR=c:\apache
msiexec /i php-5.2.10-win32-installer.msi /qn APACHEDIR=c:\apache INSTALLDIR=c:\php ADDLOCAL=ext_php_mssql,apache22
net stop "Apache2.2"
net start "Apache2.2"
m008 at springtimesoftware dot com
12-Jun-2009 08:14
Since Apache and PHP are often used together, and since it is difficult to configure the various versions, and since neither the official Apache or PHP websites or manuals contain clear, complete, and correct configuration instructions, and since hundreds of hours of wasted time has been spent, and since several of the user notes here contain conflicting advice, I hereby respectfully ask both the Apache and PHP development groups to study this issue and develop and release a simple automated tool (either to do the configuring OR to display instructions) that works for all valid version combinations.

David Spector
Springtime Software
CP
16-Apr-2009 04:27
This is old news to some. But people with Apache 2.0.55 / PHP 5.1.2 might like a reminder before they pull their hair out! (Some of us have ISPs using older version and need to test on a like version before we upload.)

If using PHP 5.1.2, to run Apache as a module, do *not* use Stephan's "php5apache2.dll" from http://www.ApacheLounge.com. That is for pre-5.1.2!

**There is a "php5apache2.dll" included with Windows PHP 5.1.2 zip file by default.**

If you forget this and overwrite the included DLL with Stephan's (as I did) you'll spend hours attempting to escape "DLL hell", with no success.
Anonymous
26-Feb-2009 12:32
i followed henke37's way to for the httpd.conf

I added all this at the very end of httpd.conf

# For PHP 5
#load the php main library to avoid dll hell
Loadfile "C:\php-5.2.8-Win32\php5ts.dll"

#load the sapi so that apache can use php
LoadModule php5_module "C:\php-5.2.8-Win32\php5apache2_2.dll"

#set the php.ini location so that you don't have to waste time guessing where it is
PHPIniDir "C:\php-5.2.8-Win32"

#Hook the php file extensions
AddHandler application/x-httpd-php .php
AddHandler application/x-httpd-php-source .phps

Also i didn't use short open tags as they are disabled in
"php.ini-recommended" if you don't change anything
So use this to test
<?php
 phpinfo
();
?>
NOT
<? phpinfo(); ?> short open tags

added my php directory to the PATH system variable and i start apache manually not as a service

It works for me hope it helps you!
cormac at kernan dot eu
20-Apr-2008 11:08
All good advice from henke, except where it says "Do not edit the system path".  You will NOT be able to load extensions that have dependencies e.g. MySQL, without adding PHP to your system path.  This threw me for some time as other extensions without dependencies will work without this requirement.
cfoesterle at yahoo dot com
10-Feb-2008 02:41
I do not have IIS installed on my server, only Apache. So I had to edit the PHP.ini file and comment out (add leading ";") to the following line "extension=php_iisfunc.dll" as I was getting "Faulting application httpd.exe, faulting module php_iisfunc.dll" errors when this line was active. I also added an additional  "AddType application/x-httpd-php .html" to my httpd.conf file so that inline php would work with files ending with an extension of ".html" on my server.
mjm at alum dot mit dot edu
27-Jan-2008 02:33
If you use the PHP 5 installer, you'll notice that it uses the wrong type of slash on Windows!

Change C:/Program Files/PHP/" to C:\Program Files\PHP\" and everything works great!
packard_bell_nec at hotmail dot com
03-Oct-2007 01:24
If you install PHP as an Apache CGI binary, you can add:
AddHandler cgi-script .php
into Apache httpd.conf, and add shebang line to every PHP scripts like:
#!php
<?php
phpinfo
();
?>
. But adding shebang line has a disadvantage that if you decided to install PHP as an Apache module afterwards, then the shebang line WILL appear in the web page.
In fact, you do NOT need to add shebang line to every PHP script even if you install PHP as an Apache CGI binary, because you can add:
ScriptInterpreterSource Registry-Strict
into Apache httpd.conf, and make the registry file and merge it like:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\.php\Shell\ExecCGI\Command]
@="\"C:\\Program Files\\PHP\\php-cgi.exe\""
. Then you will NOT need to change the PHP scripts which do not contain shebang line.
philippeboucher at newlogiccanada dot com dot com
31-Jul-2007 07:05
To do a silent install of PHP wich correctly modify the httpd.conf file, you HAVE (I find no other way) to put the directory of the Apache inside the INSTALLDIR's MSI option.  the APACHEDIR doesn't seem to work.  That's the only way I've make it work.  Maybe it's because my Apache is not in the default directory, I don't know, but there is a solution for people who cannot make work the silent install (for those who are told by the php setup that it cannot find the httpd.conf file).

Hope it helps someone.
anonymousness
15-Jun-2007 12:30
Verrrrrrrry important note:

If you enable multi-byte strings for your installation of PHP, the extension loaded MUST be the first extension in the list.

Apache, NOR PHP will generate any error messages or warning information in the error log or in system logs about this.

This information needs to be included in the Readme or in the distributed INI files.

The recommended PHP ini's should place extension=php_mbstring.dll  at the top of the list of extensions.

I had completely forgotten about this when recently upgrading php on a test server; and almost set out to re-install apache.
charlie at oblivion dot cz
14-Feb-2007 10:19
..try to set the extension_dir in php.ini to the absolute path.. (when you are pretty sure that you have set the PHPIniDir the right way)
Jim Keller
10-Jan-2007 11:35
it's important to note that on Apache 2.2.3 (probably other 2.x versions as well) on Windows, the PHPIniDir directive must use forward slashes to delimit directories, not the backslashes commonly used for Windows path strings. If PHP seems to be ignoring the directive, this may be why.
pcdinh at phpvietnam dot net
07-Oct-2006 08:50
PHP 6 is under active development but for those whose want to try out the new features or just want to keep updated with the development progress of PHP 6.0, you can follow my instructions below to install it on Windows XP and Apache 2.2.3

# For PHP 6 do something like this:
LoadModule php5_module "c:/server/php6/php6apache2_2.dll"
AddType application/x-httpd-php .php
PHPIniDir "c:/server/php6"

You should change the path as in your system. The directive LoadModule php5_module seems a bit strange to you. It should be LoadModule php6_module instead. However, I have just taken a look at php.internals and came across a message that said it should be changed in the near future after the PHP 5.2 is official released. At the time I write this, PHP 5.2 RC6 is planned to be released in the next few days.
subajawa at yahoo dot com
04-Aug-2006 06:56
To install PHP as Apache 2 CGI script, add these lines in addition to the 3 lines mentioned in the document.

<Directory "C:/php">
    AllowOverride None
    Options None
    Order allow,deny
    Allow from all
</Directory>
Isaac dot Brown at ArvinMeritor dot com
17-May-2005 10:59
Some XP machines are having troubles with the PHPIniDir derective not finding the php.ini (or so they think). Directories that do contain a php.ini file are returned as empty and it defaults to the next method of finding php.ini (often C:/windows or C:/winnt).

This is likely caused by read permissions not being set correctly on NTFS file systems, however, it has occurred when no cause could be identified. If setting correct file permissions doesn't work, the easiest way around this problem is moving php.ini to the Apache directory or adding the HKEY_LOCAL_MACHINE\SOFTWARE\PHP\IniFilePath string to your registry and setting it to the correct directory.

 
show source | credits | sitemap | contact | advertising | mirror sites