欢迎爱好Freebsd的朋友进行交流。我的BBS:bbs.22sun.comFreebsd4.11 - kern - cvsup - ports - mysql1.安装FBSD 编译内核
# ee /etc/rc.conf
sendmail_enable="NONE"
sendmail_submit_enable="NO"
sendmail_outbound_enable="NO"
sendmail_msp_queue_enable="NO"
加入下面的内容:
kern_securelevel_enable="YES"
kern_securelevel="-1"
第一句是打开安全等级,第二句是定义等级。它一共五个等级,下面说说不同之处。
* kern_securelevel -1:这是系统默认级别,没有提供任何内核的保护错误;
* kern_securelevel 0:基本上作用不多,当你的系统刚启动就是0级别的,当进入多用户
模式的时候就自动变成1级了。
* kern_securelevel 1:在这个级别上,有如下几个限制:
a. 不能通过kldload或者kldunload加载或者卸载可加载内核模块;
b. 应用程序不能通过/dev/mem或者/dev/kmem直接写内存;
c. 不能直接往已经装在(mounted)的磁盘写东西,也就是不能格式化磁盘,但是可以通过标
准的内核接口执行写操作;
d. 不能启动X-windows,同时不能使用chflags来修改文件属性;
* kern_securelevel 2:在 1 级别的基础上还不能写没装载的磁盘,而且不能在1秒之内制
造多次警告,这个是防止DoS控制台的;
* kern_securelevel 3:在 2 级别的级别上不允许修改IPFW防火墙的规则。
如果你已经装了防火墙,并且把规则设好了,不轻易改动,那么建议使用3级别,如果你没有
装防火墙,而且还准备装防火墙的话,不建议使用。我们这里推荐使用 2 级别,能够避免比
较多对内核攻击。
/usr/ports/net/cvsup
make installweb# ee /usr/share/examples/cvsup/ports-supfile
*default host=cvsup3.freebsdchina.orgweb# cvsup -g -L 2 /usr/share/examples/cvsup/ports-supfileweb# cd /usr/portsweb# make fetchindex2.使用Ports方式安装部分工具软件
web# cd /usr/ports/textproc/expat2web# make deinstallweb# make install
web# cd /usr/ports/devel/gettextweb# make deinstall clean
web# cd /usr/ports/devel/zziplibweb# make install clean
web# cd /usr/ports/devel/readlineweb# make install clean
web# cd /usr/ports/lang/perl5.8web# make install
web# /usr/local/bin/use.perl port
web# cd /usr/ports/devel/glib20web# make install clean
web# cd /usr/ports/devel/gmakeweb# make install clean
web# cd /usr/ports/lang/gcc40web# make install clean
web# cd /usr/ports/security/opensslweb# make install clean
web# pkg_delete linux_base-6.1_6web# cd /usr/ports/emulators/linux_baseweb# make install clean
web# cd /usr/ports/archivers/zipweb# make install clean
web# cd /usr/ports/archivers/rar #5.3以上版本才能升级
web# make install
web# cd /usr/ports/archivers/gzipweb# make install
web# cd /usr/ports/security/p5-Digest-MD5web# make install
web# cd /usr/ports/security/p5-Authen-PAMweb# make install
web# cd /usr/ports/security/p5-Net-SSLeayweb# make install clean
3.使用Ports方式安装MySQLweb# cd /usr/ports/databases/mysql41-server
web# make WITH_CHARSET=gbk WITH_XCHARSET=all WITH_OPENSSL=yes DB_DIR=/var/db/mysql SKIP_DNS_CHECK=yes BUILD_OPTIMIZED=yes install
##安装DBI和DBD for mysql 用于提供perl访问mysql数据库的接口规范,
请确认你已经安装了perl,一般默认系统都装上了
web# cd /usr/ports/databases/p5-DBD-mysql
web# make install
web# cd /usr/ports/security/pam-mysqlweb# make install
web# cp /usr/local/share/mysql/my-medium.cnf /etc/my.cnf
web#/usr/local/bin/mysql_install_db
web#/usr/local/bin/mysqld_safe --user=mysql &
# chown -R mysql / var / db /mysql
随系统一起启动的方式
ee /etc/rc.conf
mysql_enable="YES"
命令启动mysql的方式:
#/usr/local/share/mysql/mysql.server start
#/usr/local/etc/rc.d/mysql-server.sh start
# netstat -atln
看看有没有3306的端口打开,如果mysqld不能启动,看看/web/mysql/var下的出错日志,一般都
是目录权限没有设置好的问题
启动MYSQL 就设置密码
设置mysql40的密码
# /usr/local/bin/mysqladmin -u root -p password ' 输入MYSQL的ROOT账号的密码 '
# mysql -uroot -p
# 输入你设置的密码
mysql>use mysql;
mysql>delete from user where password=""; #删除用于本机匿名连接的空密码帐号
mysql>flush privileges;
mysql>quit
#reboot
4.ports安装 APACHE 22服务器
# /usr/ports/www/apache22
# make installweb# cd /usr/ports/www/mod_limitipconn2web# make install
随系统一起启动的方式
# ee /etc/rc.conf
# apache22_enable="YES"
# ee /usr/local/etc/apache22/httpd.conf
找到这行
<IfModule mime_module>
在这里添加PHP的代码
LoadModule limitipconn_module libexec/apache2/mod_limitipconn.soAddType application/x-httpd-php .phpAddType application/x-httpd-php-source .phpsDirectoryIndex index.php index.htmlAddDefaultCharset GB2312
httpd-vhosts.conf 设置
<Directory "/usr/local/www/apache22/">
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>
<Directory "/usr/local/www/apache22/cgi-bin">
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>
<IfModule alias_module>
ScriptAlias /cgi-bin/ "/usr/local/www/apache22/cgi-bin/"
</IfModule>
<IfModule dir_module>
DirectoryIndex index.html index.htm index.php index.pl index.jsp
</IfModule>
ee /extra/httpd-languages.conf
使用Ports方式安装turck-mmcacheweb# cd /usr/ports/www/turck-mmcacheweb# make install cleanweb# mkdir /tmp/mmcacheweb# chmod -R 0755 /tmp/mmcacheweb# chown -R www:www /tmp/mmcache
5,安装PHP5cd /usr/ports/lang/php5
make
make install
将MYSQL整合到PHP里
cd /usr/ports/lang/php5-extensions
make
make install
选择
CALENDARCTYPEGDICONVMBSTRINGMYSQLPCRESESSIONSOCKETSZIPZLIB
支持 png gif jpeg 格式的文件安装GD的方法
# cd /usr/ports/graphics/gd/
# make install
# cd /usr/ports/graphics/php5-gd/
# make install
cd /usr/ports/www/phpSysInfo/
make install
cd /usr/local/www/data/phpSysInfo/
cp config.php.new config.php
chown www.www config.php
(改变config.php的所属组和用户)
web# mv /usr/local/etc/php.ini-dist /usr/local/etc/php.iniweb# ee /usr/local/etc/php.inisession.save_path = /tmp/sessionmax_execution_time=60memory_limit=20Mpost_max_filesize=10Mfile_uploads=onupload_max_filesize=10M
5安装FTP服务器
#############################安装ftp服务器pure-ftpd#############################
cd /usr/ports/ftp/pure-ftpd
ee /usr/ports/ftp/pure-ftpd/Makefile
添加
--with-everything \
--with-paranoidmsg \
--with-virtualchroot \
--with-tls \
--with-largefile \
--with-welcomemsg \
--with-uploadscript \
--with-cookie \
--with-virtualhosts \
--with-virtualroot \
--with-diraliases \
--with-quotas \
--with-sysquotas \
--with-ratios \
--with-ftpwho \
--with-throttling \
--sysconfdir=${PREFIX}/etc
make WITH_MYSQL=1 \ WITH_LANG=simplified-chinese install (+mysql +utf8)
cd /usr/local/etc
cp pureftpd-mysql.conf.sample pureftpd-mysql.conf
cp pure-ftpd.conf.sample pure-ftpd.conf
ee /etc/rc.conf
pureftpd_enable="YES"
ee /usr/local/etc/pure-ftpd.confee /usr/local/etc/pureftpd-mysql.conf
pure-ftpd.conf配置文件
###############################################################################
# #
# Configuration file for pure-ftpd wrappers
#
# #
###############################################################################
# If you want to run Pure-FTPd with this configuration
# instead of command-line options, please run the
# following command :
#
# /usr/local/pureftpd/sbin/pure-config.pl /usr/local/pureftpd/etc/pure-ftpd.conf
#
# RPM binary files use another configuration file by default :
# /etc/sysconfig/pure-ftpd
#
# Please don't forget to have a look at documentation at
# http://www.pureftpd.org/documentation.html for a complete list of
# options.
# Cage in every user in his home directory
ChrootEveryone yes
# If the previous option is set to "no", members of the following group
# won't be caged. Others will be. If you don't want chroot()ing anyone,
# just comment out ChrootEveryone and TrustedGID.
# TrustedGID 100
# Turn on compatibility hacks for broken clients
BrokenClientsCompatibility no
# Maximum number of simultaneous users
MaxClientsNumber 50
# Fork in background
Daemonize yes
# Maximum number of sim clients with the same IP address
MaxClientsPerIP 8
# If you want to log all client commands, set this to "yes".
# This directive can be duplicated to also log server responses.
VerboseLog no
# List dot-files even when the client doesn't send "-a".
DisplayDotFiles yes
# Don't allow authenticated users - have a public anonymous FTP only.
AnonymousOnly no
# Disallow anonymous connections. Only allow authenticated users.
NoAnonymous no
# Syslog facility (auth, authpriv, daemon, ftp, security, user, local*)
# The default facility is "ftp". "none" disables logging.
SyslogFacility ftp
# Display fortune cookies
# FortunesFile /usr/share/fortune/zippy
# Don't resolve host names in log files. Logs are less verbose, but
# it uses less bandwidth. Set this to "yes" on very busy servers or
# if you don't have a working DNS.
DontResolve yes
# Maximum idle time in minutes (default = 15 minutes)
MaxIdleTime 15
# LDAP configuration file (see README.LDAP)
# LDAPConfigFile /etc/pureftpd-ldap.conf
LDAPConfigFile /usr/local/pureftpd/etc/pureftpd-ldap.conf
# MySQL configuration file (see README.MySQL)
# MySQLConfigFile /etc/pureftpd-mysql.conf
MySQLConfigFile /usr/local/pureftpd/etc/pureftpd-mysql.conf
# Postgres configuration file (see README.PGSQL)
# PGSQLConfigFile /etc/pureftpd-pgsql.conf
PGSQLConfigFile /usr/local/pureftpd/etc/pureftpd-pgsql.conf
# PureDB user database (see README.Virtual-Users)
# PureDB /etc/pureftpd.pdb
PureDB /usr/local/pureftpd/etc/pureftpd.pdb
# Path to pure-authd socket (see README.Authentication-Modules)
# ExtAuth /var/run/ftpd.sock
# If you want to enable PAM authentication, uncomment the following line
# PAMAuthentication yes
# If you want simple Unix (/etc/passwd) authentication, uncomment this
# UnixAuthentication yes
# Please note that LDAPConfigFile, MySQLConfigFile, PAMAuthentication and
# UnixAuthentication can be used only once, but they can be combined
# together. For instance, if you use MySQLConfigFile, then UnixAuthentication,
# the SQL server will be asked. If the SQL authentication fails because the
# user wasn't found, another try # will be done with /etc/passwd and
# /etc/shadow. If the SQL authentication fails because the password was wrong,
# the authentication chain stops here. Authentication methods are chained in
# the order they are given.
# 'ls' recursion limits. The first argument is the maximum number of
# files to be displayed. The second one is the max subdirectories depth
LimitRecursion 2000 8
# Are anonymous users allowed to create new directories ?
AnonymousCanCreateDirs no
# If the system is more loaded than the following value,
# anonymous users aren't allowed to download.
MaxLoad 4
# Port range for passive connections replies. - for firewalling.
# PassivePortRange 30000 50000
# Force an IP address in PASV/EPSV/SPSV replies. - for NAT.
# Symbolic host names are also accepted for gateways with dynamic IP
# addresses.
# ForcePassiveIP 192.168.0.1
# Upload/download ratio for anonymous users.
# AnonymousRatio 1 10
# Upload/download ratio for all users.
# This directive superscedes the previous one.
# UserRatio 1 10
# Disallow downloading of files owned by "ftp", ie.
# files that were uploaded but not validated by a local admin.
AntiWarez yes
# IP address/port to listen to (default=all IP and port 21).
Bind 219.159.55.28,21
# Maximum bandwidth for anonymous users in KB/s
# AnonymousBandwidth 8
# Maximum bandwidth for *all* users (including anonymous) in KB/s
# Use AnonymousBandwidth *or* UserBandwidth, both makes no sense.
# UserBandwidth 8
# File creation mask. <umask for files>:<umask for dirs> .
# 177:077 if you feel paranoid.
Umask 133:022
# Minimum UID for an authenticated user to log in.
MinUID 100
# Allow FXP transfers for authenticated users only.
AllowUserFXP yes
# Allow anonymous FXP for anonymous and non-anonymous users.
AllowAnonymousFXP no
# Users can't delete/write files beginning with a dot ('.')
# even if they own them. If TrustedGID is enabled, this group
# will have access to dot-files, though.
ProhibitDotFilesWrite no
# Prohibit *reading* of files beginning with a dot (.history, .ssh...)
ProhibitDotFilesRead no
# Never overwrite files. When a file whoose name already exist is uploaded,
# it get automatically renamed to file.1, file.2, file.3, ...
AutoRename no
# Disallow anonymous users to upload new files (no = upload is allowed)
AnonymousCantUpload no
# Only connections to this specific IP address are allowed to be
# non-anonymous. You can use this directive to open several public IPs for
# anonymous FTP, and keep a private firewalled IP for remote administration.
# You can also only allow a non-routable local IP (like 10.x.x.x) to
# authenticate, and keep a public anon-only FTP server on another IP.
#TrustedIP 10.1.1.1
# If you want to add the PID to every logged line, uncomment the following
# line.
#LogPID yes
# Create an additional log file with transfers logged in a Apache-like format :
# fw.c9x.org - jedi [13/Dec/1975:19:36:39] "GET /ftp/linux.tar.bz2" 200 21809338
# This log file can then be processed by www traffic analyzers.
# AltLog clf:/var/log/pureftpd.log
# Create an additional log file with transfers logged in a format optimized
# for statistic reports.
# AltLog stats:/var/log/pureftpd.log
#AltLog stats:/var/log/pureftpd.log
# Create an additional log file with transfers logged in the standard W3C
# format (compatible with most commercial log analyzers)
# AltLog w3c:/var/log/pureftpd.log
# Disallow the CHMOD command. Users can't change perms of their files.
#NoChmod yes
# Allow users to resume and upload files, but *NOT* to delete them.
#KeepAllFiles yes
# Automatically create home directories if they are missing
#CreateHomeDir yes
# Enable virtual quotas. The first number is the max number of files.
# The second number is the max size of megabytes.
# So 1000:10 limits every user to 1000 files and 10 Mb.
#Quota 1000:10
# If your pure-ftpd has been compiled with standalone support, you can change
# the location of the pid file. The default is /var/run/pure-ftpd.pid
#PIDFile /var/run/pure-ftpd.pid
# If your pure-ftpd has been compiled with pure-uploadscript support,
# this will make pure-ftpd write info about new uploads to
# /var/run/pure-ftpd.upload.pipe so pure-uploadscript can read it and
# spawn a script to handle the upload.
#CallUploadScript yes
# This option is useful with servers where anonymous upload is
# allowed. As /var/ftp is in /var, it save some space and protect
# the log files. When the partition is more that X percent full,
# new uploads are disallowed.
MaxDiskUsage 99
# Set to 'yes' if you don't want your users to rename files.
#NoRename yes
# Be 'customer proof' : workaround against common customer mistakes like
# 'chmod 0 public_html', that are valid, but that could cause ignorant
# customers to lock their files, and then keep your technical support busy
# with silly issues. If you're sure all your users have some basic Unix
# knowledge, this feature is useless. If you're a hosting service, enable it.
CustomerProof yes
# Per-user concurrency limits. It will only work if the FTP server has
# been compiled with --with-peruserlimits (and this is the case on
# most binary distributions) .
# The format is : <max sessions per user>:<max anonymous sessions>
# For instance, 3:20 means that the same authenticated user can have 3 active
# sessions max. And there are 20 anonymous sessions max.
# PerUserLimits 3:20
pureftpd-mysql.conf配置文件
###############################################################################
# #
# Sample Pure-FTPd Mysql configuration file. #
# See README.MySQL for explanations. #
# #
###############################################################################
# Optional : MySQL server name or IP. Don't define this for unix sockets.
#MYSQLServer 127.0.0.1
# Optional : MySQL port. Don't define this if a local unix socket is used.
#MYSQLPort 3306
# Optional : define the location of mysql.sock if the server runs on this host.
MYSQLSocket /var/lib/mysql/mysql
.sock
# Mandatory : user to bind the server as.
MYSQLUser pureftpd
# Mandatory : user password. You must have a password.
MYSQLPassword qKiscCbwbXAkWp.
# Mandatory : database to open.
MYSQLDatabase pureftpd
# Mandatory : how passwords are stored
# Valid values are : "cleartext", "crypt", "md5" and "password"
# ("password" = MySQL password() function)
# You can also use "any" to try "crypt", "md5" *and* "password"
#MYSQLCrypt leartext
MYSQLCrypt crypt
# In the following directives, parts of the strings are replaced at
# run-time before performing queries :
#
# \L is replaced by the login of the user trying to authenticate.
# \I is replaced by the IP address the user connected to.
# \P is replaced by the port number the user connected to.
# \R is replaced by the IP address the user connected from.
# \D is replaced by the remote IP address, as a long decimal number.
#
# Very complex queries can be performed using these substitution strings,
# especially for virtual hosting.
# Query to execute in order to fetch the password
MYSQLGetPW SELECT Password FROM users WHERE User="\L"
# Query to execute in order to fetch the system user name or uid
MYSQLGetUID SELECT Uid FROM users WHERE User="\L"
# Optional : default UID - if set this overrides MYSQLGetUID
#MYSQLDefaultUID 1000
# Query to execute in order to fetch the system user group or gid
MYSQLGetGID SELECT Gid FROM users WHERE User="\L"
# Optional : default GID - if set this overrides MYSQLGetGID
#MYSQLDefaultGID 1000
# Query to execute in order to fetch the home directory
MYSQLGetDir SELECT Dir FROM users WHERE User="\L"
# Optional : query
to get the maximal number of files
# Pure-FTPd must have been compiled with virtual quotas support.
MySQLGetQTAFS SELECT QuotaFiles FROM users WHERE User="\L"
# Optional : query to get the maximal disk usage (virtual quotas)
# The number should be in Megabytes.
# Pure-FTPd must have been compiled with virtual quotas support.
MySQLGetQTASZ SELECT QuotaSize FROM users WHERE User="\L"
# Optional : ratios. The server has to be compiled with ratio support.
# MySQLGetRatioUL SELECT ULRatio FROM users WHERE User="\L"
# MySQLGetRatioDL SELECT DLRatio FROM users WHERE User="\L"
# Optional : bandwidth throttling.
# The server has to be compiled with throttling support.
# Values are in KB/s .
MySQLGetBandwidthUL SELECT ULBandwidth FROM users WHERE User="\L"
MySQLGetBandwidthDL SELECT DLBandwidth FROM users WHERE User="\L"
# Enable ~ expansion. NEVER ENABLE THIS BLINDLY UNLESS :
# 1) You know what you are doing.
# 2) Real and virtual users match.
# MySQLForceTildeExpansion 1
# If you upgraded your tables to transactionnal tables (Gemini,
# BerkeleyDB, Innobase...), you can enable SQL transactions to
# avoid races. Leave this commented if you are using the
# traditionnal MyIsam databases or old (< 3.23.x) MySQL versions.
# MySQLTransactions On
####################################建立ftp用户组##############################
pw groupadd ftpusers -g 2000
pw useradd pureftpd -u 2000 -g ftpusers -s /sbin/nologin
/usr/local/sbin/pure-config.pl /usr/local/etc/pure-ftpd.conf
也可以通过
/usr/local/etc/rc.d/pure-ftpd.sh start 我就这个启动的
提示一下信息证明pure-ftpd已经工作
Running: /usr/local/sbin/pure-ftpd -A -c50 -B -C8 -D -E -fftp -H -I15
-lmysql:/usr/local/etc/pureftpd-mysql.conf -L2000:8 -m4 -Q1:10 -s -U133:022
-u100 -Ow3c:/var/log/pureftpd.log -j -k99 -Z
# sockstat -4 查看端口号
#################################测试pureftp####################################
ftp 192.168.0.205Connected to 192.168.0.205.
220---------- 欢迎来到 Pure-FTPd [TLS] ----------
220-您是第 1 个使用者,最多可达 50 个连接
220-现在本地时间是 13:17。服务器端口: 21。
220-这是私人系统 - 不开放匿名登录
220-这部主机也欢迎IPv6的连接
220 在 15 分钟内没有活动,您被会断线。
Name (192.168.0.205:chb):
输入用户名、密码
http://machiel.generaal.net 下载最新的FTP管理程序
##################################设置ftp管理界面##############################
ee config.php
require 'language.php';
$LANG = $ZH_CN; //Language (Options are $
DUTCH, $ENGLISH, $PT_BR, $RUSSIAN
//$SPANISH, $COREAN, $FRENCH, $HUNGARIAN, $GERMAN
// $TURKISH, $DANISH , $NORWEGIAN or $ZH
_CN)
$LocationImages = "images"; // Location of images
$DBHost = "localhost"; // Ip-adres of MySQL server
// (Dont change this if you are using the default database)
$DBLogin = "ftp"; // Username of MySQL user
$DBPassword = "password"; // Password of MySQL user
$DBDatabase = "ftpusers"; // Name of database
##############################设置ftp管理的虚拟主机############################
ee /usr/local/etc/apache/httpd.conf
添加
<VirtualHost 192.168.0.205>
DocumentRoot "/home/chb/ftp"
ServerName www.chb.com
<Directory "/home/chb/ftp">
allow from all
Options +Indexes
</Directory>
</VirtualHost>
编辑httpd.confee /usr/local/etc/apache/httpd.conf
添加虚拟主机 passwd.chb.com
<VirtualHost 192.168.0.205>DocumentRoot /home/passwdServerName passwd.chb.com
<Directory "/home/passwd ">allow from allOptions +Indexes
</Directory>
</VirtualHost>
# sockstat -4 查看端口号
安装 WEBMIN
下载一个 WEBMIN webmin.com
# tar zxvf webmin-1.270.tar
# cd webmin-1.270
# ./setup.sh /usr/local/webmin
官方网站下载: pute-ftpd管理软件
网址:http://machiel.generaal.net/files/pureftpd/ftp_v2.1.tar.gz