标签:http linux
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
测试:
标签:http linux
原文地址:http://12117148.blog.51cto.com/12107148/1879516