Monday, May 11, 2015

How to Install Apache 2.4, PHP5./5.6 and Mysql on Windows Server 2008/2012



Downloading all files

Download Apache
We are going to use the unofficial Windows binary from Apache Lounge for windows.  it is provided as a manually install-able ZIP file from www.apachelounge.com/download/  For 64bit download  httpd-2.4.12-win64-VC11 Download and extract the zip and copy it to the root of C:\. This will be C:\Apache24 when it is all done.
Download windows Visual C++ Re-distributable 
Download PHP
Download php-5.X.X-Win32-VC11-x64.zip Thread Safe from http://windows.php.net/download/ . Extract and rename folder to php and move to C:\.
Note : Thread Safe for Apache and non thread safe for IIS
Edit Apache’s config file, c:\Apache24\conf\httpd.conf and add the following lines to the bottom of the file.
LoadModule php5_module "c:/php/php5apache2_4.dll"
AddHandler application/x-httpd-php .php
# configure the path to php.ini
PHPIniDir "C:/php"
While we are at it we can add index.php to Apache’s list just incase we want to have a starting page as php.
Find Directory index and add index.php
DirectoryIndex index.html index.php
Install Apache Service
Now let’s install Apache as a service. Open a command prompt and type.
c:\apache24\bin\httpd -k install
If do not want Apache starting automatically at start-up/reboot:
GUI Way
START | RUN
Type in services.msc, hit Enter or click OK
Locate Apache2 service and double-click (or right-click for Properties)
Find the caption Startup type: (in the middle of the dialog box), use the pull-down and select Manual
Click OK
PHP Edits
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 changes and open a command prompt. Restart Apache to re-read the changes made to PHP.
So now we have Apache running and configured to use php. Lets create a file called info.php, save it and see if Apache parses the info correctly to display the results.
Open Notepad or your favorite Windows editor and type and save the following.
 <?php
phpinfo();
?>
Open your browser and type, localhost/info.php for the location and you should receive alot of information about PHP.
MySQL
Download and install mysql-5.6.19-win64.msi. Change installation directory to C:\MySQL\MySQL Server 5.6 instead of Program files as there could be permissions issues. Once the installation is completed you can let the configuration wizard run and setup the database server. The defaults will work just fine, but remember what you set the password to for root.
PHPMyAdmin
PHPMyAdmin is a very nice tool to use for administering your MySQL installation.
Download and install phpmyadmin-3.4.10.1-english.zip.
Extract the file and move to c:\apache24\htdocs. Rename directory to phpmyadmin.
Create a config directory under phpmyadmin. Open a browser and type localhost/phpmyadmin/setup/index.php to complete the installation.




No comments:

Post a Comment

Total Pageviews