liunx http安装配置 + 常用端口名字

常用端口

一个计算机最多有65535个端口,端口不能重复。Linux 只有 root 用户可以使用1024以下的端口

ssh 22

ftp :21连接 20传输

http :80

https:443

tomcat:8080

mysql :3306

nfs:2049

dns:53

1、安装apache

yum -y install httpd

2、访问控制

[root@web-server1 ~]# vim /etc/httpd/conf/httpd.conf 

    # 允许所有端口访问
    Require all granted 
    #拒绝所有ip
    #<RequireAll>
    #Require all denied
    #</RequireALL>
    #拒绝指定iP
    #<RequireAll>
    #Require not ip 192.168.29.129 
    #Require all granted
    #</RequireALL>

3、自定义网站发布目录

配置文件下修改

[root@web-server1 ~]# vim /etc/httpd/conf/httpd.conf 
DocumentRoot "指定目录"      
<Directory "指定目录"> 

4、虚拟主机配置

4.1 基于不同端口的虚拟主机

修改test.conf中80为自定义端口号下文中修改为100  200 
<VirtualHost *:100>
 #指定虚拟主机端口,*代表监听本机所有ip,也可以指定ip
DocumentRoot /webtest1
#指定发布网站目录,自己定义
ServerName www.webtest1.com
 #指定域名,可以自己定义
<Directory "/webtest1/">
  AllowOverride None
 #设置目录的特性,不设置目录的特性
  Require all granted
#允许所有人访问
</Directory>
</VirtualHost>

<VirtualHost *:200>
DocumentRoot /webtest2
ServerName www.webtest2.com
<Directory "/webtest2/">
  AllowOverride None
  Require all granted
</Directory>
</VirtualHost>


并在主配置文件中监听/etc/httpd/conf/httpd.conf 
添加
Listen 100
Listen 200

4.2 基于不同域名的虚拟主机

还需要根据指定的发布目录创建对应的测试目录和测试文件
mkdir /webtest{1,2}
echo "testweb1" > /webtest1/index.html
echo "testweb2" > /wentest2/index.html

<VirtualHost *:80>
 #指定虚拟主机端口,*代表监听本机所有ip,也可以指定ip
DocumentRoot /webtest1
#指定发布网站目录,自己定义
ServerName www.webtest1.com
 #指定域名,可以自己定义
<Directory "/webtest1/">
  AllowOverride None
 #设置目录的特性,不设置目录的特性
  Require all granted
#允许所有人访问
</Directory>
</VirtualHost>

<VirtualHost *:80>
DocumentRoot /webtest2
ServerName www.webtest2.com
<Directory "/webtest2/">
  AllowOverride None
  Require all granted
</Directory>
</VirtualHost>

4.3 基于不同ip的虚拟主机

# 添加一个临时ip
ifconfig ens33:0 192.168.29.130

<VirtualHost 192.168.29.129:80>
 #指定虚拟主机端口,*代表监听本机所有ip,也可以指定ip
DocumentRoot /webtest1     
#指定发布网站目录,自己定义
ServerName www.webtest1.com 
 #指定域名,可以自己定义
<Directory "/webtest1/">
  AllowOverride None   
 #设置目录的特性,不设置目录的特性
  Require all granted   
#允许所有人访问
</Directory>
</VirtualHost>

<VirtualHost 192.168.30.130:80>
DocumentRoot /webtest2
ServerName www.webtest2.com
<Directory "/webtest2/">
  AllowOverride None
  Require all granted
</Directory>
</VirtualHost>


# 取消
ifconfig ens33:0 192.168.29.130 down
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值