2010年10月21日 星期四

Linux Quota,Apache,FTP基礎練習

Linux情境練習:
1.安裝一台CentOS
磁碟分割:
/boot200M
/10G
/var6G
/home1G
swap2G

2.新增三個使用者,tom,jack,amy,預設群組mis。每位使用者的家目錄最多只能放到20MB資料,超過18MB則警告。
Quota啟用: #vim /etc/fstab
LABEL=/ / ext3 defaults,grpquota 1 1
LABEL=/home /home ext3 defaults,usrquota 1 2
#mount -o remount /
#mount -o remount /home
#cat /etc/mtab
/dev/sda2 / ext3 rw,grpquota 0 0
/dev/sda5 /home ext3 rw,usrquota 0 0
#quotacheck -uvagmc
#quotaon
新增帳號: #useradd -g mis tom
#useradd -g mis jack
#useradd -g mis amy

Quota設定: 1.USER
#setquota tom 18000 20000 0 0 /home
#setquota jack 18000 20000 0 0 /home
#setquota amy 18000 20000 0 0 /home
or
#edquota -p tom -u jack
#edquota -p tom -u amy
2.GROUP
#setquota -g mis 80000 100000 0 0 /

Quota測試: [root@localhost ~]# su - tom
[tom@localhost ~]$ pwd
/home/tom
[tom@localhost ~]$ dd if=/dev/zero of=testfile bs=1M count=19
sda5: warning, user block quota exceeded.
19+0 records in
19+0 records out
19922944 bytes (20 MB) copied,0.495339 秒,40.2 MB/s
[tom@localhost ~]$ dd if=/dev/zero of=testfile bs=1M count=21
sda5: warning, user block quota exceeded.
sda5: write failed, user block limit reached.
dd: 寫入 ‘testfile’: 硬碟 quota 滿了
20+0 records in
19+0 records out
20385792 bytes (20 MB) copied,0.017867 秒,1.1 GB/s

3.建立一個目錄:/opt/mis,這個目錄為三個使用者的共享目錄。最大100MB,超過80MB警告, 並建立家目錄到此目錄的連結。
目錄建置: [root@localhost ~]#mkdir /opt/mis
[root@localhost ~]#chown root:mis /opt/mis
[root@localhost ~]#chmod 775 /opt/mis

group quota測試如上,但最好使用兩個帳號,分別建立75M與30M大小的檔案測試
連結建置: [root@localhost ~]#ln -s /opt/mis /home/tom/mis
[root@localhost ~]#ln -s /opt/mis /home/jack/mis
[root@localhost ~]#ln -s /opt/mis /home/amy/mis

4./opt/mis設定為可用網址方式存取:http://主機ip/mis/。並設定為須輸入帳密才可讀取檔案目錄
httpd設定: [root@localhost ~]#vim /etc/httpd/conf/httpd.conf
修改:

Options FollowSymLinks
AllowOverride All

加入:
Alias /mis/ "/opt/mis/"

AllowOverride all

[root@localhost ~]#vim /opt/mis/.htacess
Options Indexes
AuthUserFile /opt/mis/.htpasswd
AuthName "mis"
AuthType Basic
require valid-user
[root@localhost ~]#htpasswd -c /opt/mis/.htpasswd tom
[root@localhost ~]#htpasswd -c /opt/mis/.htpasswd jack
[root@localhost ~]#htpasswd -c /opt/mis/.htpasswd amy
[root@localhost ~]#service httpd restart

5.主機首頁由tom與amy維護,請設定一個ftp上傳方案。
ftp設定: [root@localhost ~]#vim /etc/vsftp/vsftpd.conf
修改或加入:
anonymous_enable=NO
chroot_local_user=YES
chroot_list_enable=YES
[root@localhost ~]#vim /etc/vsftp/chroot_list
加入:
tom
amy
[root@localhost ~]#service vsftpd restart
Apache首頁目錄設定: [root@localhost ~]#chown root:apache /var/www/html
[root@localhost ~]#chmod 2775 /var/www/html
[root@localhost ~]#usermod -G apache tom
[root@localhost ~]#usermod -G apache amy
[root@localhost ~]#ln -s /var/www/html /home/tom/html
[root@localhost ~]#ln -s /var/www/html /home/amy/html

沒有留言:

張貼留言