安裝 MYSQL55-SERVER + APACHE22 + PHP53 + PHP53-EXTENSIONS
2012.09.02(週日) PM 07:16 整理
=======================================
開始安裝:THE START
=======================================
1、安裝好 FreeBSD 9.0-release
2、網路校時:ntpdate time.stdtime.gov.tw
3、把使用者加入到 wheel 群組,才能遠端登入。
# ee /etc/group
wheel:*:0:root,user
4、修改/etc/make.conf 在最前面加入
# ee /etc/make.conf
WITHOUT_X11=YES //安裝的時候才不會把X-Windows 相關的程式加進來。
SUP_UPDATE=yes
SUP=/usr/local/bin/csup //用於使用 Ports 安裝的路徑
SUP=/usr/bin/csup //用於 Base System 的路徑
SUPFLAGS= -g -L 2
SUPHOST=cvsup.tw.FreeBSD.org
SUPFILE= /usr/share/examples/cvsup/stable-supfile
PORTSSUPFILE=/usr/share/examples/cvsup/ports-supfile
MASTER_SITE_BACKUP?= \
ftp://ftp7.tw.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/\
ftp://ftp5.tw.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/\
ftp://ftp10.tw.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/\
ftp://ftp13.tw.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/\
ftp://ftp14.tw.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/\
ftp://ftp15.tw.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/\
ftp://ftp9.tw.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/\
ftp://ftp2.tw.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/\
ftp://ftp12.tw.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/\
ftp://ftp6.tw.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/\
ftp://ftp11.tw.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/\
ftp://ftp8.tw.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/\
ftp://ftp3.tw.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/\
ftp://ftp4.tw.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/\
ftp://ftp.tw.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/
MASTER_SITE_OVERRIDE?= ${MASTER_SITE_BACKUP}
5、用 portsnap 更新所有 port tree
# ee /etc/portsnap.conf
# SERVERNAME=portsnap.FreeBSD.org //預設值
SERVERNAME=portsnap.tw.FreeBSD.org //修改為離我們較近的主機
第一次使用 Portsnap 時需先取得 Ports System 的 Snapshot 並解開,鍵入如下指令即可:
# portsnap fetch extract
第二次以後就用下列的指令就行了:
# portsnap fetch update
6、PERL5.8-->> perl-5.8.9_7
# cd /usr/ports/lang/perl5.8
# make ENABLE_SUIDPERL=yes install clean
//Options 選下列一項:
[X] SUIDPERL Build set-user-id suidperl binary
# rehash
# sync;sync;sync;reboot (要重新開機)
// ENABLE_SUIDPERL=yes // 此選項用於安裝:Openwebmail
7、SUDO-->> sudo-1.8.5.p3
# cd /usr/ports/security/sudo
# make install clean
# rehash
# visudo
加入下列兩行:
User_Alias ADMIN = user
ADMIN ALL=(ALL) NOPASSWD : ALL
( 退出重新進入就可以用 sudo su - 而不用打 root 密碼了。)
8、OPENSSH-->> openssh-portable-5.8.p2_3,1
# cd /usr/ports/security/openssh-portable
# make install clean
//Options 預設的就好了。
# rehash
//安裝完後的訊息如下:
To enable this port, add openssh_enable="YES" in your rc.conf. To
prevent conflict with openssh in the base system add sshd_enable="NO"
in your rc.conf. Also you can configure openssh at another TCP port (via
sshd_config 'Port' and 'Listen' options or via 'openssh_flags'
variable in rc.conf) and run it in same time with base sshd.
'PermitRootLogin no' is the default for the OpenSSH port.
This now matches the PermitRootLogin configuration of OpenSSH in
the base system. Please be aware of this when upgrading your
OpenSSH port, and if truly necessary, re-enable remote root login
by readjusting this option in your sshd_config.
Users are encouraged to create single-purpose users with ssh keys
and very narrowly defined sudo privileges instead of using root
for automated tasks.
# ee /usr/local/etc/ssh/sshd_config
加入下列三行:
Port 22 //( port 號可以自己改變)
Protocol 2
AllowUsers user
# ee /etc/rc.conf
加入下列二行:
sshd_enable="NO"
openssh_enable="YES"
# sync;sync;sync;reboot //(重新開機)
9、MYSQL55-SERVER-->> mysql-server-5.5.27
cd /usr/ports/databases/mysql55-server
make WITH_CHARSET=big5 WITH_XCHARSET=all BUILD_OPTIMIZED=yes BUILD_STATIC=yes install clean
# rehash
ee /etc/rc.conf
mysql_enable="YES"
sudo /usr/local/etc/rc.d/mysql-server start
/usr/local/bin/mysqladmin -u root -p password 'new password'
Enter password: (第一次安裝無密碼,所以按Enter即可)
10、APACHE22-->> apache-2.2.22_6
cd /usr/ports/www/apache22
make install clean
//會出現一選單畫面,選擇MySQL(支援MySQL)。
//Options選一項:
[X]MYSQL apu was build with MySQL
ee /etc/rc.conf
apache22_enable="YES"
/usr/local/etc/rc.d/apache22 restart
11、PHP53-->> php53-5.3.16
cd /usr/ports/lang/php53
make install clean
//Options 選下列兩項:
[X]APACHE Build Apache module
[X]MULTIBYTE zend multibyte support
# rehash
//安裝 php53 後的訊息:
***************************************************************
Make sure index.php is part of your DirectoryIndex.
You should add the following to your Apache configuration file:
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
***************************************************************
# ee /usr/local/etc/apache22/httpd.conf
//加兩行:
AddType application/x-httpd-php .php .php3
AddType application/x-httpd-php-source .phps
//原來的設定:
# DirectoryIndex index.html
# 修改後的:
DirectoryIndex index.php index.php3 index.htm index.html
//先複製 php.ini 設定檔,以後就是設定這個檔就行了。
# cp /usr/local/etc/php.ini-production /usr/local/etc/php.ini
12、PHP53-EXTENSIONS-->> php53-extensions-1.6
cd /usr/ports/lang/php53-extensions
make install clean
//Options 選下列 9 項:
[X] EXIF
[X] GD
[X] GETTEXT
[X] MBSTRING
[X] MCRYPT
[X] MYSQL
[X] MYSQLI
[X] ZIP
[X] ZLIB
ee /usr/local/www/apache22/data/test.php
//內容如下:
<?php
phpinfo();
?>
13、wget -->> wget-1.13.4_1
# cd /usr/ports/ftp/wget
# make install clean
# rehash
14、gnuls -->> gnuls-8.12
cd /usr/ports/misc/gnuls
make install clean
//加一行在最底下,讓目錄變成彩色的:
alias ls 'gnuls --color=auto --show-control-chars'
//不必安裝軟體也可以讓目錄與檔案產生彩色的。
//以下會產生彩色目錄與檔名。而且會補與秀目錄有的字。
# ee /etc/csh.cshrc
setenv LESSCHARSET latin1
setenv LC_TIME C
alias ls env LC_CTYPE=en_US.ISO8859-1 \ls
set dspmbyte=big5
setenv CLICOLOR
set color
setenv LSCOLORS ExGxFxdxCxDxDxBxBxExEx
set autolist
#set nobeep //會發生嗶嗶叫的聲音。
//加下列二行,可以顯示中文檔案與目錄,只要加在/etc/csh.cshrc,不必在/etc/csh.login設定。
# ee /etc/csh.cshrc
setenv LC_CTYPE en_US.ISO8859-1
setenv LANG zh_TW.Big5
# 下面這一行會產生亂碼,所以要拿掉。101.08.19 AM:12:50發現的。
# setenv LC_ALL zh_TW.Big5
15、imageMagick -->> ImageMagick-nox11-6.7.8_6
# cd /usr/ports/graphics/ImageMagick
# make install clean
# rehash
//預設的就可以了。
//圖形處理工具:
//如果成功可以在系統中找到:convert 這個檔案,它可以產生縮圖功能。
# /usr/local/bin/convert
16、phpmyadmin -->> phpmyadmin-3.5.2_2
//方法1:
# cd /usr/ports/databases/phpmyadmin
# make install clean
# rehash
//方法2:
# cd /usr/local/www/
# wget http://sourceforge.net/projects/phpmyadmin/files/phpMyAdmin/3.5.2.2/phpMyAdmin-3.5.2.2-all-languages.zip
# unzip phpMyAdmin-3.5.2.2-all-languages.zip
# mv phpMyAdmin-3.5.2.2-all-languages.zip phpMyAdmin
# ee /usr/local/etc/rc.d/httpd.conf
//加入下列幾行:
Alias /phpmyadmin/ “/usr/local/www/phpMyAdmin/"
Options none
AllowOverride Limit //另外可按照軟體開發者建議,進一步限制phpMyAdmin的使用者。
Order Deny,Allow
Deny from all
Allow from 127.0.0.1 .example.com //可以限制 IP 或 網域連線。
OR
Alias /phpmyadmin/ "/usr/local/www/phpMyAdmin/"
<Directory "/usr/local/www/phpMyAdmin/">
Options FollowSymLinks MultiViews
DirectoryIndex index.php
AllowOverride None
Order allow,deny
Allow from (your domain or ip)or (all)
</Directory>
//修改phpMyAdmin設定檔
# cd /usr/local/www/phpMyAdmin/
# cp ./libraries/config.default.php ./config.inc.php
# ee ./config.inc.php
--> $cfg['Servers'][$i]['auth_type'] = ‘cookie’ ; //原來的。
--> $cfg['Servers'][$i]['auth_type'] = ‘http’ ; //修改後。
=======================================
結束安裝:THE END
=======================================
=======================================
=======================================
# 自己測試主機的內容:
ee /etc/rc.conf
hostname="your domain name"
keymap="hy.armscii-8.kbd"
ifconfig_re0=" inet (your ipv4 ip) netmask 255.255.255.0 "
defaultrouter="(your ipv4 router)"
ifconfig_re0_ipv6="inet6 accept_rtadv"
sshd_enable="YES"
ntpd_enable="YES"
# Set dumpdev to "AUTO" to enable crash dumps, "NO" to disable
dumpdev="NO"
apache22_enable="YES"
apache22_http_accept_enable="YES"
mysql_enable="YES"
# IPV6 設定
ipv6_enable="YES"
ipv6_network_interfaces="re0" //網路代號
ipv6_ifconfig_re0="ipv6 ip"
ipv6_defaultrouter="ipv6 router"
inetd_enable="YES"
sendmail_enable="NONE"
ntpdate_flags="watch.stdtime.gov.tw" //開機就網路校時
ntpdate_enable="YES"
//dns 啟動設定
named_enable="YES"
named_program="/usr/sbin/named"
named_flags="-c /etc/namedb/named.conf"
=======================================
=======================================