[How-to] Directadmin Custombuild 2.0 Multi PHP versions selectable by .htaccess

ของขวัญปีใหม่ดีสุด ๆ ขอบคุณครับ

อยากได้ peak เพราะแค่นี้แหละ ฮ่าๆๆ

:875328cc: ขอบคุณมากๆ ครับ นั่งงมอยู่นานมาก ไม่สมบูรณ์ซะที คราวนี้ละ :slight_smile:

คำเตือนอย่างนึงนะครับ

รันใน mode suPHP จะช้า และเปลืองทรัพยากรกว่า mode apache sapi/fastcgi มากๆ และทำให้พวก apc/xcache ไม่มีผลด้วยนะครับ

ถ้าตัด php 5.2 ทิ้งได้ ก็ใช้ custombuild 2.0 ลง php แบบ fpm ได้เลย เลือกใช้ได้ 2 version

เอาจริงๆมันใช้หลาย version ได้ แต่ da มันเขียน config ให้แค่ 1-2 version ตาม options ของ custombuild ถ้าจะเอาจริงๆก็ต้องไปเขียน script post_user_add ให้สร้าง config เพิ่มให้ครบ

วิธีข้างบนก็ไว้เป็นทางเลือกสำหรับเครื่องที่ปกติไม่ได้ทำงานหนักมาก

ขอบคุณครับ

[B]php ถ้าเรา compile แต่ละ เวอร์ชั่นแยกกัน (mod_php)
แบบไม่ใช้ suphp [/B]เราจะสร้าง พวกนี้ได้เองได้อย่างไรครับ

AddHandler application/x-httpd-php53 -> /usr/local/php53/bin/php
AddHandler application/x-httpd-php52 -> /usr/local/php52/bin/php
AddHandler application/x-httpd-php51 -> /usr/local/php51/bin/php
AddHandler application/x-httpd-php5 -> /usr/local/php5/bin/php
AddHandler application/x-httpd-php4 -> /usr/local/php4/bin/php

ผมลอง แบบนี้ก็ยังไม่ได้ครับ
Action application/x-httpd-php53 /usr/local/php53/bin/php

เราไม่ใช้ suphp พอจะได้ไหมครับ
ขอบคุณครับ

เวลาต้องการ build php แต่ละ version โดยไม่ต้อง set option ใหม่ สามารถใช้คำสั่งนี้ได้ครับ

cd /usr/local/directadmin/custombuild
./build php_expert php_release php_mode

เช่น
./build php_expert 5.4 suphp
./build php_expert 5.5 suphp
./build php_expert 5.6 suphp

สำหรับท่านใด ที่ลง PHP 5.2 หรือ 5.4 แล้ว compile ไม่ผ่าน

2.17/TSRM -I/usr/local/directadmin/custombuild/php-5.2.17/Zend -I/usr/local/include -g -O2 -c /usr/local/directadmin/custombuild/php-5.2.17/ext/dom/node.c -o ext/dom/node.lo
/usr/local/directadmin/custombuild/php-5.2.17/ext/dom/node.c: In function ‘dom_canonicalization’:
/usr/local/directadmin/custombuild/php-5.2.17/ext/dom/node.c:1953: error: dereferencing pointer to incomplete type
/usr/local/directadmin/custombuild/php-5.2.17/ext/dom/node.c:1955: error: dereferencing pointer to incomplete type
make: *** [ext/dom/node.lo] Error 1

========================================================
cd /usr/local/directadmin/custombuild
wget http://files10.directadmin.com/services/custombuild/php-5.2.17.tar.gz
wget http://files10.directadmin.com/services/custombuild/php-5.2.x-mail-header.patch
tar xzf php-5.2.17.tar.gz
patch -p0 < php-5.2.x-mail-header.patch
cd php-5.2.17

curl -o php-5.2.17.patch https://mail.gnome.org/archives/xml/2012-August/txtbgxGXAvz4N.txt
patch -p0 < php-5.2.17.patch

