Linux版本为RHEL8
首先为不同端口创建目录并写入首页文件
mkdir -p /var/www/html/8000
mkdir -p /var/www/html/8080
echo "This is 8000">/var/www/html/8000/index.html
echo "This is 8080">/var/www/html/8080/index.html
进行文件配置
vim /etc/httpd/conf.d/myconf.conf
Listen 8000
Listen 8080
<VirtualHost 192.168.85.128:8000>
Servername 192.168.85.128
DocumentRoot "/var/www/html/8000"
DirectoryIndex index.html
</VirtualHost>
<VirtualHost 192.168.85.128:8080>
Servername 192.168.85.128
DocumentRoot "/var/www/html/8080"
DirectoryIndex index.html
</VirtualHost>
关闭selinux,防火墙重启httpd服务
setenforce 0
systemctl stop firewalld
systemctl restart httpd
测试
curl 192.168.85.128:8000
curl 192.168.85.128:8080
![](https://i-blog.csdnimg.cn/blog_migrate/8449dc891fd5dacd72f26f0f52f5c8f4.png)