linux中的Apache服务

******apache
主配置文件/etc/httpd/conf/httpd.conf
子配置文件 /etc/httpd/conf.d/
.conf

安装httpd,关闭火墙

linux中的Apache服务

linux中的Apache服务
在/var/www/html (默认发布目录)中vim /index.html(默认发布文件)
写下qiangsen man
在firefox中172.25.254.114就直接可以看见
linux中的Apache服务

linux中的Apache服务

*****修改默认端口
在配置文件中 vim /etc/http/conf/httpd.conf
43行 listen(默认端口)改为8080

linux中的Apache服务

修改默认发布文件名称

linux中的Apache服务
建立发布文件
****修改默认发布文件
在配置文件中 vim /etc/http/conf/httpd.conf
164行 DirectoryIndex 后面跟的就是默认发布文件的名字 可以改index.html为test.html

修改后systenctl restart httpd
vim /var/www/html/test.html 写入qiangsen namshen
在firefox中搜索可以搜索到
linux中的Apache服务

linux中的Apache服务

firewall-cmd --permanent --add-prot=8080/tcp
firewll-cmd --reload
netstat -antlupe | grep httpd 查看火墙端口信息
semanage port -l | grep http
在firefox中搜索172.25.254.114
linux中的Apache服务

******修改默认发布文件

在主配置文件中vim /etc/http/conf/http.conf
120行 注释掉原来的DocumentRoot /var/www/html
写下新的发布文件
DocumentRoot /westos/html(设置新的发布目录)
<Directory “/westos/html”>
Require all granted(所有人都可以访问)
(给权限)

linux中的Apache服务

linux中的Apache服务

linux中的Apache服务

linux中的Apache服务

重启服务
这时候在浏览器中访问不上
因为你selinux开了,去看看安全上下文
ls -Zd /var/www/html/
ls -Zd /westos/html/
将你新建的文件夹更改上下文
semanage fcontext -a -t httpd_sys_content_t ‘/westos/html(/.*)?’
restorecon -RvvF /westso/html(将westos下的文件同步安全上下文)
重启服务
在文件夹中建立默认发布文件vim /westos/html/index.html
suibian
这时候在浏览器中访问172.25.254.114

linux中的Apache服务

linux中的Apache服务

linux中的Apache服务

********一个apache的ip实现多个站点的的服务
cd /etc/httpd/conf.d

vim /etc/hosts
172.25.254.114 www.westos.com news.westos.com music.westos.com
(本地解析 设置一个ip 对应多个站点)
linux中的Apache服务

访问子配置文件,
设置每个子站的发布文件,给权限
vim vhost.conf(子配置文件) 里面可以设置每个站点的信息,比如站点的发布目录,日志情况

linux中的Apache服务

linux中的Apache服务

linux中的Apache服务

mkdir -p /var/www/haha/news
mkdir -p /var/www/haha/music
vim /var/www/haha/news/index.html

vim /var/www/haha/music/index.html

firefox访问www.westos.com
news.westos.com
music.westos.com
可以看见那些域名有不同的解析
linux中的Apache服务

linux中的Apache服务

linux中的Apache服务

******设置一个域名的黑白名单
在子配置文件的下面想设置那个域的权限
在那个域下写
vim /etc/httpd/conf.d/haha.conf

<Directory “/var/www/html”>
Order Allow,Deny
Allow from all
Deny 172.25.254.100

ip 172.25.254.100进黑名单
linux中的Apache服务

(2)给你一个账号和密码登陆域名

cd /etc/httpd/
htpasswd -cm .apache_auth admin

htpasswd -m .apache_auth lee
创建俩个用户
linux中的Apache服务

在子配置文件中设置这个域名的允许张号登陆
vim /etc/httpd/conf.d/haha.conf
图上只允许lee登陆
linux中的Apache服务

访问会发现要求要认证

linux中的Apache服务

linux中的Apache服务

错误。。。。。
linux中的Apache服务

************apache支持的语言类型
html语言:不在多说,上面都是

php语言
共享目路下的发布文件
linux中的Apache服务

在共享目录中写下php语句
linux中的Apache服务

linux中的Apache服务

修改默认发布文件为php
linux中的Apache服务

在浏览器上访问
linux中的Apache服务

****perl语言
编辑一个.cgi的per语言文件
linux中的Apache服务
chmod +x index.cgi

执行文件,发现可调用执行
linux中的Apache服务

修改文件安全上下文
linux中的Apache服务
修改子配置文件在vhost中写下如图

linux中的Apache服务

在浏览器中搜索可以执行per语句写的文件

linux中的Apache服务

wsgi语言
这个需要python文件,我没拷到文件。。。。。。

linux中的Apache服务

linux中的Apache服务

linux中的Apache服务