แสดงบทความที่มีป้ายกำกับ PHP แสดงบทความทั้งหมด
แสดงบทความที่มีป้ายกำกับ PHP แสดงบทความทั้งหมด

วันศุกร์ที่ 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.

วันพฤหัสบดีที่ 6 ธันวาคม พ.ศ. 2555

Unable to load dynamic library 'xxx/php_pdo_mysql.dll'

Yes I can't load this php_pdo_mysql.dll and it still in my ext folder.
After search but cannot remember if you want to use any php_pdo_xxxx.dll you need to enable php_pdo.dll in php.ini too.

Hope this help.

วันอังคารที่ 4 กันยายน พ.ศ. 2555

PHP include UTF8 have strange line or space.

Because UTF8 hast 2 type this explain in

http://www.w3.org/International/questions/qa-utf8-bom.en.php

This explain about UTF8 BOM and Remove BOM

For Visual Studio.NET Use
UTF8 with signature for BOM and
UTF8 without signature for remove BOM

To do this you must use "File > Advanced save options..."

วันอาทิตย์ที่ 2 กันยายน พ.ศ. 2555

php 5.2, 5.3, 5.4 connected mssql with sqlsrv

1. Download SQLSRV30.EXE at

http://www.microsoft.com/en-us/download/details.aspx?id=20098
For use with PHP 5.2 you need SQLSRV20.EXE instead for more details see
http://www.php.net/manual/en/sqlsrv.installation.php

2. Read instruction to install or run download file point location to php extension folder.
3. Install it will get file dll and manual in your extension folder.
4. add extension call in your php.ini file (this ex. use for PHP 5.4 thread safe version)
extension=php_sqlsrv_54_ts.dll

5. Go for Test Code.
/* Specify the server and connection string attributes. */
$serverName = "(localhost)\SQLExpress";

/* Get UID and PWD from application-specific files.  */
$uid = file_get_contents("C:\AppData\uid.txt");
$pwd = file_get_contents("C:\AppData\pwd.txt");
$connectionInfo = array( "UID"=>$uid,
                         "PWD"=>$pwd,
                         "Database"=>"your_db_name");

/* Connect using SQL Server Authentication. */
$conn = sqlsrv_connect( $serverName, $connectionInfo);
if( $conn === false )
{
     echo "Unable to connect.</br>";
     die( print_r( sqlsrv_errors(), true));
}

/* Query SQL Server for the login of the user accessing the
database. */
$tsql = "SELECT CONVERT(varchar(32), SUSER_SNAME())";
$stmt = sqlsrv_query( $conn, $tsql);
if( $stmt === false )
{
     echo "Error in executing query.</br>";
     die( print_r( sqlsrv_errors(), true));
}

/* Retrieve and display the results of the query. */
$row = sqlsrv_fetch_array($stmt);
echo "User login: ".$row[0]."</br>";

/* Free statement and connection resources. */
sqlsrv_free_stmt( $stmt);
sqlsrv_close( $conn);

วันอังคารที่ 3 กรกฎาคม พ.ศ. 2555

PHP Loaded Configuration File not load from php folder

This happen to me when try to use PHP 5.2.16 with IIS 6 (Windows 2003)
To fix this add folder php path to System Environment Path and add PHPRC with value same folder

Restart and now it will load from php directory.

วันจันทร์ที่ 28 พฤษภาคม พ.ศ. 2555

PHP Startup: Unable to load dynamic library 'C:\php\ext\php_mssql.dll' - The specified module could not be found.

I don't know why I can't load this dll because I make sure destination correct until search some and found this page
http://www.php.net/manual/en/install.windows.extensions.php

php_mssql.dll need ntwdblib.dll So I need to include path php in system environment.

yes that not enough because still not run

You can check with php.exe -v for what dll cannot load and what it required
In my case I need msvcr71.dll and I don't know where is this come from
I use Windows Server 2008 R2 and after found this

http://blogs.msdn.com/b/laurenbo/archive/2009/11/03/php-on-windows-workaround-for-a-command-line-error-msvcr71-dll-is-missing.aspx

 For general English can download here http://www.microsoft.com/en-us/download/details.aspx?id=26

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

PHP 5.2 Windows Sever 2008 R2 (IIS 7.5) The FastCGI process exited unexpectedly

