越简单越好!

freebsd7.1下apahce,mysql,php,ftp等安装配置

bevin 发表于 2009-05-08 21:51 | 23次阅读 0次推荐   Freebsd

1. 最简安装
选上ports
增加/data 目录


2. 配置好ip等信息,使其能上网


3. 增加ssh
#ee /etc/rc.conf
sshd_enable="YES"
#ee /root/.cshrc
添加
alias ls        ls -G
set prompt = "[%N@%m:%/]#"


4. 增加用户
#pw useradd cxh1984 -s /bin/csh -d /home/cxh1984 -m -g wheel -h 0


5. 更新ports
首先安装cvsup

#pkg_add -r cvsup   or
    #cd /usr/ports/net/cvsup
    #make install clean

系统自动上FreeBSD服务器上查找适合你所安装的BSD的打好的软件包,根据网络的速度,应该很快就可以安装完成。
接下来把文件/usr/share/examples/cvsup/ports-supfile复制到/root下
#cp /usr/share/examples/cvsup/ports-supfile ~/
然后编辑ports-supfile,把CHANGE_THIS.FreeBSD.org修改为离你最近的CVSup站点。如:cvsup.cn.FreeBSD.org。
最后运行命令cvsup更新Ports
#cd
#cvsup -g -L 2 ports-supfile (cvsup于/usr/local/bin/)

6. 安装mysql
#cd /usr/ports/database/mysql51-server
#make WITH_CHARSET=utf8
#make install clean
列改db目录
#/usr/local/bin/mysql_install_db --datadir=/data/db/mysql

#echo 'mysql_enable="YES"' >> /etc/rc.conf
#
echo 'mysql_dbdir="/data/db/mysql"' >> /etc/rc.conf
#chown -R mysql /usr/db/mysql

#/usr/local/etc/rc.d/mysql-server start
添加mysql用户
#mysql
GRANT ALL PRIVILEGES ON *.* TO IDENTIFIED BY 'password' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON *.* TO " IDENTIFIED BY 'password' WITH GRANT OPTION;


7. 安装apache22
#cd /usr/ports/www/apache22
#make
#make install clean
/etc/rc.conf 增加
apache22_enable="YES"
修改web目录 /data/webroot


8. 安装php
#cd /usr/ports/lang/php5
#make install clean
[X] APACHE     Build Apache module
[X] MULTIBYTE Enable zend multibyte support

#cd /usr/ports/lang/php5-extensions
#make install clean

#ee /usr/local/etc/apache2/httpd.conf
加入
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps

9. 安装ftp
#cd cd /usr/ports/ftp/proftpd
#make config
#make install clean

#echo 'proftpd_enable="YES"' >> /etc/rc.conf
#pw groupadd ftpgroup -g 2005
#pw adduser ftpuser -u 2005 -s /bin/false -d /bin/null -c "proftpd user" -g ftpgroup ftpuser


#mysql 增加表
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
create database ftpdb;
grant select, update on ftpdb.* to identified by '123456';
use ftpdb;

CREATE TABLE `ftpgroup` (
`groupname` varchar(16) NOT NULL default '',
`gid` smallint(6) NOT NULL default '2005',
`members` varchar(16) NOT NULL default '',
KEY `groupname` (`groupname`)
) TYPE=MyISAM COMMENT='ProFTP group table';

INSERT INTO `ftpgroup` VALUES ('ftpgroup', 2005, 'ftpuser');

CREATE TABLE `ftpquotalimits` (
`name` varchar(30) default NULL,
`quota_type` enum('user','group','class','all') NOT NULL default 'user',
`per_session` enum('false','true') NOT NULL default 'false',
`limit_type` enum('soft','hard') NOT NULL default 'soft',
`bytes_in_avail` float NOT NULL default '0',
`bytes_out_avail` float NOT NULL default '0',
`bytes_xfer_avail` float NOT NULL default '0',
`files_in_avail` int(10) unsigned NOT NULL default '0',
`files_out_avail` int(10) unsigned NOT NULL default '0',
`files_xfer_avail` int(10) unsigned NOT NULL default '0'
) TYPE=MyISAM;

CREATE TABLE `ftpquotatallies` (
`name` varchar(30) NOT NULL default '',
`quota_type` enum('user','group','class','all') NOT NULL default 'user',
`bytes_in_used` float NOT NULL default '0',
`bytes_out_used` float NOT NULL default '0',
`bytes_xfer_used` float NOT NULL default '0',
`files_in_used` int(10) unsigned NOT NULL default '0',
`files_out_used` int(10) unsigned NOT NULL default '0',
`files_xfer_used` int(10) unsigned NOT NULL default '0'
) TYPE=MyISAM;

CREATE TABLE `ftpuser` (
`id` int(10) unsigned NOT NULL auto_increment,
`userid` varchar(32) NOT NULL default '',
`passwd` varchar(32) NOT NULL default '',
`uid` smallint(6) NOT NULL default '2005',
`gid` smallint(6) NOT NULL default '2005',
`homedir` varchar(255) NOT NULL default '',
`shell` varchar(16) NOT NULL default '/sbin/nologin',
`count` int(11) NOT NULL default '0',
`host` varchar(30) NOT NULL default '000-000-000-000',
`lastlogin` datetime NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY (`id`)
) TYPE=MyISAM COMMENT='ProFTP user table';
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------

