วันศุกร์ที่ 29 พฤษภาคม พ.ศ. 2558

Install Apache 2.4 and PHP 5.4 on Windows Server 2012 and support for CodeIgniter

Not simple not much but this is step for me to do this success.
1. Download and Extract Apache and PHP to root directory or what u want.
2. Config Apache and PHP

Yes 2 step and this job will done. here we go.
Step 1 Download 32 bit version (or 64 bit if u need but u need any library for 64 bit too. but php 5.4 has only 32bit ) for Apache and PHP
I use httpd-2.4.12-win32-VC11.zip from https://www.apachelounge.com/download/
this need VC++ 11.0 that u can find at https://support.microsoft.com/en-us/kb/2977003
make sure u use correct 32 bit or 64 bit version for me i use 32 bit in my Windows Server 2012 64bit
for PHP to use with apache we must use Thread Safe version I download php-5.4.41-Win32-VC9-x86.zip from here http://windows.php.net/download#php-5.4

Extract both files.

for Apache Copy Apache24 inside extract folder to root Drive (or whatever u want)
for PHP extract to c:/php54ts (or whatever u want)

finish step 1 here.

Step 2 Configuration
I will config PHP first
1. go to php folder and copy php.ini-production save as to php.ini or rename it (if u don't want any backup)
2. Edit list here

2.1  for this line make sure u create folder logs in php folder
error_log = "C:\php54ts\logs\php_error.log"

2.2 copy or uncomment this
extension_dir = "ext"

2.3 uncomment this extension
extension=php_mysql.dll
extension=php_mysqli.dll

2.4 time zone setting
date.timezone = "Asia/Bangkok"

this is done for PHP
3 go to Apache24 folder and edit httpd.conf in Apache24/conf folder
3.1 ServerRoot to your root folder.
3.2  Listen for your Port 
3.3 Uncomment this line for module rewrite
LoadModule rewrite_module modules/mod_rewrite.so
3.4 ServerName (for this line because i don't have domain name so i set 127.0.0.1:port for me
3.5 Change AllowOverride None to AllowOverride All for
for me line 226

     AllowOverride None
     Require all denied

And another line is 264 in


3.6 Line 277  for Index page
DirectoryIndex index.html index.php

3.7 and for last line add this (if u use folder php545ts like me)
LoadModule php5_module "c:/php54ts/php5apache2_4.dll"
AddHandler application/x-httpd-php .php

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

we end configuration Apache here.

4. Make Apache to service with Command.
4.1 add path for php and apache in system PATH
;c:\php54ts;c:\Apache24;c:\Apache24\bin
4.2 Install service by Command
c:\Apache24\bin\httpd -k install
(and can remove service with httpd -k unintall)

if u don't found any errors then anything will work fine.
go to service manager in Administrative tools and start Apache service

now we can test with basic PHP file info.
phpinfo()
?>

Hope this help.

ไม่มีความคิดเห็น: