2010年12月17日 星期五

Freebsd8.1安裝AMP套件紀錄

一切從Freebsd8.1安裝完畢,且可以SSH遠端登入說起。
參考資料:


檔案下載:freebsd8_1安裝AMP實做


修改 root 的個人設定
# ee /root/.cshrc

1.將 setenv EDITOR vi 這行改成:
setenv EDITOR ee

2.將 set prompt = "`hostname -s`# " 這行改成:
set prompt = "%B%n@%m [%/] # "

確定改完後,按 Esc 鍵,按 Enter 鍵存檔並離開 ee
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

修改所有使用者共通的設定
# ee /etc/csh.cshrc
然後將下面的三行加在該檔案的最後面:
setenv LC_CTYPE en_US.ISO_8859-1
set prompt = "%B%n@%m [%/] $ "
set autolist

上面修改的 *.cshrc 內容並不會馬上生效,如果立即要使用就執行 csh 的內部指令 source:

# source /etc/csh.cshrc
# source ~/.cshrc
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

加入不正常關機後自動檢查並繼續啟動
# ee /etc/rc.conf
加入
fsck_y_enable="YES"
background_fsck="NO"
tcp_drop_synfin="YES"
icmp_drop_redirect="YES"
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

對時
# ntpdate -b clock.stdtime.gov.tw
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

# cd /usr/share/examples/cvsup            //路徑
# cp ports-supfile /usr/                  //放到 /usr 下 (看你高興要放哪)
# cd /usr
# ee ports-supfile                        //修改原更新站台位置內容如下
  default host CHANGE_THIS.FreeBSD.org     //官方站台 (預設值)
  default host cvsup.tw.freebsd.org        //改為國內站台交大資工如此下載速度較快 (還有 cvsup1 ~ 15 都可使用)
# cd /usr                          //切換路徑
# rehash                           //才不會出現指令無效訊息 (csup: Command not found.)
# csup -L 2 ports-supfile          //開始更新 Ports Tree
# cd /usr/ports ; make fetchindex
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

安裝openssl
# cd /usr/ports/security/openssl
# make all install
# pkg_info
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

mysql:
# cd /usr/ports/databases/mysql51-server
# make WITH_CHARSET=big5 WITH_XCHARSET=utf8 WITH_OPENSSL=yes BUILD_OPTIMIZED=yes all install
# /usr/local/bin/mysql_install_db
# chown -R mysql:mysql /var/db/mysql

Apache:
# cd /usr/ports/www/apache22
# make config
必選的選項有:MYSQL,其它用預設即可。
# make install clean

PHP5:
# cd /usr/ports/lang/php5
# ee Makefile
將USE_APACHE= 13+
改成USE_APACHE= 22
# make config
必選選項有:APACHE,其它用預設即可。
# make install clean

php5-extensions:
# cd /usr/ports/lang/php5-extensions
# make config
   必選選項:
   GD、GETTEXT、ICONV、MBSTRING、MING、MYSQL、PDF、
   SESSION、XML、XMLREADER、XMLWRITER、ZLIB
   其它用預設即可。
# make install clean

中間突然說找不到此檔手動下載
# cd /usr/ports/distfiles/
# fetch ftp://ftp.freebsd.org/pub/FreeBSD/ports/distfiles/sqlite-src-3070400.zip
# cd /usr/ports/lang/php5-extensions
# make install clean

啟動 Apache 及 Mysql
# ee /etc/rc.conf    //加入以下內容:
apache22_enable="YES"
mysql_enable="YES"
#ee /usr/local/etc/apache22/httpd.conf    //加入以下內容:
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
//在DirectoryIndex 加入 index.php
DirectoryIndex index.php index.htm
#/usr/local/etc/rc.d/apache22 start
#/usr/local/etc/rc.d/mysql-server start

設定Mysql的root密碼 (假設密碼為happy_99)
#rehash
#mysqladmin -u root password 'happy_99'

重新啟動Apache
/usr/local/etc/rc.d/apache22 restart

# ee /usr/local/www/apache22/data/info.php
加入後存檔

瀏覽器:http://localhost/info.php
# rm -f /usr/local/www/apache22/data/info.php

基本FAMP安裝結束~~~耶

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

系統內核級優化+防止ddos
# ee /boot/loader.conf加入如下文本
kern.dfldsiz="2147483648"
kern.maxdsiz="2147483648"
kern.ipc.nmbclusters="0"
kern.ipc.nsfbufs="66560"   

# ee /etc/rc.local
sysctl kern.ipc.maxsockets=100000    ##增加並發的socket,對於ddos很有用
sysctl kern.ipc.somaxconn=65535      ##打開文件數
sysctl net.inet.tcp.msl=2500         ##timeout時間
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

沒有留言:

張貼留言