#proftpd.conf 配置
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
#
# For more informations about Proftpd configuration
# look at : http://www.proftpd.org/
#
# This is a basic ProFTPD configuration file (rename it to
# 'proftpd.conf' for actual use. It establishes a single server
# and a single anonymous login. It assumes that you have a user/group
# "nobody" and "ftp" for normal operation and anon.

ServerName    "DFA FTP Server"
ServerType    standalone
#ServerAdmin   

DefaultServer    on
#ScoreboardFile   /var/run/proftpd/proftpd.scoreboard

# Port 21 is the standard FTP port.
Port     21

# Use IPv6 support by default.
#UseIPv6     on

# Umask 022 is a good standard umask to prevent new dirs and files
# from being group and world writable.
Umask     022

# To prevent DoS attacks, set the maximum number of child processes
# to 30. If you need to allow more than 30 concurrent connections
# at once, simply increase this value. Note that this ONLY works
# in standalone mode, in inetd mode you should use an inetd server
# that allows you to limit maximum number of processes per service
# (such as xinetd).
MaxInstances    30

CommandBufferSize 512

# Set the user and group under which the server will run.
User     ftpuser
Group     ftpgroup

# To cause every FTP user to be "jailed" (chrooted) into their home
# directory, uncomment this line.
DefaultRoot ~

# Normally, we want files to be overwriteable.
AllowOverwrite   on

# Bar use of SITE CHMOD by default
#<Limit SITE_CHMOD>
# DenyAll
#</Limit>

# A basic anonymous configuration, no upload directories. If you do not
# want anonymous users, simply delete this entire <Anonymous> section.

#########################################################################
#                                                                       #
# Uncomment lines with only one # to allow basic anonymous access       #
#                                                                       #
#########################################################################

#<Anonymous ~ftp>
#   User     ftp
#   Group     ftp

### We want clients to be able to login with "anonymous" as well as "ftp"
# UserAlias    anonymous ftp

### Limit the maximum number of anonymous logins
MaxClients    100

### We want 'welcome.msg' displayed at login, and '.message' displayed
### in each newly chdired directory.
#DisplayLogin    welcome.msg
#DisplayFirstChdir   .message

### Limit WRITE everywhere in the anonymous chroot
# <Limit WRITE>
#   DenyAll
# </Limit>
#</Anonymous>
DisplayLogin                   welcome.msg
#DisplayFirstChdir              .message

DisplayConnect /usr/local/proftpd/etc/connect.msg
DisplayGoAway /usr/local/proftpd/etc/goway.msg

DisplayQuit /usr/local/proftpd/etc/quit.msg
MaxHostsPerUser 3
MaxClientsPerUser 5

MaxClientsPerHost 6

RootLogin off
RequireValidShell off
UseReverseDNS     off
IdentLookups      off
TimeoutStalled    600
TimeoutLogin      900
TimeoutIdle       600
TimeoutNoTransfer 600

AllowForeignAddress on

PassivePorts 49152 65534

AllowStoreRestart      on
AllowRetrieveRestart   on

ServerIdent off
DefaultRoot ~ ftpgroup


SQLAuthTypes Backend Plaintext

SQLAuthenticate users* groups*
SQLConnectInfo proftpd 123456

SQLUserInfo ftpuser userid passwd uid gid homedir shell
SQLGroupInfo ftpgroup groupname gid members

SQLNegativeCache   on
SQLDefaultGID      65534
SQLDefaultUID      65534

SQLLogFile /var/log/proftpd.sql.log
SQLNamedQuery getcount SELECT "count from ftpuser where userid='%u'"
SQLNamedQuery getlastlogin SELECT "lastlogin from ftpuser where userid='%u'"
SQLNamedQuery updatelogininfo UPDATE "count=count+1,host='%h',lastlogin=current_timestamp() WHERE userid='%u'" ftpuser
SQLShowInfo PASS "230" "You've logged on %{getcount} times, last login at %{getlastlogin}"
SQLLog PASS updatelogininfo
SyslogLevel emerg
SystemLog /var/log/proftpd.system.log
TransferLog /var/log/proftpd.xferlog

LogFormat default "%h %l %u %t "%r" %s %b"
LogFormat auth "%v [%P] %h %t "%r" %s"
LogFormat write "%h %l %u %t "%r" %s %b"

ExtendedLog /var/log/proftpd.auth_log AUTH auth

ExtendedLog /var/log/proftpd.paranoid_log ALL default
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------

#插入test用户 进行测试
insert into ftpuser (id,userid,passwd,uid,gid,homedir,shell) values ('1', 'test','test','2005','2005','/home/test','/sbin/nologin');

/usr/local/etc/rc.d/proftpd start

+0
发表评论
×您的大名会显示在评论处

评论内容不能少于5个字哦~~~

评论列表
当前暂无评论
发送数据中... 请求错误. 请输入评论内容和验证码后再发布 您已经参与过了,谢谢
返回顶部 ^