http:(httpd 是有http協議的軟件)
lamp=linux apache mysql php
lnmp=linux nginx(共享) mysql php
(curn -I baidu.com server:訪問淘寶時訪問的淘寶的哪一個服務(軟件))
squid(做代理軟件:類似於海淘代購)
vim index.html(apache默認訪問文件)
修改默認訪問文件
<IfModule dir_module>
DirectoryIndex file index.html(誰在前就優先訪問誰,如果沒有file就訪問index.html)
</IfModule>
修改默認訪問目錄
標籤修改:(selinux) 如果標籤不一樣,無法通過apache訪問
DocumentRoot "/www/westos"
(認證)
<Directory "/www/westos">
Require allgranted
</Directory>
修改默認訪問端口:
Listen 8080
測試:172.25.254.231:8080(默認爲80)
允許誰訪問我的目錄:(apache本身不會拒絕你,只是這個目錄拒絕你的訪問)
所有人都能訪問,31不能
<Directory "/www/westos">
Require allgranted
OrderAllow,Deny
Allow fromALL
Deny from172.25.254.31
</Directory>
<Directory "/www/westos">
Require allgranted
OrderDeny,Allow
Allow from172.25.254.31 (只有31能訪問)
Deny fromALL
</Directory>
<Directory "/www/westos">
Require allgranted
OrderAllow,Deny
Allow from172.25.254.0/24 (所有人都不能訪問)
Deny fromALL
</Directory>
<Directory "/www/westos">
Require allgranted
OrderDeny,Allow
Allow from172.25.254.0 (只有254網段能訪問)
Deny fromALL
</Directory>
用戶登陸認證:
cd /etc/httpd
htpasswd -cm htpasswdfile admin
New password:
Re-type new password:
Adding password for user admin
htpasswd -m htpasswdfile westos(注意:第二個用戶不加c,加c會覆蓋前一個用戶)
New password:
Re-type new password:
Adding password for user westos
編輯主配置文件:vim/etc/httpd/conf/httpd.conf
<Directory "/www/westos">
AllowOverrideALL
Authuserfile/etc/httpd/htpasswdfile (生成認證用戶的目錄)
Authname"Please input username and password"
Authtypebasic
Requirevalid-user (所設定用戶都可以通過密碼認證訪問)
</Directory>
<Directory "/www/westos">
AllowOverrideALL
Authuserfile/etc/httpd/htpasswdfile
Authname"Please input username and password"
Authtypebasic (用戶基礎認證)
Require useradmin (只有admin用戶可以通過認證)
</Directory>
(注意:測試時先清空瀏覽器緩存哦~ ^_^)
apache虛擬主機:
mkdir
/var/www/virtual/news.westos.com/html -p (建立共享目錄)
mkdir /var/www/virtual/music.westos.com/html -p
cd /var/www/virtual/news.westos.com/html
vim index.html(默認訪問文件)
cd /var/www/virtual/music.westos.com/html
vim index.html
cd /etc/httpd/conf.d(主配置文件(vim/etc/httpd/conf/httpd.conf)默認會讀取此目錄裏面的文件)
vim default.conf
vim music.conf
vim news.conf
用另一臺主機去測試:
vim /etc/hosts
https:
客戶有證書和鎖,服務器有鑰匙
證書的生成(生成自己的證書)
yum install mod_ssl -y
systemctl restart httpd(打開443端口)
生成證書:
yum install crypto-utils -y
genkey www.westos.com
cd /etc/httpd/conf.d
vim ssl.conf
SSLCertificateFile/etc/pki/tls/certs/www.westos.com.crt
SSLCertificateKeyFile/etc/pki/tls/private/www.westos.com.key
測試: