系统管理及网络服务
实验环境的配置:
配置网卡文件
搭建软件仓库
具体的配置过程查看(软件仓库的配置)
http:超文本传输协议(查资料)
curl -I www.taobao.com
注:查看服务软件
Apache
nginx
stgw
jfe
如何安装Apache
安装Apache服务
开启Apache
设定火墙(火墙开启时设定)
firewall-cmd --permanent --add–service=http
fire-cmd --reload
fire-cmd --list-all
操作流程:
Apache的基本配置
服务名称:httpd
查看配置文件
netstat -antlupe | grep httpd
端口的更改
netstat -antlupe | grep httpd 查看端口
编辑主配置文件Listen
45行
火墙要设定端口的开启
重启httpd服务,并查看更改结果
/var/www/html (默认发布文件)
要求:文件名称:index.html
如何更改默认发布文件
主配置文件中 设定
/etc/httpd/conf/httpd.conf
默认文件有两个时,访问文件westos,当文件westos不存在的时候,访问index.html
注:在修改完成之后要重新启动htppd服务,并在网页中进行验证
默认发布目录的更改
原目录 /var/www/html
主配置文件中的122行
<Directory “/var/www/westos”>
Require all granted
并对目录进行访问授权
重启httpd服务,在网页中进行验证
Apache的访问控制
基于ip
禁止所有用户的访问,只允许172.25.254.40用户进行访问
基于用户的访问设定
htpasswd -cm /etc/httpd/.htpasswd lee
htpasswd -m /etc/httpd/.htpasswd lee
在主配置文件中编写 (130行左右)
然后重启服务
再次访问时就不需要输入用户还有密码
浏览器信息清空 ctrl +shift+del
Apache的虚拟主机
解决多个页面的发布
假设网站为westos.org
linux shell python 为westos.org中的三个子网页
注:本地地址解析(浏览器所在的主机)
此时访问四个网页,都会访问默认测试页
Apache的子配置目录:/etc/httpd/conf.d
配置的根目录 /etc/httpd
注:上图中的~为错误输入,完成上述的配置之后重新启动htppd服务
就可以通过域名进行访问三个子网页
Apache对(php perl python)访问
https:加密传输
明文的安全性太差
php的发布
注:访问php成功
perl的访问
cgi对脚本进行执行
条件:安装httpd-manual Apache的帮助文档
通过网络查找cgi的程序
创建/var/www/html/cgi
编写文件 index.cgi
chmod +x index.cgi
修改文件权限
修改主文件/etc/httpd/conf.d/vhost.conf
重启httpd服务,apache访问显示结果
python的访问
实验环境的配置:
dnf install mod_ssl
dnf install mod_ssl
完成之后/etc/httpd/conf.d 中会存在加密配置文件
重启httpd
firewall-cmd --permanent --add-service=https ##火墙支持支持
firewall-cmd --reload
firewall-cmd --list-all
openssl genrsa -out /etc/httpd/webkey/www.westos.org.key 2048
openssl genrsa -out /etc/httpd/webkey/www.westos.org.csr 2048 ##签证
创建目录后
openssl genrsa -out /etc/httpd/webkey/www.westos.org.key 2048 #生成钥匙
openssl req -new -key /etc/httpd/webkey/www.westos.org.key -out /etc/httpd/webkey/www.westos.org.csr ##签证请求书写
##填写公司资料
国家 省 城市 公司 部门 域名 邮箱
openssl x509 -req -days 365 -in /etc/httpd/webkey/www.westos.org.csr -signkey /etc/httpd/wenkey/www.westos.org.key -out /etc/httpd/webkey/www.westos.org.crt
##证书的颁布
#x509 证书格式
#-rep 请求
#-in 加载签证名称
建立加密网站
/var/www/westos.org/lodin -p
echo login.westos.org > /var/www/westos.org/login/index.html
vim /etc/httpd/conf.d/vhost.conf
<VirtualHost *:443>
ServerName=login.westos.org
DocumentRoot /var/www/westos.org/login
Customlog logs/login.log combined
SSLENGINE ON
SSLCertificateFile /etc/httpd/webkey/www.westos.org.crt
SSLCertificateKeyFile /etc/httpd/webkey/www.westos.org.key
利用sp /etc/httpd/conf.d/ssl.conf ##参数参考文件
systemctl restart httpd ##重启系统
vim /etc/hosts ##编辑本地解析
不用http访问,端口的转化80转443
vim /etc/httpd/conf.d/vhost.conf
<VirtualHost :80>
ServerName=login.westos.org
RewriteEngine On
RewriteRule ^(/.)$ https://%{HTTP_HOST}$1 ##自动加密
重启服务