หลักการง่ายๆ ก็ คือ ติดตั้ง PHP4 และ PHP5 ให้อยู่คนละตำแหน่งกัน แล้วใช้ Software ชื่อ suPHP
เป็นตัวกำหนดการใช้งานของ PHP ว่าจะใช้งาน PHP4 และ PHP5 จากที่ไหน ทั้งนี้ต้องไปกำหนดค่า
ใน Apache ด้วยว่าเมื่อไหร่ที่จะเรียกใช้งาน PHP4 หรือ PHP5
ตัวอย่างการติดตั้ง suPHP+PHP4+PHP5 บน FreeBSD 8
1. ติดตั้ง PHP4
ติดตั้งผ่าน /usr/ports/lang/php4/
ssh#cd /usr/ports/lang/php4/
ssh#make && make install
php4 จะถูกติดตั้งในระบบ หลังจากนั้นทำการ Config php.ini และ Config ของ Apache ให้สามารถใช้งานได้
2. ติดตั้ง PHP5
ทำการ Download PHP5 จาก http://th.php.net/distributions/
ssh#fetch http://th.php.net/distributions/php-5.2.14.tar.gz
ssh#tar zxvf php-5.2.14.tar.gz
ทำการ Compile PHP5 ให้เรียกใช้โดย cgi
ssh#cd php-5.2.14
ssh#./configure --prefix=/usr/local/php5 --with-config-file-path=/usr/local/etc/php5/cgi --enable-force-cgi-redirect --enable-fastcgi --with-gettext --with-jpeg-dir=/usr/local/lib --with-kerberos --with-mcrypt --with-mysql=/usr --with-pear --with-png-dir=/usr/local/lib --with-gd --with-gettext --with-jpeg-dir=/usr/local/lib --enable-ftp --enable-magic-quotes --enable-sockets
ssh#make && make install
เมื่อติดตั้งเสร็จแล้ว ให้ทำการสร้าง Config ของ PHP5
ssh#cp /usr/ports/lang/php-5.2.14/php.ini-dist /usr/local/php5/cgi/php.ini
3. ติดตั้ง suphp
ติดตั้งผ่าน /usr/ports/www/suphp/
ssh#cd /usr/ports/www/suphp/
ssh# make && make install
เมื่อติดตั้งเสร็จแล้ว ทำการสร้าง Log File
ssh#touch /var/log/suphp.log
สร้าง Config ของ suphp
ssh# cp /usr/local/etc/suphp.conf-example /usr/local/etc/suphp.conf
ssh#vi /usr/local/etc/suphp.conf
กรณีที่ไฟล์ใช้ User อื่นที่ไม่ใช่ apache แก้ไขเป็น
; Security options
allow_file_group_writeable=true
allow_file_others_writeable=false
allow_directory_group_writeable=true
allow_directory_others_writeable=false
เพิ่ม
[handlers]
;Handler for php-scripts
application/x-httpd-php="php:/usr/local/bin/php-cgi"
application/x-httpd-php5="php:/usr/local/php5/bin/php-cgi"
x-httpd-php5="php:/usr/local/php5/bin/php-cgi"
4. แก้ไข Config ของ Apache
เพิ่ม LoadModule
LoadModule suphp_module /usr/local/libexec/apache22/mod_suphp.so
เพิ่ม AddHandler
AddHandler application/x-httpd-php .php .inc .php4
AddHandler application/x-httpd-php5 .php5
AddHandler x-httpd-php5 .php5
เพิ่ม Location ของ suphp โดยใส่ก่อน vhosts

จากนั้นทำการ Restart Apache แล้วทดสอบการใช้งาน
ถ้าต้องการให้เฉพาะบาง Sub-Domain ใช้งาน ตัว suPHP ก็ให้เพิ่มใน vhosts.conf ในส่วนของ Sub-Domain นั้นๆ ตัวอย่าง

จากนั้นทำการ Restart Apache แล้วทดสอบ
อ้างอิง
http://www.suphp.org/Home.html
http://www.thainorthadmin.com/board/index.php?topic=436.0;wap2
http://www.suphp.org/DocumentationView.html?file=apache/INSTALL
No comments:
Post a Comment