Linux系统提供的TFTP服务器及apache网页服务器结合规划配置了方便的路由资料备份系统解决以上问题。因为目前主流的Linux系统基本是由RedHat及Debian衍生出来的发行版。所以笔者分别就以上两个操作系统的配置进行叙述,希望能给其他用户以帮助。
一、Debian下配置TFTP及apache服务器
(一)TFTP服务器配置
1、TFTP服务器组件安装
在Debian中可以使用新立得软件包管理器搜索tftpd-hpa软件包,并勾选“标记以便安装”选项,然后点击应用按扭,系统将自动进行该组件包的安装。用户也可是直接再命令行下执行apt-get install tftpd-hpa来进行安装命令模式如下:
root@AkBirdofpreyWorkStation:~# apt-get install tftpd-hpa
之后系统将创建相关的应用启动脚本及配置文件,并会在跟目录下创建/srv/tftp目录。
2、TFTP配置文件及相关目录权限修改
系统安装完TFTP服务组件后,会自动创建TFTP服务需要的用户组及配置文件,该文件为/etc/default/tftpd-hpa,初始配置内容如下:
# /etc/default/tftpd-hpa
TFTP_USERNAME="tftp"
TFTP_DIRECTORY="/srv/tftp"
TFTP_ADDRESS="0.0.0.0:69"
TFTP_OPTIONS="-secure"
我们需要将该文件修改为如下内容:
# /etc/default/tftpd-hpa
TFTP_USERNAME="tftp"
TFTP_DIRECTORY="/srv/tftp"
TFTP_ADDRESS="0.0.0.0:69"
TFTP_OPTIONS="-l -c -secure"
其中在TFTP_OPTIONS选项中加入了-l -c参数,这样当我们使用路由器参数备份命令时,可以将文件顺利的上传之TFTP服务器目录。
于此同时我们需要修改TFTP服务器指定目录的用户及属组,命令模式如下:
root@AkBirdofpreyWorkStation:/etc/default# chown tftp:tftp /srv/tftp
这样/srv/tftp目录的属组就修改为了tftp用户,修改用户属组必须要进行,笔者测试中发现,TFTP服务组件安装后/srv/tftp目录的属组为root,如果不进行用户属组修改时,当使用路由器参数备份命令时,服务器将会出现transfer time out错误。
此时只要使用/etc/init.d/tftpd-hpa restart重启TFTP服务,TFTP服务器应该就可以正常使用了,命令模式如下:
root@AkBirdofpreyWorkStation:/etc/default# /etc/init.d/tftpd-hpa restart
[ ok ] Restarting HPA's tftpd: in.tftpd.我们需要将它修改为如下内容:
ServerAdmin webmaster@localhost
#DocumentRoot /var/www
DocumentRoot /srv/tftp
Options FollowSymLinks Indexes
AllowOverride All
Order allow,deny
Allow from all
#
#
#Options Indexes FollowSymLinks MultiViews
#AllowOverride None
#Order allow,deny
#allow from all
#
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
使用vi命令编辑/srv/tftp/.htaccess文件,命令模式如下:
root@AkBirdofpreyWorkStation:/# vi /srv/tftp/.htaccess
文件内容如下:
AuthUserFile /etc/secure.user ##用户帐号密码文件名
AuthName akcwdCA 用户登录认证信息提示
AuthType Basic
require valid-user
使用htpasswd -c /etc/secure.user建立用户密码文件,命令模式如下:
root@AkBirdofpreyWorkStation:/# htpasswd -c /etc/secure.user user1
程序会提示你输入两次用户的口令,然后用户密码文件就已经创建,user1这个用户也同时创建完成了。
使用命令/etc/init.d/apache2 restart重启apache服务器,命令模式如下:
root@AkBirdofpreyWorkStation:/# /etc/init.d/apache2 restart
[....] Restarting web server: apache2apache2: Could not reliably determine the server's fully qualified domain name, using 192.168.1.253 for ServerName
... waiting .apache2: Could not reliably determine the server's fully qualified domain name, using 192.168.1.253 for ServerName
. ok
(二)apache服务器服务器配置
1、apache服务器服务器组件安装
该组件安装和TFTP服务组件安装差别不大,用户可以选择图形界面或者命令行界面进行安装即可
2、apache服务器服务器配置
因为之前笔者一直较多的使用RedHat及其衍生Linux版本。使用Debian/Linux系统后发现apache服务器配置文件与RedHat及其衍生Linux版本apache服务器配置文件差别很大,Debian/Linux系统的apache服务器配置文件没有被集中在像httpd.conf文件中,而是被分别放置在了不同的配置文件里。因为路由器资料涉及到安全性问题,因此我们配置的apache服务器访问时需要进行用户安全审核,下面我们来做具体配置。
Debian/Linux系统的apache服务器配置文件保存在/etc/apache2中,使用vi /etc/apache2/apache2.conf查看帮助中的对该目录结构对应配置文件的说明,我们需要修改的配置文件为 /etc/apache2/sites-enabled/000-default,该文件实际才是apache用户定义的配置文件,其中包括服务器目录以及访问权限等内容,初始配置文件为如下内容:
ServerAdmin webmaster@localhost
DocumentRoot /var/www
Options FollowSymLinks Indexes
AllowOverride None
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
我们需要将它修改为如下内容:
ServerAdmin webmaster@localhost
#DocumentRoot /var/www
DocumentRoot /srv/tftp
Options FollowSymLinks Indexes
AllowOverride All
Order allow,deny
Allow from all
#
#
#Options Indexes FollowSymLinks MultiViews
#AllowOverride None
#Order allow,deny
#allow from all
#
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
使用vi命令编辑/srv/tftp/.htaccess文件,命令模式如下:
root@AkBirdofpreyWorkStation:/# vi /srv/tftp/.htaccess
文件内容如下:
AuthUserFile /etc/secure.user ##用户帐号密码文件名
AuthName akcwdCA 用户登录认证信息提示
AuthType Basic
require valid-user
使用htpasswd -c /etc/secure.user建立用户密码文件,命令模式如下:
root@AkBirdofpreyWorkStation:/# htpasswd -c /etc/secure.user user1
程序会提示你输入两次用户的口令,然后用户密码文件就已经创建,user1这个用户也同时创建完成了。
使用命令/etc/init.d/apache2 restart重启apache服务器,命令模式如下:
root@AkBirdofpreyWorkStation:/# /etc/init.d/apache2 restart
[....] Restarting web server: apache2apache2: Could not reliably determine the server's fully qualified domain name, using 192.168.1.253 for ServerName
... waiting .apache2: Could not reliably determine the server's fully qualified domain name, using 192.168.1.253 for ServerName
. ok
posted on 2013-06-08 12:23 顺其自然EVO 阅读(186) 评论(0) 编辑 收藏