实验环境:
centos7,httpd
实验步骤
1.使用yum安装httpd
yum install httpd
2.启动 httpd 服务
# 重启httpd服务
systemctl restart httpd
# 启动httpd服务
systemctl start httpd
# 设置httpd服务为开机自启状态
systemctl enable httpd
# 查询服务是否为开机启动
systemctl is-enabled httpd
3.找到httpd.conf文件,大部分都在/etc/httpd/conf/下面
4.使用打开httpd.conf文
vim httpd.conf
5.查找到 Listen 80 ,再下面添加上 Listen 8080 。意思是让httpd再监听8080 端口
6.在下面添加以下配置
ServerName localhost
<VirtualHost *:80>
ServerName localhost:80
DocumentRoot "/var/www/html"
<Directory "/var/www/html/">
AllowOverride All
Options Indexes FollowSymLinks
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:8080>
ServerName localhost:8080
DocumentRoot "/var/www/html2"
<Directory "/var/www/html2/">
AllowOverride All
Options Indexes FollowSymLinks
Require all granted
</Directory>
</VirtualHost>
7.转移到www目录下创建html2目录
cd /var/www/
mkdir html2
重启一下httpd服务,就可以访问了