========================================================

เวอร์ชั่นอื่นๆ เช่น
curl -o php-5.4.5.patch https://mail.gnome.org/archives/xml/2012-August/txtbgxGXAvz4N.txt
$ tar jxf php-5.4.5.tar.bz2
$ cd php-5.4.5
$ patch -p0 -b <…/php-5.4.5.patch
patching file ext/dom/node.c
patching file ext/dom/documenttype.c
patching file ext/simplexml/simplexml.c

อันนี้กลัวไฟล์ patch หายครับ
Credit Thank : Alfa-Host

— ext/dom/node.c 2012-08-06 17:49:48.826716692 +0800
+++ ext/dom/node.c 2012-08-06 17:52:47.633484660 +0800
@@ -1895,9 +1895,17 @@ static void dom_canonicalization(INTERNA
RETVAL_FALSE;
} else {
if (mode == 0) {
+#ifdef LIBXML2_NEW_BUFFER

  •        ret = xmlOutputBufferGetSize(buf);
    

+#else
ret = buf->buffer->use;
+#endif
if (ret > 0) {
+#ifdef LIBXML2_NEW_BUFFER

  •            RETVAL_STRINGL((char *) xmlOutputBufferGetContent(buf), ret, 1);
    

+#else
RETVAL_STRINGL((char *) buf->buffer->content, ret, 1);
+#endif
} else {
RETVAL_EMPTY_STRING();
}
— ext/dom/documenttype.c 2012-08-06 18:02:16.019640870 +0800
+++ ext/dom/documenttype.c 2012-08-06 18:06:16.612228905 +0800
@@ -205,7 +205,13 @@ int dom_documenttype_internal_subset_rea
if (buff != NULL) {
xmlNodeDumpOutput (buff, NULL, (xmlNodePtr) intsubset, 0, 0, NULL);
xmlOutputBufferFlush(buff);
+
+#ifdef LIBXML2_NEW_BUFFER

  •        ZVAL_STRINGL(*retval, xmlOutputBufferGetContent(buff),
    
  •                     xmlOutputBufferGetSize(buff), 1);
    

+#else
ZVAL_STRINGL(*retval, buff->buffer->content, buff->buffer->use, 1);
+#endif
(void)xmlOutputBufferClose(buff);
return SUCCESS;
}
— ext/simplexml/simplexml.c 2012-08-06 18:10:44.621017026 +0800
+++ ext/simplexml/simplexml.c 2012-08-06 18:12:48.016270419 +0800
@@ -1417,7 +1417,12 @@ SXE_METHOD(asXML)

         xmlNodeDumpOutput(outbuf, (xmlDocPtr) sxe-&gt;document-&gt;ptr, node, 0, 0, ((xmlDocPtr) sxe-&gt;document-&gt;ptr)-&gt;encoding);
         xmlOutputBufferFlush(outbuf);

+#ifdef LIBXML2_NEW_BUFFER

  •        RETVAL_STRINGL((char *)xmlOutputBufferGetContent(outbuf),
    
  •                       xmlOutputBufferGetSize(outbuf), 1);
    

+#else
RETVAL_STRINGL((char *)outbuf->buffer->content, outbuf->buffer->use, 1);
+#endif
xmlOutputBufferClose(outbuf);
}
} else {

credit: [solved] Compile PHP 5.2 | LiteSpeed Support Forums

สำหรับไฟล์ php-5.2.x-mail-header.patch ท่านใด patch ไม่ได้
fix ดังนี้ครับ

cd /usr/local/directadmin/custombuild
cd php-5.2.17

wget http://files10.directadmin.com/services/custombuild/php-5.2.x-mail-header.patch

[QUOTE]— a/ext/standard/mail.c 2010-12-11 23:35:23.000000000 +0800
+++ b/ext/standard/mail.c 2010-12-11 23:35:41.000000000 +0800
@@ -216,6 +216,49 @@
void (*sig_handler)() = NULL;
#endif

แก้เป็น

— ext/standard/mail.c 2010-12-11 23:35:23.000000000 +0800
+++ ext/standard/mail.c 2010-12-11 23:35:41.000000000 +0800
@@ -216,6 +216,49 @@
void (*sig_handler)() = NULL;
#endif

patch -p0 < php-5.2.x-mail-header.patch

[/QUOTE]

ทำไมผมทำไม่สำเร็จ หว่า T-T หรือช่วง 2 เดือนนี้มีเปลี่ยนแปลงอะไรใน custom build ป่ะ

Wrong php_ini_type set in options.conf.

ตอนนี้ค่าเป้นอะไรครับ

custombuild 2.0 ปกติมาเป็น no ครับ แต่พี่จะใส่เป็น yes ก็ได้

./build set php_ini yes

เมื่อวานลองทำตาม smtalk กระทู้นานแล้วไม่รู้ยังใช้ได้อยู่หรือเปล่า ผมสั่ง ./build all d ต่อจากเขาไปอีกแต่ติด error ตอนบิว suphp ลืมเซฟไว้ด้วยเลยกลับไปใช้ php5.3 เหมือนเดิมก่อน
ถ้าทำได้ผมว่าก็สะดวกดีนะครับ เลือกเวอร์ชั่น php ที่ลูกค้าต้องการใน DirectAdmin ได้เลยไม่ต้องใช้ .htaccess แต่ไม่รู้ว่าจำกัด php แค่ 2 เวอร์ชั่นหรือเปล่า
http://forum.directadmin.com/showthread.php?t=48028

Feel free to use any php[B]X[/B]_mode, the example is given with suphp:
Code:
cd /usr/local/directadmin/custombuild
./build update
./build set mod_ruid2 no
./build set php1_release 5.5
./build set php2_release 5.3
./build set php1_mode suphp
./build set php2_mode suphp
More about CB 2.0:
http://forum.directadmin.com/showthread.php?t=44743

In #12 it’s mentioned that PHP version could be changed in domain settings (user level). Good luck!
http://www.directadmin.com/features.php?id=1456

php 5.2.17 ก็ ใช้ตัว patch ให้มันรัน php-fpm ได้ อะไรก็น่าจะง่ายขึ้นเยอะครับ

CB 2 จะเลือก php ได้จากใน da โดยมันไปสลับ version ใน httpd.conf ของ user นั้นๆ ทำให้ต้อง restart httpd ทุกครั้งที่ user ไปสลับ version ถ้านานๆสลับทีก็คงไม่เป็นไร แค่ถ้ามี user เยอะๆ แล้วผลัดกันสลับเป็นว่าเล่น httpd ก็จะ restart บ่อย โดยไม่จำเป็น สู้ใช้ .htaccess ไม่ได้
และอีกอย่างถ้าไม่ได้ใช้ php 5.2 ก็ใช้เป็นโหมด php-fpm ไปเลย custombuild 2 รองรับอยู่แล้ว สลับ version ได้จากใน da เหมือนกัน (restart httpd)

ตอน compile php 5.2
cd /usr/local/directadmin/custombuild wget http://files10.directadmin.com/services/custombuild/php-5.2.17.tar.gz
wget http://files10.directadmin.com/services/custombuild/php-5.2.x-mail-header.patch
tar xzf php-5.2.17.tar.gz
patch -p0 < php-5.2.x-mail-header.patch

[root@server custombuild]# patch -p0 < php-5.2.x-mail-header.patch
can’t find file to patch at input line 3
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:

|— a/ext/standard/mail.c 2010-12-11 23:35:23.000000000 +0800

+++ b/ext/standard/mail.c 2010-12-11 23:35:41.000000000 +0800

File to patch:

พอใช้คำสั่ง patch แล้วขึ้นแบบนี้ไปต่อไม่เป็นเลย ช่วยด้วยครับ

แก้เป็น patch -p1 ครับ

patch -p1 < php-5.2.x-mail-header.patch ก็ขึ้นแบบเดิมครับ

ก่อนสั่ง patch ได้สั่ง cd เข้าไปใน folder php-5.2.17 ละยังครับ

ได้แล้วครับแก้ตามที่คุณ mean โพสไว้ ไม่ได้อ่านกระทู้ก่อนหน้าเลย :040:

เผื่อใครเจอปัญหาเดียวกับผมครับ จะได้ไม่ต้องเสียเวลางม
เวลา compile 5.2 ไม่ผ่านอีกกรณี เจอ error

-liconv -ldl -lm -lrt -lcrypt  -o sapi/cgi/php-cgi
ext/pcre/php_pcre.o: In function `pcre_get_compiled_regex_cache':
/usr/local/directadmin/custombuild/php-5.2.17/ext/pcre/php_pcre.c:259: undefined reference to `pcre_info'
collect2: ld returned 1 exit status
make: *** [sapi/cgi/php-cgi] Error 1

ให้ใช้ patch จาก
https://code.google.com/p/php52-backports/issues/detail?id=33

วิธีต่อจากพี่แมนและคุณมีนได้เลย
ดูให้แน่ใจว่าอยู่ในแฟ้ม
/usr/local/directadmin/custombuild/php-5.2.17
หลังจากเจอ error

สร้างไฟล์ php-pcre-fix.patch แล้วเพิ่ม code ด้านล่าง


--- ext/pcre/php_pcre.c	2012-01-01 14:15:04.000000000 +0100
+++ ext/pcre/php_pcre.c	2012-02-06 13:31:36.198935107 +0100
@@ -252,10 +252,10 @@
 	   back the compiled pattern, otherwise go on and compile it. */
 	if (zend_hash_find(&PCRE_G(pcre_cache), regex, regex_len+1, (void **)&pce) == SUCCESS) {
 		/*
-		 * We use a quick pcre_info() check to see whether cache is corrupted, and if it
+		 * We use a quick pcre_fullinfo() check to see whether cache is corrupted, and if it
 		 * is, we flush it and compile the pattern from scratch.
 		 */
-		if (pcre_info(pce->re, NULL, NULL) == PCRE_ERROR_BADMAGIC) {
+		int count = 0; if (pcre_fullinfo(pce->re, NULL, PCRE_INFO_CAPTURECOUNT, &count) == PCRE_ERROR_BADMAGIC) {
 			zend_hash_clean(&PCRE_G(pcre_cache));
 		} else {
 #if HAVE_SETLOCALE
--- ext/pcre/php_pcre.def	2009-01-11 14:59:00.000000000 +0100
+++ ext/pcre/php_pcre.def	2012-02-06 13:31:47.775299315 +0100
@@ -4,7 +4,6 @@
 php_pcre_exec
 php_pcre_get_substring
 php_pcre_get_substring_list
-php_pcre_info
 php_pcre_maketables
 php_pcre_study
 php_pcre_version
--- main/php_compat.h	2012-01-01 14:15:04.000000000 +0100
+++ main/php_compat.h	2012-02-06 13:26:59.272834580 +0100
@@ -34,7 +34,6 @@
 #define pcre_exec			php_pcre_exec
 #define pcre_get_substring		php_pcre_get_substring
 #define pcre_get_substring_list		php_pcre_get_substring_list
-#define pcre_info			php_pcre_info
 #define pcre_maketables			php_pcre_maketables
 #define pcre_study			php_pcre_study
 #define pcre_version			php_pcre_version

จากนั้นสั่งตามพี่แมนซ้ำอีกครั้ง

sh configure.php5

แล้วสั่ง patch

 patch -p0 < php-pcre-fix.patch

เรียบร้อยแล้ว compile ซ้ำอีกครั้ง

make && make install

พอไม่เจอ error แล้วกลับไปตามขั้นตอนพี่แมนหน้า แรกต่อครับ

:875328cc: