Tuesday, July 12, 2016

configure php 5.x apache 2.4 windows 7



httpd.conf Edit



Download php-5.6.23-Win32-VC11-x86.zip from http://windows.php.net/download/ . Extract the zip file to c:\php.


Edit Apache’s config file, c:\Apache\conf\httpd.conf and add the following lines to the bottom of the file.

Method 1

  • LoadModule php5_module "c:/php/php5apache2_4.dll"
  • AddHandler application/x-httpd-php .php
  • PHPIniDir "c:/php"
  • Set the environment variable append this text : "c:/php"
  • Find Directory index and add index.php add below line
    • "DirectoryIndex index.html index.php"


save the conf file. Restart your Apache server.

Method 2

In this method we Configuring Apache to Use PHP as CGI on Windows Systems. which best suitable for Higher versions of php like (above php5.3 on Apache 2.2). we will configure below steps.


1. Assuming that your Apache server is installed at C:\Apache2.2

2. Assuming that your PHP engine is installed at c:/php/

3. Use "notepad" to open C:\Apache2.2\conf\httpd.conf

4. Go to alias_module section and define a script directory call /php/ as:


...
   ScriptAlias /php/ "c:/php/"
5. Add an access control section for this directory as:


    AllowOverride None
    Options None
    Order allow,deny
    Allow from all

6. Go to mime_module section and define a mime type as:


...  
    AddType application/x-httpd-php .php

7. At the root level below the LoadModule section, define an "Action" entry:

#LoadModule ssl_module modules/mod_ssl.so

Action application/x-httpd-php "/php/php-cgi.exe"
This "Action" entry tells Apache to run "php-cgi.exe" from the script directory "/php/" for any "application/x-httpd-php" mime files.

8. Restart your Apache server.

save the conf file. Restart your Apache server.

PHP INI Edit

Now we have to do a few edits to the php.ini file to tell it to load support for mysql and the location for the extensions. Since there is not a already set php.ini file we need to rename one of the two examples to php.ini.
Rename c:\php\php.ini-development to php.ini
Now let’s edit php.ini
Uncomment extension directory.
; Directory in which the loadable extensions (modules) reside.
; http://php.net/extension-dir
; extension_dir = "./"
; On windows:
extension_dir = "ext"

Uncomment mysql modules
extension=php_mysql.dll
extension=php_mysqli.dll

save the .ini file changes. Restart your Apache server.

No comments:

Post a Comment