Installing PHP 5.4 with Apache 2.4 in 32 bit of Windows !

http://jumnuoy.blogspot.com/2012/07/installing-php-54-with-apache-24-in-32.html
Installing AMP (Apache, MySQL and PHP) have become quite easier with single wizard based installations available as a packet these days. Like using XAMPP, WAMP you can just install them and use. But with these setups, you will have (or will not have) less knowledge about configuring them each in your own way because they will present some user interface where you can directly do configurations by one click. You will not know what exactly required for changing something in Apache, PHP or MySQL. So to have knowledge on configurations on them according to your requirement, you have to install each applications individually. I always recommend to do that and configure them for your purpose.

The installation and configurations of PHP, Apache and MySQL in Windows has also become quite easier these days because they provide some default configurations. As PHP, after its latest releases i.e.5.4, does not provide the downloads of VC6 version (the PHP compiled with Visual C++ 2006 compiler) these days because it is believed that the performance of the PHP compiled with VC9 (compiled with Visual C++ 2008 or later) has improved quite a lot than the compiled with VC6. So to work with the latest VC9 version of PHP, you must have installed PHP with VC9 compiled Apache as well or you use IIS as web server. VC9 compiled Apache is provided by Apache Lounge (apachelounge.com) not the original Apache (apache.org). Since I haven’t worked yet with IIS and always work with Apache in anyway, I don’t have knowledge about the IIS & PHP. Here I am going to explain few steps on how to install PHP 5.4 and Apache 2.4 in Windows.

Requirement

To run the applications compiled with VC8 or VC10, it is required to install the respective (or latest one is always better) Visual C++ redistributable packages. You can download the package from Microsoft’s official site for free.
Note: If you have any Visual Studio installed in your PC then you don’t have to install them separately.

Where to install?

Since I have not used any installers for both PHP and Apache, I will be downloading the pre compiled zipped packages and install them in my D drive. The folder structure will look like below:
  • d:/etc/apache                                   – Apache installation
  • d:/etc/php                                          – PHP installation
  • d:/etc/mysql                                      – MySQL installation
  • d:/etc/mysql/databases               – MySQL data folder
  • d:/etc/www                                       – document root folder
Note: You can change the drive and path for the installations in your own way.

Download

  1. Download the latest Apache 2.4.1 (as of writing this) from http://www.apachelounge.com/download/ (direct link for the current version – http://www.apachelounge.com/download/win32/bins/httpd-2.4.1-win32.zip) and unzip it in d:/etc/apache
  2. Download latest version 5.4 from http://windows.php.net/download and unzip it in d:/etc/php. While downloading PHP, choose the Thread Safe version for windows.
  3. Download the PHP and Apache connector DLL file from http://www.apachelounge.com/download/ (direct link: http://www.apachelounge.com/download/win32/mods-2.4/php5apache2_4.dll-php-5.4-win32.zip) and extract the file php5apache2_4.dll and copy it to d:/etc/php.

Configurations

Though the configurations may vary from individual’s requirement but here I will be discussing for some basic configurations in PHP and Apache.

Apache

  1. Open the file d:/etc/apache/conf/httpd.conf in any text editor (I use my lovely Notepad++) then find and make the following changes/configurations as per your installation path.
  2. Set the server root
    ServerRoot "D:/etc/apache"
  3. Enable required Apache modules. I just uncomment one more for mod_rewrite module.
  4. Add the following lines somewhere (I did just below the module enabling)
    LoadModule php5_module "d:/etc/php/php5apache2_4.dll"
    AddHandler application/x-httpd-php .php
    PHPIniDir "d:/etc/php"
  5. Change server admin email address
    ServerAdmin info@yoursite.com
  6. Change the document root:
    DocumentRoot "d:/etc/www"
    <Directory "d:/etc/www">
  7. If you want to allow .htaccess to be used under document root do the following under <Directory “d:/etc/www”>
    AllowOverride All
  8. Find the follwoing and replace the path:
    ScriptAlias /cgi-bin/ "d:/etc/apache/cgi-bin/"
    <Directory "d:/etc/apache/cgi-bin">
  9. Add index.php in directory index
    DirectoryIndex index.html index.php

