【Linux深度学习笔记5.13(Apache)】

Apache :

复制代码
1.安装
        yum -y install hhtpd

2.启动
        hhtpd -k start

3.停止
        httpd -k stop

4.重启
        httpd -k restart

  或者 : 
        systemctl [ start | stop | restart ] httpd

 默认页面 : 
        cd /etc/www/html

        echo "hello 2402" > index.html

验证 : 
        浏览器访问 : http://ip 

访问控制

复制代码
vim /etc/httpd/conf/httpd.conf -------->配置文件

​    denied 拒绝访问

默认 : 允许所有

复制代码
   <Directory "/var/www/htnl">

​            Options Indexes FollowSymLinks

​            Require all granted

​            AllowOverride  None

​   </Directory>

​ 拒绝某些ip访问

复制代码
   <Directory "/var/www/html">

​            Options Indexes FollowSymLinks

​            <RequireAll>

​                Require all granted

​                Require not ip  10.36.178.30    10.36.178.119    

​            </RequireAll>

​            AllowOverride None

​   </Directory>

允许一部分

复制代码
<Directory "/var/www/html">

​            Options Indexes FollowSymLinks

​            <RequireAll>

​                Require ip 被拒绝的ip

​            </RequireAll>

​            AllowOverride None

​ </Directory>

​ 拒绝所有ip访问

复制代码
<Directory "/var/www/html">

​            Oprions Indexes FollowSymLinks

​            Require all denied

​            AllowOverride None

​</Directory>

虚拟主机 :

虚拟主机:将多个网站放在一台服务器上。web服务器都可以实现。

三种:基于域名 基于端口 基于Ip(300M/9w/1y)

基于域名:

1.基于域名

复制代码
[root@qfedu.com ~]# cd /etc/httpd/conf.d/
[root@qfedu.com conf.d]# vim test.conf   #创建配置文件
<VirtualHost *:80>   #指定虚拟主机端口,*代表监听本机所有ip,也可以指定ip
DocumentRoot /soso     #指定发布网站目录,自己定义
ServerName www.soso666.com  #指定域名,可以自己定义
<Directory "/soso/">
  AllowOverride None    #设置目录的特性,不设置目录的特性
  Require all granted   #允许所有人访问
</Directory>
</VirtualHost>
[root@qfedu.com ~]# mkdir /soso #创建发布目录
[root@qfedu.com ~]# mkdir /soho
[root@qfedu.com ~]# echo qianfen > /soso/index.html #创建测试页面
[root@qfedu.com ~]# echo qfedu > /soho/index.html
[root@qfedu.com ~]# systemctl restart httpd

配置域名解析:
    在wind电脑上面打开C:\Windows\System32\drivers\etc\hosts文件。可以用管理员身份打开

2.基于端口:

复制代码
 [root@qfedu.com ~]# vim /etc/httpd/conf/httpd.conf  ---添加
    [root@qfedu.com ~]# vim /etc/httpd/conf.d/test.conf
    <VirtualHost *:81>   #修改端口
     DocumentRoot /soho
      ServerName test.soso666.com
    <Directory "/soho/">
      AllowOverride None
      Require all granted
    </Directory>
    </VirtualHost>
    [root@qfedu.com ~]# systemctl restart httpd
    注意:域名解析并没有变

3.基于IP

复制代码
 [root@qfedu.com ~]# ifconfig ens33:0 192.168.153.123  #添加一个临时ip
    [root@qfedu.com ~]# vim /etc/httpd/conf.d/test.conf
    <VirtualHost 192.168.153.144:80>   #指定ip
      DocumentRoot /soso
      #ServerName www.soso666.com
    <Directory "/soso/">
      AllowOverride None
      Require all granted
    </Directory>
    </VirtualHost>
相关推荐
zmsup26 分钟前
Agent 上下文调优:结合 OpsArk 运维智能体,设计模型每一步真正需要的信息
运维·agent·上下文压缩·运维智能体·上下文调优
吴声子夜歌3 小时前
Nginx应用与运维——Nginx负载均衡应用实战(二)
运维·nginx·负载均衡
lisanmengmeng3 小时前
NRPE 添加命令(一)
linux·运维·服务器
pt10433 小时前
CML网络仿真入门-2:使用CML模拟网络实验环境
运维·网络协议
树下水月4 小时前
Typora破解
linux·服务器·前端
沫璃染墨4 小时前
《从零入门Linux系统篇(五十七):线程篇·十——生产者消费者模型进阶:从环形缓冲区到POSIX信号量》
linux·运维·服务器·开发语言·c++·系统架构·信号处理
HAHAXX85 小时前
电商RPA批量上架通用方案:一套流程如何同时跑通拼多多、抖店、淘宝和跨境平台
java·运维·rpa
零基础1235 小时前
LLM Agent 驱动的物模型构建:从设备手册到边缘接入的自动化实践
运维·人工智能·经验分享·python·自动化
星夜夏空995 小时前
网络编程(5)—— Reactor实现(v3)
服务器·网络·php
程序猿老A6 小时前
从入门型到企业型:云服务器开放共享型到独享型规格升级
运维·服务器