FreeBSD 7.0 Relese Apache MySQL PHP

第一次安裝 ports

# csup -L 2 -h cvsup4.tw.FreeBSD.org /usr/share/examples/cvsup/ports-supfile

其中的 cvsup4.tw.FreeBSD.org 是對我來說,連線速度比較快的站台。

將範例檔 copy 到 root 家目錄。

%cp /usr/share/examples/cvsup/ports-supfile /root/

% vi /root/ports-supfile



*host=CHANGE_THIS.FreeBSD.org

改為

*default host=cvsup4.tw.FreeBSD.org
以後更新 ports 時,改用如下指令。

%csup -g -L 2 /root/ports-supfile

更新 ports tree


*default host=CHANGE_THIS.FreeBSD.org

改成
*default host=cvsup4.tw.freebsd.org

安裝、設定 MySQL:


# cd /usr/port/databases/mysql51-server
# make WITH_CHARSET=utf8 BUILD_OPTIMIZED=yes BUILD_STATIC=yes install

開機的時候自動啟動 Services

# vi /etc/rc.conf

加上

mysql_enable="YES"

複製相關的設定檔來來修改:


# cp /usr/local/share/mysql/my-large.cnf /etc/my.cnf

修改 MySQL 的 root 密碼:


# mysql mysql

mysq> UPDATE user SET password=password('你的密碼') where user='root' ;

mysql>FLUSH PRIVILEGES ;

mysql>exit

# cp /usr/src/share/examples/etc/make.conf /etc/make.conf.example
# cp /etc/make.conf.example /etc/make.conf
# vi /etc/make.conf



#SUPHOST=        cvsup.uk.FreeBSD.org

改成

#SUPHOST=        cvsup4.tw.freebsd.org

安裝Apache22:


# cd /usr/ports/www/apache22/
# make install

# vi /usr/local/etc/apache22/httpd.conf

加上

AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

安裝PHP:


# cd /usr/port/lang/php5

# make config

#make install

安裝 extensions


# cd /usr/ports/lang/php5-extensions

因為可以裝的太多了,用 make config 來選擇比較方便:

# make config

選擇完後,開始編譯、安裝:

# make WITHOUT_X11=yes install

安裝 ImageMagick:


因為 Gallery2 等等會用到,且一般來說會比 GD2 的品質好,所以也裝一下:

# cd /usr/ports/graphics/ImageMagick
# make config

先選擇自己會需要的項目,記得 modules 要選,然後 X11 不要,不然會等到死。接著:

# make install

安裝 eAccelerator:


# cd /usr/ports/www/eaccelerator

直接安裝可能會有點問題(0.9.5,之後有修正了),詳細請參考 這篇,下面是修正的辦法:

# cd file

# wget http://www.joehorn.idv.tw/download/patch-debug.c

# make instll

這樣就安裝好了。然後編輯 /usr/local/etc/php/extensions.ini,在最後加上:
extension=eaccelerator.so

然後編輯 /usr/local/etc/php.ini,在最後加上:
eaccelerator.shm_size="16"
eaccelerator.cache_dir="/tmp/eaccelerator"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="0"
eaccelerator.shm_prune_period="0"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"

接著,依序輸入:
# mkdir /tmp/eaccelerator
# chown www /tmp/eaccelerator
# chmod 0777 /tmp/eaccelerator

接著重開 apache 即可。用 php -v 指令,應該可以看到 eAccelerator 的字樣。

都弄好了,最後 make clean 一下:

# cd /usr/port
# make clea

參考資料:

http://twntwn.info/blog/ajer001/archives/1596

[@more@]

留言

這個網誌中的熱門文章

電腦科評語

拔河技巧

三小時架好 FreeNAS 私有雲(3)