PHP

  1. Rename php.ini-development to php.ini
  2. Find extension directory setting and set the path as per your installation.
    extension_dir = "d:\etc\php\ext"
  3. Uncomment (remove the simicolon ; from the beginning of the line) the extensions that you want to enable them. i.e.
    extension=php_curl.dll
    extension=php_mysql.dll
    extension=php_mysqli.dll
    extension=php_pdo_mysql.dll
    extension=php_soap.dll
  4. If you want to test email sending from the PHP in local system, then you need to set the SMTP. i.e.
    SMTP = smtp.yoursite.com
    smtp_port = 25
    sendmail_from = youremail@sender.com
Rest of the changes/configurations are totally depends on requirement project wise.

Set Environment Variables for PHP (Windows 7)

To be available PHP globally in Windows, the path of the PHP has to be set.
  1. Right click on Computer and click Properties
  2. Click on Advanced system settings on the left side (top).
  3. Click on the Environment variables
  4. Under System variables, double click the Path variable name and add ;d:\etc\php without double quotes at the end where semicolon (;) is the separator.
  5. Click OK to save. Sometimes you may need to restart the computer this to take it into effect.

Install Apache as Service

Since we have just copied the files in a folder, the Apache is not yet not a windows service. To install it as a service follow the steps.
  1. Run the command line (cmd.exe) As Administrator. Browse the folder c:\Windows\System32\ and right click on cmd.exe and select Run as Administrator.
  2. Change directory to d:\etc\apache\binin the command line
    cd d:\etc\apache\bin
  3. Run the command to install it
    httpd -k install (or sometimes httpd.exe -k install if that does not work)
Now restart the computer and test both PHP and Apache. To test both together create a PHP file phpinfo.php in d:\etc\www. Now browse in the browser as http://localhost/phpinfo.php.
If you can see the PHP information then now you are done !

Installing AMP (Apache, MySQL and PHP) have become quite easier with single wizard based installations available as a packet these days. Like using XAMPP, WAMP you can just install them and use. But with these setups, you will have (or will not have) less knowledge about configuring them each in your own way because they will present some user interface where you can directly do configurations by one click. You will not know what exactly required for changing something in Apache, PHP or MySQL. So to have knowledge on configurations on them according to your requirement, you have to install each applications individually. I always recommend to do that and configure them for your purpose.

The installation and configurations of PHP, Apache and MySQL in Windows has also become quite easier these days because they provide some default configurations. As PHP, after its latest releases i.e.5.4, does not provide the downloads of VC6 version (the PHP compiled with Visual C++ 2006 compiler) these days because it is believed that the performance of the PHP compiled with VC9 (compiled with Visual C++ 2008 or later) has improved quite a lot than the compiled with VC6. So to work with the latest VC9 version of PHP, you must have installed PHP with VC9 compiled Apache as well or you use IIS as web server. VC9 compiled Apache is provided by Apache Lounge (apachelounge.com) not the original Apache (apache.org). Since I haven’t worked yet with IIS and always work with Apache in anyway, I don’t have knowledge about the IIS & PHP. Here I am going to explain few steps on how to install PHP 5.4 and Apache 2.4 in Windows.

Requirement

To run the applications compiled with VC8 or VC10, it is required to install the respective (or latest one is always better) Visual C++ redistributable packages. You can download the package from Microsoft’s official site for free.
Note: If you have any Visual Studio installed in your PC then you don’t have to install them separately.

Where to install?

Since I have not used any installers for both PHP and Apache, I will be downloading the pre compiled zipped packages and install them in my D drive. The folder structure will look like below:
  • d:/etc/apache                                   – Apache installation
  • d:/etc/php                                          – PHP installation
  • d:/etc/mysql                                      – MySQL installation
  • d:/etc/mysql/databases               – MySQL data folder
  • d:/etc/www                                       – document root folder
Note: You can change the drive and path for the installations in your own way.

