简体   繁体   中英

How to activate PHP on Apache2 by httpd.conf

I have Windows 7 Utimate System.
I have a working Apache2 server without PHP activated.
I have downloaded PHP5 and extracted the files to C:\\php. I added these lines to activate PHP to httpd.conf file, as per instructions in PHP directory:

    ##PHP
    # For PHP 5 do something like this:
    LoadModule php5_module "C:/php/php5apache2_4.dll"
    AddType application/x-httpd-php .php

    # configure the path to php.ini
    PHPIniDir "C:/php"
    ####################PHP  

Now Apache refusing to start again, even after restarting the system.
It is starting fine if I undo changes to conf.
How to get PHP and server working?

error.log for Apache says:

"[Fri Apr 11 10:57:43 2014] [warn] pid file C:/Program Files (x86)/  
Apache Group/Apache2/logs/httpd.pid overwritten -- Unclean shutdown  
of previous Apache run?" 

The warning error log was irrelevant. It merely says the httpd.pid is overwritten and the server should be online anyway.

Apache & PHP on Windows requires both to be compiled in the same environment for compatibility especially when you download pre-compiled binaries for Apache and PHP, you have to make sure they are being compiled using the same compiler.

Eg.

OK

Apache 2.4.9 Win32 VC11 & PHP 5.5.11 VC11 x86

Apache 2.4.9 Win32 VC9 & PHP 5.5.11 VC9 x86

Apache 2.2.27 Win32 VC9 & PHP 5.4.27 VC9 x86

NOT OK

Apache 2.4.9 Win32 VC11 & PHP 5.4.27 VC9 x86

Apache 2.4.9 Win32 VC9 & PHP 5.5.11 VC11 x86

Apache 2.2.27 Win32 VC9 & PHP 5.5.11 VC11 x86

Try making sure PHP you downloaded is built with the same compiler ie. VC11 coupled with VC11 or VC9 coupled with VC9 as well as x86 with x86 and x64 with x64.

This might not be always the case but when I follow this, it'll work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM