vim/etc/postfix/accessphp
172.25.254.10 REJECThtml
查看使用參數mysql
postconf -d |grep clientlinux
加密成db文件
nginx
postmap accesssql
將參數寫入文件數據庫
postconf -e "smtpd_client_restrictions=check_client_access hash:/etc/postfix/access"apache
以後vim/etc/postfix/main.cf會發現最後一行出現了vim
smtpd_client_restrictions =check_client_access hash:/etc/postfix/access瀏覽器
五光十色噠~~美美噠~
systemctl restart postfix.service
在172.25.254.10 執行 telnet 172.25.254.11 25
能夠登錄,但不能使用(發郵件)。
vim/etc/postfix/recip
xixi@lalala.com REJECT
postmap recip加密成db文件
postconf -e"smtpd_sender_restrictions =check_sender_access hash:/etc/postfix/recip"
systemctl restart postfix.service
其餘用戶能夠發郵件,xixi不能。
vim/etc/postfix/recip
xixi@lalala.com REJECT
postmap recip
postconf -e"smtpd_recipient_restrictions = check_recipient_accesshash:/etc/postfix/recip"
systemctl restart postfix.service
其餘用戶能夠收郵件,xixi不能。
常見端口號
pop3 110
pop3S 995
imap 143
imaps 993
cat /etc/services |grep imap 能夠查看imap的端口號
vim/etc/dovecot/dovecot.conf
24 protocols = imap pop3 lmtp dovecot使用的協議
49 disable_plaintext_auth = no 使用明文認證
50 login_trusted_networks = 0.0.0.0/0 使外網也能夠使用dovecot服務
vim/etc/dovecot/conf.d/10-mail.conf
30 mail_location =mbox:~/mail:INBOX=/var/mail/%u
netstat -antlupe |grep dovecot
passwd westos
telnet 172.25.254.11 110
user mooc
pass 1
若是登陸失敗,能夠在服務器查看日誌(cat /var/log/maillog),獲取錯誤信息
根據提示:mkdir –p /home/mooc/mail/.imap
touch /home/mooc/mail/.imap/INBOX
1)本地
yum install mutt -y
mutt -f imap://mooc@172.25.254.11
登陸成功~~~~
小問題
爲何 在配置文件裏,寫了 pop3 ,可是pop能登錄,pop3卻不能夠????
2)雷鳥
使用雷鳥的時候要注意,也要打開postfix對於外網的25端口哦~~
vim /etc/postfix/main.cf
因爲每一個新用戶都要手動建立/home/mooc/mail/.imap/INBOX,太麻煩~
因此直接在/etc/skel中建立mail/.imap/INBOX,這樣系統在建立新用戶時,會自行建立/home/newuser/mail/.imap/INBOX
創建一個虛擬用戶(vmail)來管理郵箱數據庫,不直接用root,由於風險太大!
groupadd -g 666
useradd -g 666 -u 666 -s /sbin/nologinvmail
1)在數據庫中添加信息
給 postfix受權,SELECT
2)檢測數據庫是否讀取成功
vim/etc/postfix/mysql-users.cf
hosts = localhost
user = postfix
password = postfix
dbname = email
table = muser
select_field = username
where_field = username
cp-p mysql-users.cf mysql-domain.cf
hosts = localhost
user = postfix
password = postfix
dbname = email
table = muser
select_field = domain
where_field = domain
cp-p mysql-users.cf mysql-maildir.cf
hosts = localhost
user = postfix
password = postfix
dbname = email
table = muser
select_field = maildir
where_field = username
讓咱們來小小檢測一下~~
postmap -q "admin@westos.org"mysql:/etc/postfix/mysql-users.cf
postmap -q "westos.org"mysql:/etc/postfix/mysql-domain.cf
postmap -q "admin@westos.org"mysql:/etc/postfix/mysql-maildir.cf
3)將數據寫入配置文件
postconf –d | grep map
postconf -e "virtual_uid_maps =static:666"
postconf -e "virtual_gid_maps =static:666"
postconf -e "virtual_mailbox_base=/home/vmail" 指定郵箱位置
postconf -e"virtual_alias_maps=mysql:/etc/postfix/mysql-users.cf" 本地文件鏈接數據庫
postconf -e"virtual_mailbox_domains=mysql:/etc/postfix/mysql-domain.cf"
postconf -e"virtual_mailbox_maps=mysql:/etc/postfix/mysql-maildir.cf"
最後配置文件變成:
mailadmin@westos.org
即本地沒有org這個域名,在org在數據庫中,實現org用戶之間的相互通訊
yum install dovecot-mysql -y
vim/etc/dovecot/conf.d/auth-sql.conf.ext 查看模板位置
cp -p /usr/share/doc/dovecot-2.2.10/example-config/dovecot-sql.conf.ext/etc/dovecot
vim /etc/dovecot/dovecot-sql.conf.ext
32driver = mysql 驅動
70connect = host=localhost dbname=email user=postfix password=postfix
使用本地用戶(postfix)鏈接數據庫email,他一般只擁有select權限(在企業中)
77default_pass_scheme = PLAIN 登錄密碼明文(數據庫)
106 password_query = \
107 SELECT username, domain, password \
108 FROM muser WHERE username = '%u' AND domain = '%d'
%u=entire user@domain
%d=domainpart of user@domian
%n=userpart in user@domian,same as %u if there is no domain
124 user_query = SELECT maildir, 666 AS uid,666 AS gid FROM muser WHERE username = '%u'
vim10-mail.conf
30 mail_location =maildir:/home/vmail/%d/%n 郵箱的位置
168 first_valid_uid = 666 使虛擬用戶和mail有聯繫
175 first_valid_gid = 666
vim10-auth.conf
122 !include auth-system.conf.ext系統用戶
123 !include auth-sql.conf.ext 數據庫用戶
首先檢測admin@westos.org 是否能經過172.25.254.11的110端口登陸,登陸成功才說明配置成功,纔有可能使用雷鳥~
在雷鳥上能夠實現admin@westos.org和zoe@westos.org互發郵件!!!
在本身的服務器能夠使用雷鳥~
在客戶端也能夠使用雷鳥,哦哈哈哈~開森~
1)/run/dovecot 對於mooc沒有w權限
解決方法: chmod o+w /run/dovecot
2)dovecot不能識別mysql
解決方法:yum install dovecot-mysql –y
郵件服務器是mat,一般運行smtp協議(發郵件的時候),比較重要,不能暴露在外面,因此要找個傀儡。
表面上,郵件都發給傀儡,實際上郵件所有發給服務器,傀儡那裏一點數據都沒有~
空殼(傀儡):10
vim/etc/resolv.conf
nameserver 172.25.254.10
vim/etc/named.rfc1912.zones
zone "westos.org" IN {
type master;
file "westos.org.zone";
allow-update { none; };
};
vimwestos.org.zone
dns A 172.25.254.10
westos.org. MX 1 172.25.254.10.
vim/etc/postfix/main.cf
75 myhostname = maillalala.lalala.com 真實主機信息
83 mydomain = lalala.com 真實主機信息
98 myorigin = westos.org 我要接受哪一個域的郵件
113 inet_interfaces = all
140 local_transport = error:local deliverydisabled
提示用戶我是一個空殼,不要給我發郵件了!!!
164 mydestination = 我就不接受郵件,大家傻了吧
313 relayhost = 172.25.254.10 把郵件傳遞給個人真實服務器
別忘了關火牆!
服務器
vim /etc/postfix/main.cf
264 mynetworks = 172.25.254.10 個人傀儡的ip
空殼端:mail admin@westos.org 給本身發郵件,郵件並不在本身的收件箱。
服務器:rm -rf /home/vmail/*
會發如今產生/home/vmail/westos.org/admin 的目錄,而且郵件在new/下
1.httpd
httpd 是有http協議的軟件
2.架構
lamp=linux apache mysql php
lump=linux nginx mysql php
nginx 共享
jsp asp 動態,用tomcat jbosss 翻譯讀不懂的語言
squied 代理軟件
3.server
curl -I www.taobao.com
server 訪問淘寶時訪問的淘寶的哪個服務(軟件)
4.nmap
nmap個人虛擬機,查看哪一個端口開着
nmap 度~娘 (侵刪)
apache默認訪問端口80
tomcat 8080
vim /etc/httpd/conf/httpd.conf
/Listen
42 Listen 8080
apache 默認訪問/var/www/html/index.html
1)更改apache默認發佈主頁
vim /etc/httpd/conf/httpd.conf
/index
170 <IfModule dir_module>
171 DirectoryIndex file index.html
172 </IfModule>
哪一個文件在前面先訪問哪一個,若是爲空,將訪問apache官方主頁
2)訪問apache幫助手冊
yum install http-manual -y
在瀏覽器訪問http://172.25.254.230/manual
3)更改默認訪問目錄
vim /etc/httpd/conf/httpd.conf
/DocumentRoot
120 DocumentRoot "/www/westos"
121
122 <Directory "/www/westos"> 目錄的受權
123 Require all granted
124 </Directory>
在getenforce=Enforcing 時,若是上下文標籤不一致時,將不能經過apache訪問
因此要將新目錄的上下文標籤改爲http_sys_content_t:s0
mkdir /www/westos -p
semanage fcontext -a -t httpd_sys_content_t'/www/westos(/.*)?'
restorecon -RccF /www/
vim index.html
/www/westos
lalallaa
systemctl reload httpd 同 kill 1
結果圖:
4)訪問控制
1)經過ip控制
120 DocumentRoot "/www/westos"
121
122 <Directory "/www/westos">
123 Require all granted
124 Order Allow,Deny
125 Allow from 172.25.254.88
126 Deny from ALL 全部人都不能訪問
127 </Directory>
124 Order Deny,Allow
125 Allow from 172.25.254.88 172.25.254.10 只有88,10能訪問
126 Deny from ALL
124 Order Deny,Allow
125 Allow from 172.25.254.0/24 全部網段都能訪問
126 Deny from ALL
124 Order Deny,Allow
125 Allow from 172.25.254.88 只有88能訪問
126 Deny from ALL
結論:以最後讀取的allow或deny爲準
2)經過密碼控制
cd /etc/httpd/
htpasswd -cm htpasswdfile admin 第一次建立用戶 -c create
htpasswd -m htpasswdfile westos 以後建立用戶
-m Force MD5 encryption of the password (default).
122 <Directory "/www/westos">
123 AllowOverride All
124 Authuserfile/etc/httpd/htpasswdfile
125 Authname "Please inputusername and password"
126 Authtype basic
127 Require valid-user /etc/httpd/htpasswdfile裏的用戶
Requireadmin 只容許admin。
128 </Directory>
admin 正確輸入用戶名和密碼,進去啦~
但在當前配置下,Require admin,zoe不能進去。
配置爲Require valid-user
/etc/httpd/htpasswdfile裏全部的用戶,才能都進入。
清除緩存Ctrl+Shift+Delete
apache 虛擬主機
vim /etc/hosts
172.25.254.230 www.westos.com westos.com news.westos.commusic.westos.com
創建子服務器目錄
mkdir/var/www/virtual/news.westos.com/html -p
mkdir/var/www/virtual/music.westos.com/html -p
寫子服務器主頁
vim var/www/html/index.html
default
vim /var/www/virtual/music.westos.com/html/index.html
music
vim/var/www/virtual/news.westos.com/html/index.html
news
爲何要把news.conf,music.conf,default.conf寫在/etc/httpd/conf.d下?
vim /etc/httpd/conf/httpd.conf
356 IncludeOptional conf.d/*.conf
能夠看到apache默認讀取/etc/httpd/conf.d/下以conf結尾的文件
cd /etc/httpd/conf.d
1.vim news.conf
<Virtualhost *:80>
Servername news.westos.com
Documentroot /var/www/virtual/news.westos.com/html
Customlog "logs/news.log" combined
</Virtualhost>
<Directory"/var/www/virtual/news.westos.com/html">
Require all granted
</Directory>
2.vim music.conf
<Virtualhost *:80>
Servername music.westos.com
Documentroot /var/www/virtual/music.westos.com/html
Customlog "logs/music.log" combined
</Virtualhost>
<Directory"/var/www/virtual/music.westos.com/html">
Require all granted
</Directory>
3.vim default.conf
<Virtualhost _default_:80>
Documentroot /var/www/html
Customlog "logs/default.log" combined
</Virtualhost>
<Directory "/var/www/html">
Require all granted
</Directory
vim /etc/hosts
服務器解密,客戶端加密
yum install mod_ssl -y
會生成這個文件:/etc/httpd/conf.d/ssl.conf
systemctl restart httpd
netstat -antlpe |grep httpd
使用https://www.westos.com 會由於缺乏證書,沒法訪問
安裝生成證書的軟件
yuminstall crypto-utils -y
加密公司網址
genkeywww.westos.com
/etc/pki/tls/certs/www.westos.com.crt
/etc/pki/tls/private/www.westos.com.key
vim/etc/httpd/conf.d/ssl.conf
100 SSLCertificateFile/etc/pki/tls/certs/www.westos.com.crt
107 SSLCertificateKeyFile/etc/pki/tls/private/www.westos.com.key
systemctl restart httpd
個人證書~~~~~