FreeBSD 6.2+APACHE+PHP+MYSQL WEB服務器入門級安裝與配置全教程 (2007-11-18 15:17)
分類: BSD WWW服務器架設
設置DNS
===========================================
ee /etc/resolv.conf
修改
nameserver 10.0.xx.xx
nameserver 10.0.xx.xx
#設置cvsup
#目前已經改用/usr/bin/csup 安裝FreeBSD時,已經安裝完成
#===========================================
#ee /usr/share/examples/cvsup/standard-supfile
#ee /usr/share/examples/cvsup/ports-supfile
# *default host=cvsup.freebsd.org
#cvsup -L 2 -h cvsup.freebsd.org /usr/share/examples/cvsup/standard-supfile
#rehash
#cvsup -L 2 -h cvsup.freebsd.org /usr/share/examples/cvsup/ports-supfile
#rehash
網絡優化
===========================================
ee /etc/sysctl.conf
net.inet.ip.check_interface=1
net.inet.tcp.blackhole=2
net.inet.udp.blackhole=1
net.inet.tcp.recvspace=65535
net.inet.tcp.sendspace=65535
kern.ipc.somaxconn=32768
kern.ipc.maxsockbuf=2097152
net.inet.ip.redirect=0
net.inet.icmp.icmplim=100
net.inet.tcp.always_keepalive=1
net.inet.tcp.delayed_ack=1
net.inet.udp.maxdgram=65535
net.local.stream.sendspace=65535
net.local.stream.recvspace=65535
kern.maxfiles=65536
kern.maxfilesperproc=65536
net.inet.udp.checksum=1
net.inet.tcp.msl=7500
net.inet.tcp.syncookies=1
net.inet.icmp.bmcastecho=0
net.inet.icmp.maskrepl=0
kern.securelevel=0
安裝多線程下載工具axel
===========================================
cd /usr/ports/ftp/axel
make install clean
rehash
ee /etc/make.conf
FETCH_CMD=axel
FETCH_BEFORE_ARGS= -n 10 -a
FETCH_AFTER_ARGS=
DISABLE_SIZE=yes
SUPFILE= /usr/share/examples/cvsup/stable-supfile
PORTSSUPFILE= /usr/share/examples/cvsup/ports-supfile
DOCSUPFILE= /usr/share/examples/cvsup/doc-supfile
# ..... FreeBSD distfiles mirror ..
SUP_UPDATE= yes
#SUP= /usr/local/bin/cvsup
SUP= /usr/bin/csup
SUPFLAGS= -g -L 2
MASTER_SITE_BACKUP?= \
ftp://ftp.tw.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/\
ftp://ftp2.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://ftp5.tw.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/\
ftp://ftp7.tw.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/\
ftp://ftp8.tw.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/\
ftp://ftp9.tw.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/
MASTER_SITE_OVERRIDE?= ${MASTER_SITE_BACKUP}
配置中文環境
===========================================
ee /.cshrc
set prompt = "%{^[[1m%}[%n@%m %{^[[33m%}%c%{^[[37m%}]%{^[[0m%} "
setenv LSCOLORS "gxfxcxdxbxegedabagacad"
alias date 'date "+%Y-%m-%d %H:%M:%S"'
setenv EDITOR ee
setenv LC_ALL zh_TW.Big5
setenv LANG zh_TW.Big5
setenv LC_CTYPE en_US.ISO8859-1
#big5cce - 繁體中文 Console 環境
# cd /usr/ports/outta-port/big5cce
# make install clean
安裝perl
===========================================
# cd /usr/ports/lang/perl5.8
# make install clean ; rehash
安裝openssl
===========================================
# cd /usr/ports/security/openssl
# make install clean ; rehash
安裝Ports檢查更新工具
===========================================
# cd /usr/ports/sysutils/portupgrade (找不到這個目錄,沒裝)
# make install clean ; rehash
安裝mysql
===========================================
cd /usr/ports/databases/mysql50-server/
make WITH_CHARSET=big5 WITH_XCHARSET=all WITH_PROC_SCOPE_PTH=yes BUILD_OPTIMIZED=yes BUILD_STATIC=yes SKIP_DNS_CHECK=yes WITHOUT_INNODB=yes install clean
ee /etc/my.cnf
[mysqld]
skip-networking
skip-innodb
skip-bdb
skip-name-resolve
skip-locking
#log-bin
# 2g server
key_buffer=512M
max_allowed_packet=4M
table_cache=1024
thread_cache=64
join_buffer_size=32M
sort_buffer=32M
record_buffer=32M
max_connections=512
wait_timeout=120
interactive_timeout=120
max_connect_errors=30000
long_query_time=1
max_heap_table_size=256M
tmp_table_size=128M
thread_concurrency=8
myisam_sort_buffer_size=128M
# cp /usr/local/etc/rc.d/mysql-server /usr/local/etc/rc.d/mysql.sh
# ee /etc/rc.conf
mysql_enable="YES"
/usr/local/etc/rc.d/mysql-server start
安裝apache22
===========================================
cd /usr/ports/www/apache22/
make WITH_MPM=worker WITHOUT_IPV6=yes WITH_THREADS=yes WITHOUT_SSL=yes install clean
安裝過程中,取消ipv6
apache隨系統啟動
# ee /etc/rc.conf
apache22_enable="YES"
啟動apache
/usr/local/etc/rc.d/apache22 start
安裝php
===========================================
cd /usr/ports/lang/php5
make WITHOUT_X11="YES" WITH_APACHE22=yes install clean
安裝過程中,選擇apache,取消ipv6
安裝php擴展
===========================================
cd /usr/ports/lang/php5-extensions
make install clean ; rehash
可以選擇
CALENDAR
CTYPE
GD
ICONV
MBSTRING
MYSQL
PCRE
SESSION
SOCKETS
ZIP
ZLIB
配置php
===========================================
# cd /usr/local/etc
# cp php.ini-recommended php.ini
# ee php.ini
disable_functions = passthru, exec, phpinfo, system, ini_alter, readlink, symlink, leak, proc_open, popepassthru, chroot, scandir, chgrp, chown, escapeshellcmd, escapeshellarg, shell_exec, proc_get_status
配置apache
===========================================
具體選項參考http://lamp.linux.gov.cn/Apache/ApacheMenu/index.html
cd /usr/local/etc/apache22/
cp httpd.conf httpd.conf.bak
ee /usr/local/etc/apache22/httpd.conf
DocumentRoot "/usr/www" # 網站主目錄
Options FollowSymLinks
DirectoryIndex index.html index.php index.htm
AddType application/x-gzip .gz .tgz
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
AddDefaultCharset big5
ServerTokens Prod
ServerSignature Email
StartServers 10
MinSpareServers 10
MaxSpareServers 15
ServerLimit 2000
MaxClients 1500
MaxRequestsPerChild 10000
安裝ZendOptimizer
===========================================
ZendOptimizer屬於商業軟件,所以不能通過ports編譯安裝,只能下載安裝
# ln -s /lib/libm.so.3 /lib/libm.so.2
# mount /cdrom
# cp -R /cdrom/Zend /usr/ports/devel/Zend
# cd /usr/ports/devel/zend
# ./install
一路默認
沒有留言:
張貼留言