httpd常用配置和配置https步骤

httpd常用配置


apache源码安装
切换使用MPM(编辑/etc/httpd24/extra/httpd-mpm.conf文件):

//IfModule mpm_name_module
//NAME有三种,分别是:
    prefork
    event
    worker
[root@localhost ~]# vim /etc/httpd24/extra/httpd-mpm.conf
<IfModule mpm_prefork_module>
    StartServers             5		
    MinSpareServers          5
    MaxSpareServers         10
    MaxRequestWorkers      250
    MaxConnectionsPerChild   0
</IfModule> 

StartServers:  数量的服务器进程开始
MinSpareServers:  最小数量的服务器进程
MaxSpareServers:  最大数量的服务器进程
MaxRequestWorkers:  最大数量的服务器进程允许开始
MaxConnectionsPerChild:  最大连接数的一个服务器进程服务

设置环境变量

[root@localhost ~]# vim /etc/prelink.conf.d/httpd.sh
[root@localhost ~]# cat /etc/prelink.conf.d/httpd.sh 
 export PATH=/usr/local/apache/bin/:$PATH
[root@localhost ~]# source /etc/prelink.conf.d/httpd.sh

开启apache

[root@localhost ~]# apachectl start		//启动apache服务
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message 		//不想出现这个这个警告就修改主配置文件vim 											/etc/httpd24/httpd.conf把ServerName www.example.com:80							这一行的注释取消就好了
httpd (pid 1567) already running
[root@localhost ~]# ss -antl		//查看80端口是否开启
State  Recv-Q Send-Q  Local Address:Port   Peer Address:Port Process                                                      
LISTEN 0      128           0.0.0.0:22          0.0.0.0:*                                                                 
LISTEN 0      128              [::]:22             [::]:*                                                                 
LISTEN 0      128                 *:80                *:*                                                             

访问控制法则:

法则 功能
Require all granted 允许所有主机访问
Require all deny 拒绝所有主机访问
Require ip IPADDR 授权指定来源地址的主机访问
Require not ip IPADDR 拒绝指定来源地址的主机访问
Require host HOSTNAME 授权指定来源主机名的主机访问
Require not host HOSTNAME 拒绝指定来源主机名的主机访问
IPADDR的类型 HOSTNAME的类型
IP:192.168.1.1 Network/mask:192.168.1.0/255.255.255.0 Network/Length:192.168.1.0/24 Net:192.168 FQDN:特定主机的全名 DOMAIN:指定域内的所有主机

注意:httpd-2.4版本默认是拒绝所有主机访问的,所以安装以后必须做显示授权访问

示例:

[root@localhost ~]# vim /etc/httpd24/httpd.conf
<Directory "/usr/local/apache/htdocs">
    Require all granted		//把这一行删除或注释
</Directory>
[root@localhost ~]# apachectl restart	//重启服务打开浏览器就看不到页面了

[root@localhost ~]# vim /etc/httpd24/httpd.conf 
<Directory "/usr/local/apache/htdocs">
    Require all granted		//取消注释或者添加此行就可以看到初始页面了
</Directory>
[root@localhost ~]# apachectl restart

虚拟主机:

虚拟主机有三类:

  • 相同IP不同端口
  • 不同IP相同端口
  • 相同IP相同端口不同域名

进入存放网页的路径把网页加入进去

[root@localhost ~]# cd /usr/local/apache/htdocs/
[root@localhost htdocs]# ls
index.html  jp  year	//这里的jp和year是目录里面是我弄得网页内容
[root@localhost htdocs]# tree
.
├── index.html
├── jp
│   └── index.html
└── year
    ├── css
    │   ├── bootstrap.css
    │   ├── font_1191451_h720mljzrsc.css
    │   └── style.css
    ├── fonts
    │   ├── DIN-Black_0.otf
    │   ├── DIN-Bold_0.otf
    │   ├── dinbold-webfont.bc8aa63.woff
    │   ├
  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值