Download

  1. Download the latest Apache 2.4.1 (as of writing this) from http://www.apachelounge.com/download/ (direct link for the current version – http://www.apachelounge.com/download/win32/bins/httpd-2.4.1-win32.zip) and unzip it in d:/etc/apache
  2. Download latest version 5.4 from http://windows.php.net/download and unzip it in d:/etc/php. While downloading PHP, choose the Thread Safe version for windows.
  3. Download the PHP and Apache connector DLL file from http://www.apachelounge.com/download/ (direct link: http://www.apachelounge.com/download/win32/mods-2.4/php5apache2_4.dll-php-5.4-win32.zip) and extract the file php5apache2_4.dll and copy it to d:/etc/php.

Configurations

Though the configurations may vary from individual’s requirement but here I will be discussing for some basic configurations in PHP and Apache.

Apache

  1. Open the file d:/etc/apache/conf/httpd.conf in any text editor (I use my lovely Notepad++) then find and make the following changes/configurations as per your installation path.
  2. Set the server root
    ServerRoot "D:/etc/apache"
  3. Enable required Apache modules. I just uncomment one more for mod_rewrite module.
  4. Add the following lines somewhere (I did just below the module enabling)
    LoadModule php5_module "d:/etc/php/php5apache2_4.dll"
    AddHandler application/x-httpd-php .php
    PHPIniDir "d:/etc/php"
  5. Change server admin email address
    ServerAdmin info@yoursite.com
  6. Change the document root:
    DocumentRoot "d:/etc/www"
    <Directory "d:/etc/www">
  7. If you want to allow .htaccess to be used under document root do the following under <Directory “d:/etc/www”>
    AllowOverride All
  8. Find the follwoing and replace the path:
    ScriptAlias /cgi-bin/ "d:/etc/apache/cgi-bin/"
    <Directory "d:/etc/apache/cgi-bin">
  9. Add index.php in directory index
    DirectoryIndex index.html index.php

PHP

  1. Rename php.ini-development to php.ini
  2. Find extension directory setting and set the path as per your installation.
    extension_dir = "d:\etc\php\ext"
  3. Uncomment (remove the simicolon ; from the beginning of the line) the extensions that you want to enable them. i.e.
    extension=php_curl.dll
    extension=php_mysql.dll
    extension=php_mysqli.dll
    extension=php_pdo_mysql.dll
    extension=php_soap.dll
  4. If you want to test email sending from the PHP in local system, then you need to set the SMTP. i.e.
    SMTP = smtp.yoursite.com
    smtp_port = 25
    sendmail_from = youremail@sender.com
Rest of the changes/configurations are totally depends on requirement project wise.

Set Environment Variables for PHP (Windows 7)

To be available PHP globally in Windows, the path of the PHP has to be set.
  1. Right click on Computer and click Properties
  2. Click on Advanced system settings on the left side (top).
  3. Click on the Environment variables
  4. Under System variables, double click the Path variable name and add ;d:\etc\php without double quotes at the end where semicolon (;) is the separator.
  5. Click OK to save. Sometimes you may need to restart the computer this to take it into effect.

Install Apache as Service

Since we have just copied the files in a folder, the Apache is not yet not a windows service. To install it as a service follow the steps.
  1. Run the command line (cmd.exe) As Administrator. Browse the folder c:\Windows\System32\ and right click on cmd.exe and select Run as Administrator.
  2. Change directory to d:\etc\apache\binin the command line
    cd d:\etc\apache\bin
  3. Run the command to install it
    httpd -k install (or sometimes httpd.exe -k install if that does not work)
Now restart the computer and test both PHP and Apache. To test both together create a PHP file phpinfo.php in d:\etc\www. Now browse in the browser as http://localhost/phpinfo.php.
If you can see the PHP information then now you are done !

0 comments:

Post a Comment

Followers

រឿង ដែលខានមើលមិនបាន

Contact us

Name

Email *

Message *

Your Language

Online

Copyright 2009 Simplex Celebs All rights reserved Designed by www.sruol9.com