"The FastCGI process exited unexpectedly"


For my project I need mantis for install and use with sql 2008 express.
I cannot use FastCgi for thread safe with support extension php_mssql.dll but non thread safe work without any problem

วันพฤหัสบดีที่ 24 พฤษภาคม พ.ศ. 2555

Install PHP 5.4 on Windows Server 2008 R2 or Windows 7

1. Download PHP Thread safe on Non Thread safe it depend on your requirement.

2. Unpackage to folder you like (ex. is C:\php-5.4.3-Win32)

3. Open IIS (After you prepare IIS)
4. Go to Handler Mappings

5. Add Module Mapping
6. Add Input Like this one
    *Windows 7  If you cannot find FastCgi module see here.
7. On Request Restrictions Set to File only then click OK.
8. Now time to set php.ini  first make php.ini from copy from php.ini.production (or rename it if you don't want any backup) and set by this (this come from this reference)
extension_dir = "C:\php-5.4.3-Win32\ext" (what your directory you set that.)
if has comment in front ";" just delete it like
to
log_errors = On
error_log = "C:\php-5.4.3-Win32\temp\php_error.log" (Create folder temp in php folder or whatever you want to keep log file but beware on write or modifiled permission in windows)
cgi.force_redirect = 0
cgi.fix_pathinfo=1
fastcgi.logging = 0

php 5.4 recommend to set timezone before use.

date.timezone = "Asia/Bangkok"

for timezone see list here
for more details see http://php.net/date.timezone

extension_dir = "C:\php-5.4.3-Win32\ext\"

for support Ms SQL Server see
http://pakorosprogramming.blogspot.com/2012/09/php-52-53-54-connected-mssql-with-sqlsrv.html

9. Now time to test for this just create php file in root folder or somewhere and open it for my sample i create phpinfo.php in root folder with code


if you have problem to create file php from text file may be set security to show up extension by this

10. Final result.
If it don't show up try to restart IIS first.

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

Install PHP 5.4 via FastCgi on IIS 6

I will explain later when have time but for success this
I follow by this references.

ref:http://it.megocollector.com/?p=1305
ref:http://learn.iis.net/page.aspx/247/using-fastcgi-to-host-php-applications-on-iis-60/
ref:http://php.net/manual/en/install.windows.iis6.php


วันเสาร์ที่ 17 ธันวาคม พ.ศ. 2554

How to reset the Admin Kayako password?

If you forget the password for the Admin CP you will not be able to login. - If you are using a Hosted license, you will need to contact us to reset the password for you. You will need to provide us some proof of identity like your Transaction ID or the Order ID before we can reset the password for you. - If you are using a Leased or an Owned license, you will need to run the following queries at your MySQL prompt : 1. Select title,fullname,username from swstaff sw join swstaffgroup sg on (sw.staffgroupid=sg.staffgroupid); 2. Update swstaff set password=md5('Test') where username='username'; The first query will provide you with a user name, which you will need to specify in the subsequent query and it will reset the password to 'Test'.

วันจันทร์ที่ 12 ธันวาคม พ.ศ. 2554

PHP Setting

short_open_tag = On || Off display_error = On || Off mysql.connect_timeout = 60 || (240 in my notebook)
extension=php_mbstring.dll
extension=php_mcrypt.dll
extension=php_mssql.dll
extension=php_mysql.dll
extension=php_gd2.dll
extension=php_imap.dll
extension=php_mysqli.dll

update 08/12/2012 (dd/mm/yyyy)
max_execution_time = 60 ; Old value is 30 is not enough for install Magento

วันจันทร์ที่ 26 ตุลาคม พ.ศ. 2552

[PHP] การเขียนไฟล์

ใช้คำสั่ง fopen นะคร้าบ

$strFileName = "MyFile.txt";
$objFopen = fopen($strFileName, 'w');
$strText = "Test ja";
fwrite($objFopen, $strText1);

if($objFopen)
{
echo "File writed.";
}
else
{
echo "File can not write";
}

fclose($objFopen);

สำหรับ Mode การเขียนก็มี
r - ไว้อ่านอย่างเดียว
w - ถ้ามีไฟล์อยู่แล้วเขียนทับหรือสร้างใหม่
a - เขียนต่อขอรับ