FREEBSD升级及优化全攻略(中)
【FreeBSD教程】安装数据库MYSQL
安装mysql40-server和mysql40-client
进入/usr/ports/databases/mysql40-server
执行:
make clean
make deinstall
make WITH_OPENSSL=yes WITH_LINUXTHREADS=yes BUILD_OPTIMIZED=yes install
或者使用下面可参考的编译参数:BUILD_STATIC=yes
编译成静态执行版本
make clean
更改mysql的root密码:
mysqladmin –uroot –p password 123456
生成/etc/my.cnf,使用如下命令:
vi /etc/my.cnf
[client]
#password = your_password
port = 3306
socket = /tmp/mysql.sock
[mysqld]
skip-innodb
skip-locking
skip-networking
set-variable = port=3306
set-variable = socket=/tmp/mysql.sock
set-variable = back_log=50
set-variable = connect_timeout=3
set-variable = key_buffer=128M
set-variable = max_connections=1000
set-variable = max_allowed_packet=1M
set-variable = net_buffer_length=8K
set-variable = wait_timeout=3
set-variable = read_buffer_size=1M
set-variable = sort_buffer_size=1M
set-variable = table_cache=256
set-variable = myisam_sort_buffer_size=32M
set-variable = log_slow_queries=/var/log/log_slow_queries.log
#log-bin
server-id = 1
[mysqldump]
quick
set-variable = max_allowed_packet=16M
[mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates
[isamchk]
set-variable = key_buffer=20M
set-variable = sort_buffer=20M
set-variable = read_buffer=2M
set-variable = write_buffer=2M
[myisamchk]
set-variable = key_buffer=20M
set-variable = sort_buffer=20M
set-variable = read_buffer=2M
set-variable = write_buffer=2M
[mysqlhotcopy]
interactive-timeout
安装phpmyadmin
注重,此步骤需要在apache和php之后再执行
进入/usr/ports/databases/phpmyadmin
执行:
make clean
make deinstall
make install
make clean
新建立一个system的数据库备用。
安装FTP服务器
安装ftp软件(使用pure-ftpd/)
进入/usr/ports/ftp/pufe-ftpd
执行:
make clean
make deinstall
make WITH_MYSQL=1 install
或者使用下面可参考的编译参数:WITH_LANG=simplified-chinese
使用简体中文语言包
make clean
配置pure-ftpd,主要需要做以下的工作:
cp /usr/local/etc/pure-ftpd.conf.sample /usr/local/etc/pure-ftpd.conf
cp /usr/local/etc/pureftpd-mysql.conf.sample /usr/local/etc/pureftpd-mysql.conf
再修改/usr/local/etc/pure-ftpd.conf的如下部份为:
NoAnonymous yes
MySQLConfigFile /usr/local/etc/pureftpd-mysql.conf
再修改/usr/local/etc/pureftpd-mysql.conf的如下部份为您的设定值:
# Mandatory : user to bind the server as.
MYSQLUser demo
# Mandatory : user password. You must have a password.
MYSQLPassword demo
# Mandatory : database to open.
MYSQLDatabase demo
再进入使用mysql –uroot –p123456 进入mysql的文本方式﹔
使用如下命令建立新表:
use system;
DROP TABLE IF EXISTS users;
CREATE TABLE users (
User varchar(16) NOT NULL default '',
status enum('0','1') NOT NULL default '0',
Password varchar(64) NOT NULL default '',
Uid varchar(11) NOT NULL default '-1',
Gid varchar(11) NOT NULL default '-1',
Dir varchar(128) NOT NULL default '',
ULBandwidth smallint(5) NOT NULL default '0',
DLBandwidth smallint(5) NOT NULL default '0',
comment tinytext NOT NULL,
ipaccess varchar(15) NOT NULL default '*',
QuotaSize smallint(5) NOT NULL default '0',
QuotaFiles int(11) NOT NULL default 0,
PRIMARY KEY (User),
UNIQUE KEY User (User)
) TYPE=MyISAM;
安装pureftpd_php_manager
下载pureftpd_php_manager.zip
解压并放到指定的目录里面,比如:
/usr/local/www/data
chmod –R 755 /usr/local/www/data/pureftpd_php_manager
再加入一个普通用户和一个群组,以供ftp使用:
pw groupadd ftpusers
pw useradd ftpuser –g ftpusers –s /sbin/nologin
记住他们的uid和gid号,备用!
进入并编辑pureftp.config.php文件
更改里面的如下行:
$PUREFTP_CONFIG_FILE = '/usr/local/etc/pureftpd-mysql.conf';^M
$DefaultUser = "ftpuser"; # Default User Logon^M
$DefaultPass = ""; # Default User Password^M
$DefaultUid = "1002"; # Default User ID ( must be a re
al user acct )^M
$DefaultGid = "1001"; # Default Group ID ( must be a r
eal group acct )^M
$DefaultDir = "/home"; # Default User Dir ( use
/./ at the end to chroot )^M
$DefaultUL = "0"; # Default Upload Throttl
e ( 0 disables it )^M
$DefaultDL = "0"; # Default Download Throt
tle ( 0 disables it )^M
$Defaultip = "*"; # Default IP restriction
s ( * = any IP )^M
$DefaultQS = "200"; # Default Quota Size ( 0 disable
s it )^M
$Defaultcmt = ""; # Default Comment for us
er^M
^M
// UA^M
$DefaultQF = "0"; # Default Quota Files ( 0 disabl
安装APACHE服务器
安装apache13-modssl
进入/usr/ports/www/apache13-modssl
执行:
make clean
make deinstall
make WITH_APACHE_SUEXEC=yes APACHE_HARD_SERVER_LIMIT=1024 APACHE_PERF_TUNING=yes install
编译时带上suexec和优化。
Make clean
取消所有Options里面的Indexes,禁止浏览目录及文件。
设置KeepAlive Off
安装PHP语言
安装php
进入/usr/ports/www/mod_php4
执行:
make clean
make deinstall
make install
编译常用的选项即可,一定记得选择上mysql和gd。
Make clean
安装完成后,在/usr/local/etc/apache/httpd.conf里面,加入如下内容:
AddType application/x-httpd-php .php .php3 .php4 .phtml
AddType application/x-httpd-php-source .phps
替换DirectoryIndex细节为:
<IfModule mod_dir.c>
DirectoryIndex index.html index.htm index.wml index.cgi index.shtml index.jsp index.js index.jp index.php4 index.php3 index.php index.phtml default.htm default.html home.htm
</IfModule>
再cp php.ini-recommended /etc/php.ini
以及修改php.ini里面的参数
vi /etc/php.ini
修改下面两处为:
register_globals = On
magic_quotes_gpc = On
安装ZendOptimizer
先下载ZendOptimizer-2.1.0b-FreeBSD4.0-i386.tar.gz
再执行
tar zxvf ZendOptimizer-2.1.0b-FreeBSD4.0-i386.tar.gz
cd ZendOptimizer-2.1.0b-FreeBSD4.0-i386
sh setup
即可完成傻瓜式的安装。
注重:此时您的php.ini配置文件,一般会移到
/usr/loca/Zend/etc/php.ini
并且底部会增加以下几行:
[Zend]
zend_optimizer.optimization_level=15
zend_extension_manager.optimizer=/usr/local/Zend/lib/Optimizer-2.1.0
zend_extension_manager.optimizer_ts=/usr/local/Zend/lib/Optimizer_TS-2.1.0
zend_extension=/usr/local/Zend/lib/ZendExtensionManager.so
zend_extension_ts=/usr/local/Zend/lib/ZendExtensionManager_TS.so
您可以根据需要,改变15为1023,来提升加速的等级。