yum install -y httpd
systemctl start httpd

显示如图:证明 Apache已正常启动

ServerRoot "/etc/httpd" //服务器安装的路径
Listen 80 //监听端口
Include conf.modules.d/*.conf //引用 conf.modules.d下的.conf模块配置文件
User apache //运行用户apache
Group apache //运行用户组
ServerAdmin root@localhost //如果Apache运行出错发送的邮箱地址
<Directory /> //项目根目录,访问根目录拒绝
AllowOverride none
Require all denied
</Directory>
DocumentRoot "/var/www/html" //网站主目录
<Directory "/var/www"> // /var/www 允许访问
AllowOverride None
# Allow open access:
Require all granted
</Directory>
<Directory "/var/www/html">
Options Indexes FollowSymLinks //运行使用连接等方式
AllowOverride None
Require all granted
</Directory>
<IfModule dir_module>
DirectoryIndex index.html //默认访问页面index.html
</IfModule>
<Files ".ht*">
Require all denied //禁用
</Files>
ErrorLog "logs/error_log" //错误日志
LogLevel warn //警告等级
<IfModule log_config_module> //日志格式
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
<IfModule logio_module>
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
</IfModule>
CustomLog "logs/access_log" combined
</IfModule>
<IfModule alias_module>
ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
</IfModule>
<Directory "/var/www/cgi-bin">
AllowOverride None
Options None
Require all granted
</Directory>
<IfModule mime_module> //运行文件类型
TypesConfig /etc/mime.type
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
</IfModule>
AddDefaultCharset UTF-8 //默认编码
<IfModule mime_magic_module>
MIMEMagicFile conf/magic
</IfModule>
EnableSendfile on
IncludeOptional conf.d/*.conf //引入conf.d/的所有.conf文件
<VirtualHost *:自定义端口>
ServerName www.circle.com #在ServerName后加上你的网站名称
ServerAdmin admin@circle.com #在ServerAdmin后加上网站管理员的电子邮件地址,方便别人有问题是可以联络网站管理员
DocumentRoot /var/www/html #在DocumentRoot后加上存放网站内容的目录路径(用户的个人目录)
</VirtualHost>
[root@server1 conf.d]# mkdir /var/www/html/web{1,2}
[root@server1 conf.d]# cd /var/www/html/
[root@server1 html]# ls -l
总用量 0
drwxr-xr-x 2 root root 101 8月 2 14:12 exam
drwxr-xr-x 2 root root 6 11月 14 06:34 web1
drwxr-xr-x 2 root root 6 11月 14 06:34 web2
[root@server1 html]# vi web1/index.html
[root@server1 html]# vi web2/index.html
[root@server1 html]# ls web1
index.html
[root@server1 html]# ls web2
index.html
[root@server1 html]# cd /etc/httpd/conf.d/
[root@server1 conf.d]# vi web1.conf
[root@server1 conf.d]# vi web2.conf
[root@server1 conf.d]# cat web1.conf
<VirtualHost 192.168.122.1:80>
ServerName www.circle.com
ServerAdmin admin@circle.com
DocumentRoot /var/www/html/web1
</VirtualHost>
[root@server1 conf.d]# cat web2.conf
<VirtualHost 192.168.122.1:80>
ServerName admin.circle.com
ServerAdmin admin@circle.com
DocumentRoot /var/www/html/web2
</VirtualHost>
systemctl restart httpd
vi /etc/named.conf
修改后的文件内容如下
[root@server1 named]# cat /etc/named.conf
options {
listen-on port 53 { 192.168.122.1; };
directory "/var/named";
allow-query { any; };
};
zone "uos.com" IN {
type master;
file "uos.com.db";
};
zone "circle.com" IN {
type master;
file "circle.com.db";
};
zone "." IN {
type hint;
file "named.ca";
};
[root@server1 named]# cp -p uos.com.db circle.com.db
[root@server1 named]# ls -l
总用量 28
-rw-r----- 1 root named 246 11月 13 16:29 circle.com.db
drwxrwx--- 2 named named 6 10月 12 2022 data
drwxrwx--- 2 named named 6 10月 12 2022 dynamic
-rw-r----- 1 root named 2253 10月 12 2022 named.ca
-rw-r----- 1 root named 152 10月 12 2022 named.empty
-rw-r----- 1 root named 152 10月 12 2022 named.localhost
-rw-r----- 1 root named 168 10月 12 2022 named.loopback
drwxrwx--- 2 named named 6 10月 12 2022 slaves
-rw-r----- 1 root named 246 11月 13 16:29 uos.com.db
-rw-r----- 1 root named 238 11月 13 16:07 uos.com.files
[root@server1 named]# vi circle.com.db
[root@server1 named]# cat circle.com.db
$TTL 1D
@ IN SOA ns.circle.com root.ns.circle.com. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
IN NS ns.circle.com.
ns IN A 192.168.122.1
www IN A 192.168.122.1
admin IN A 192.168.122.1
oa IN A 192.168.122.1
[root@server1 named]# systemctl restart named
[root@server1 named]# curl www.circle.com
this is web1;
[root@server1 named]# curl admin.circle.com
this is web2;
[root@server1 named]#