ISO:CentOS-7-x86_64-DVD-1708
VMwareWorkstation12 Player:
Memory:2GB
Processors:2
Hard Disk:20GB
Network Adapter:Bridged(Automatic)
安裝
手動處理分割
/boot 500M
swap 2048M
/var/log 3000
/ 8000M 或不寫自動補上所有可用空間
線上更新
# yum install wget
# wget ftp://ftp.kh.edu.tw/pub/APPL/yum/CentOS7/fix-yum-CentOS7.sh
# ls
fix-yum-CentOS7.sh
# chmod 755 fix-yum-CentOS7.sh
# ./fix-yum-CentOS7.sh
# vi /etc/yum.repos.d/rpmforge.repo
### Name: RPMforge RPM Repository for RHEL 7 - dag
### URL: http://rpmforge.net/
[rpmforge]
name = RHEL $releasever - RPMforge.net - dag
baseurl = http://apt.sw.be/redhat/el7/en/$basearch/rpmforge
mirrorlist = http://mirrorlist.repoforge.org/el7/mirrors-rpmforge
#mirrorlist = file:///etc/yum.repos.d/mirrors-rpmforge
enabled = 1
protect = 0
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-dag
gpgcheck = 1
proxy=http://open.kh.edu.tw:3128/
timeout=300
# yum -y update
# yum clean packages
自動化排程,讓作業系統每天自動去檢查是否要更新套件
😍方法1:
# yum install yum-cron
# vi /etc/yum/yum-cron.conf
download_updates = yes
...
apply_updates = yes
...
# systemctl enable yum-cron //設定成開機啟動
# systemctl start yum-cron
# systemctl -l status yum-cron //檢查目前狀態,確認是否開機啟動,且執行中
😛方法2:系統的設定檔
# vi /etc/crontab
....
30 07 * * * root yum update -y ; yum clean packages
//分 時 日 月 星期(0:週日 ~ 6:週六) 身分 指令
# systemctl restart crond
# tail /var/log/cron
安裝Samba Server
# yum -y install samba
# rpm -qa | grep samba
samba-common-4.6.2-12.el7_4.noarch
samba-libs-4.6.2-12.el7_4.x86_64
samba-common-libs-4.6.2-12.el7_4.x86_64
samba-common-tools-4.6.2-12.el7_4.x86_64
samba-client-libs-4.6.2-12.el7_4.x86_64
samba-4.6.2-12.el7_4.x86_64
# systemctl enable smb.service
# systemctl start smb.service
# systemctl -l status smb.service
# systemctl -l status smb.service
關閉SELINUX,後重開
# vi /etc/sysconfig/selinux
...
SELINUX=disabled
...
SELinux status: disabled
新增使用者
# adduser kk3
# passwd kk3
更改使用者 kk3的密碼。
新 密碼:123456
# ls /home
複製檔案
# cp /etc/samba/smb.conf /etc/samba/smb.conf.bk
# ls /etc/samba/
# vi /etc/samba/smb.conf
# See smb.conf.example for a more detailed config file or
# read the smb.conf manpage.
# Run 'testparm' to verify the config is correct after
# you modified it.
[global]
workgroup = WORKGROUP
security = user
passdb backend = tdbsam
max log size = 50
comment = Home Directories
browseable = No
writable = YES
//**
workgroup = 工作群組名稱
security = user 透過 samba 伺服器本身的帳號密碼資料庫
netbios name = 現在預設為主機名稱喔! (可不設定,預設使用 hostname 的輸出)
server string = 主機的簡易說明 (可不設定)
display charset = 自己伺服器上面的顯示編碼
unix charset = 在 Linux 伺服器上面所使用的編碼
dos charset = 就是 Windows 用戶端的編碼
雖然說 display charset, dos charset, unix charset 可以指定中文編碼的格式,不過由於目前新版的 Samba 對於編碼的解析已經大有進步, 同時,目前我們的 server/client 大多同時使用 utf8 了,因此上述關於語系的設定可以忽略不理,或者是全部通通設定為 utf8 即可。
[homes]
comment = Home Directories
valid users = %S, %D%w%S
browseable = No
read only = No
inherit acls = Yes
comment :該目錄用途的簡易說明
valid users :能使用此項目的用戶。
browseable :是否允許被瀏覽查詢到該目錄的存在 (只能看到目錄,不是允許登入的意思)
read only :是否為唯讀
inherit acls :是否放行已經設定權限的 ACL 資訊
那個 valid users 比較特別~怎麼會是 %S 呢?如果你使用 man smb.conf 去查詢就知道!那就代表 [這裡的名字] 的意思~如前所述, [homes] 是特別的名稱,他可以被登入者的帳號所取代,而 %S 則是代表 [] 裡面的名稱之意!所以,當有 dmtsai 這個家目錄存在, 就代表 dmtsai 是允許登入的用戶之意!更多的 %XXX 請參考 man smb.conf 的內容!
**//
# systemctl restart smb.service
# testparm
Load smb config files from /etc/samba/smb.conf
rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)
Processing section "[homes]"
Loaded services file OK.
Server role: ROLE_STANDALONE
Press enter to see a dump of your service definitions
開放防火牆
# firewall-cmd --permanent --zone=public --add-service=samba
# firewall-cmd --reload
# firewall-cmd --zone=public --list-all
將系統使用者加入 samba 使用者
# smbpasswd -a kk3
New SMB password:123456
Client端連線
只有第1次需登入帳號密碼
登入後建立網路磁碟機
後即不需登入帳號密碼
\\163.16.63.191
安裝Apache
# yum -y install httpd
# rpm -qa | grep httpd
httpd-2.4.6-67.el7.centos.6.x86_64
httpd-tools-2.4.6-67.el7.centos.6.x86_64
# systemctl start httpd.service
# systemctl enable httpd.service
# systemctl status httpd.service
# firewall-cmd --permanent --zone=public --add-service=http
# firewall-cmd --reload
# firewall-cmd --list-all
public (active)
target: default
icmp-block-inversion: no
interfaces: ens33
sources:
services: ssh dhcpv6-client http
ports:
protocols:
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules:
http://163.16.63.191/
設定虛擬目錄
# mkdir /home/myweb設定虛擬目錄
# cd /home/myweb
# vi /home/myweb/index.html
this is My Visual Dir...
# vi /etc/httpd/conf/httpd.conf
...
Alias /myweb "/home/myweb"
<Directory "/home/myweb">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
關閉SELINUX,後重開
# vi /etc/sysconfig/selinux
...
SELINUX=disabled
...
# sestatus
SELinux status: disabled
由Client端瀏覽器測試
http://163.16.63.191/myweb