Apache2.0 + PHP5 on FreeBSD


ผ่านไปพักใหญ่ MySQL Cluster ก็ยังไม่ Start สะทีเลยถือโอกาศมาเขียน docs เรื่องการติดตั้ง Apache + PHP + Mysql ในรูปแบบของผมกันครับ ก่อนอื่นให้ทำการติดตั้ง MySQL ตามเอกสารนี้ครับ

1. ทำการ Update pors ครับ (แนะนำว่าให้ทำบ่อยๆ ใส่ crontab ไว้เลยก็ได้ครับ)

cvsup -g -L 2 /usr/share/examples/cvsup/ports-supfile -h cvsup.th.freebsd.org

2. ทำการติดตั้ง Apache 2.0

cd /usr/ports/www/apache20/
make all install clean WITH_SSL_MODULES=yes


3. ทำการติดตั้ง PHP5

cd /usr/ports/lang/php5
make all install clean

จะมี box ให้เราเลือกครับ ให้เลือก Apache ด้วยครับ

lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk
x Options for php5 5.2.6 x
x lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk x
x x[X] CLI Build CLI version x x
x x[X] CGI Build CGI version x x
x x[X] APACHE Build Apache module x x
x x[ ] DEBUG Enable debug x x
x x[X] SUHOSIN Enable Suhosin protection system (not for jails) x x
x x[ ] MULTIBYTE Enable zend multibyte support x x
x x[X] IPV6 Enable ipv6 support x x
x x[ ] MAILHEAD Enable mail header patch x x
x x[ ] REDIRECT Enable force-cgi-redirect support (CGI only) x x
x x[ ] DISCARD Enable discard-path support (CGI only) x x
x x[X] FASTCGI Enable fastcgi support (CGI only) x x
x x[X] PATHINFO Enable path-info-check support (CGI only) x x
x x x x
x x x x
x x x x
tqmqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqjqu
x [ OK ] Cancel x
mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj

4. หลังจากติดตั้ง PHP เสร็จ เราก็ทำการติดตั้ง php5-extentions ต่อครับ โดยพวก php5-mysql, php5-gd อะไรพวกนี้ php จะมองว่าเป้น extentions เวลาติดตั้งให้เลือกเอาแค่ extention ที่เราต้องการแค่นั้นพอครับ

cd /usr/ports/lang/php5-extensions/
make all install clean

จะมี box ให้เลือกเราก็เลือกเอาแค่ใช้งานครับ หากเลือก extentions มากแล้วไม่ได้ใช้งาน มันก็จะไปโหลดเครื่อง อันนี้เจอกับตัวเองครับ

lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk
x Options for php5-extensions 1.1 x
x lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk x
x x [ ] BCMATH bc style precision math functions x x
x x [ ] BZ2 bzip2 library support x x
x x [ ] CALENDAR calendar conversion support x x
x x [ ] CTYPE ctype functions x x
x x [ ] CURL CURL support x x
x x [ ] DBA dba support x x
x x [ ] DBASE dBase library support x x
x x [ ] DOM DOM support x x
x x [ ] EXIF EXIF support x x
x x [ ] FILEINFO fileinfo support x x
x x [ ] FILTER input filter support x x
x x [ ] FRIBIDI FriBidi support x x
x x [ ] FTP FTP support x x
x x [ ] GD GD library support x x
x x [ ] GETTEXT gettext library support x x
tqmqqqqqqqv(+)qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqjqu
x [ OK ] Cancel x
mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj

6. ต่อไปก็จะเป็นการ config apache ให้สามารถใช้งาน php ได้ครับ ส่วนตัวแล้ว ผมจะไม่ทำการแก้ไขไฟล์์ config ของ apche ตรงๆเพราะ apache จะเปิดให้ทำการ include ไฟล์ *.conf อยู่แล้ว เวลา config เราก็สร้างไฟล์ 0default.conf ไว้้ที่ /usr/local/etc/apache2/Includes apache ก็จะทำการโหลด config ของเราเองครับ (เวลา backup หรือติดตั้งใหม่ ง่ายดีครับ)

vi /usr/local/etc/apache2/Includes/0default.conf
Timeout 60
KeepAlive Off
 
StartServers            16
MinSpareServers         10
MaxSpareServers         40
ServerLimit             500
MaxClients              500
MaxRequestsPerChild     1000
 
ServerAdmin     webmaster@howtoconfig.com
ServerName      kumandtong.howtoconfig.com
ServerTokens    Prod
ServerSignature Off
 
DocumentRoot    "/usr/local/www/data"
 
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
DirectoryIndex index.php index.php3 index.html index.htm
 
ExtendedStatus On
 
SetHandler server-status
Order deny,allow
Deny from all
Allow from all
 
NameVirtualHost         *:80
 
DocumentRoot    "/usr/local/www/data"

6. ทำการแก้ไขให้ apache start ทุกครั้งที่ เปิดเครื่อง

echo 'apache2_enable="YES"' >> /etc/rc.conf

เป็นอันจบพิธีครับ

ต่อตอน 2 เรื่อง “Apache2.0 + Name Base Vhost

Tags: , ,


4 Responses to “Apache2.0 + PHP5 on FreeBSD”

  1. repair credit Says:

    Nice Site!
    http://google.com

  2. Seo Says:

    Well some like this way, Buy I think you should consider the another side of the toppic too. Thanks

  3. How to Config » Blog Archive » Apache 2.0 - Name Base VHost Says:

    [...] หลังจากที่ติดตั้ง “Apache2.0 + PHP5 on FreeBSD” ก็ถึงครามาทำ Name Base Vhost ในรูปแบบของผม [...]

  4. Andrew Says:

    LOL
    that doesn’t even make any sense!

Leave a Reply