建一个网站,
- [root@799b431e9d3b ~]# dnf install -y httpd setroubleshoot-server
- Rocky Linux 8 - AppStream 21 kB/s | 4.8 kB 00:00
- Rocky Linux 8 - AppStream 21 MB/s | 8.8 MB 00:00
- Rocky Linux 8 - BaseOS 19 kB/s | 4.3 kB 00:00
- Rocky Linux 8 - BaseOS 11 MB/s | 3.6 MB 00:00
- Rocky Linux 8 - Extras 15 kB/s | 3.5 kB 00:00
- Rocky Linux 8 - Extras 38 kB/s | 11 kB 00:00
- Last metadata expiration check: 0:00:01 ago on Sat 02 Jul 2022 03:33:56 AM CEST.
- Dependencies resolved.
- ====================================================================================================================
- Package Arch Version Repository Size
- ====================================================================================================================
- Installing:
- httpd x86_64 2.4.37-47.module+el8.6.0+985+b8ff6398.2 appstream 1.4 M
- setroubleshoot-server x86_64 3.3.26-3.el8 appstream 388 k
- Upgrading:
- audit x86_64 3.0.7-2.el8.2 baseos 262 k
- audit-libs x86_64 3.0.7-2.el8.2 baseos 122 k
- libsemanage x86_64 2.9-8.el8 baseos 167 k
- libxml2 x86_64 2.9.7-13.el8_6.1 baseos 695 k
- policycoreutils x86_64 2.9-19.el8 baseos 373 k
- Installing dependencies:
- apr x86_64 1.6.3-12.el8 appstream 128 k
- apr-util x86_64 1.6.1-6.el8.1 appstream 104 k
- cairo x86_64 1.15.12-6.el8 appstream 718 k
- cairo-gobject x86_64 1.15.12-6.el8 appstream 32 k
- checkpolicy x86_64 2.9-1.el8 baseos 345 k
- dejavu-fonts-common noarch 2.35-7.el8 baseos 73 k
- dejavu-sans-fonts noarch 2.35-7.el8 baseos 1.5 M
- fontconfig x86_64 2.13.1-4.el8 baseos 273 k
- fontpackages-filesystem noarch 1.44-22.el8 baseos 15 k
- httpd-filesystem noarch 2.4.37-47.module+el8.6.0+985+b8ff6398.2 appstream 40 k
- httpd-tools x86_64 2.4.37-47.module+el8.6.0+985+b8ff6398.2 appstream 107 k
- libX11 x86_64 1.6.8-5.el8 appstream 610 k
- libX11-common noarch 1.6.8-5.el8 appstream 157 k
- libXau x86_64 1.0.9-3.el8 appstream 36 k
- libXext x86_64 1.3.4-1.el8 appstream 44 k
- libXrender x86_64 0.9.10-7.el8 appstream 32 k
- libxcb x86_64 1.13.1-1.el8 appstream 228 k
- mailcap noarch 2.1.48-3.el8 baseos 38 k
- mod_http2 x86_64 1.15.7-5.module+el8.6.0+823+f143cee1 appstream 153 k
- pixman x86_64 0.38.4-2.el8 appstream 256 k
- policycoreutils-python-utils noarch 2.9-19.el8 baseos 252 k
- python3-audit x86_64 3.0.7-2.el8.2 baseos 86 k
- python3-cairo x86_64 1.16.3-6.el8 appstream 89 k
- python3-gobject x86_64 3.28.3-2.el8 appstream 25 k
- python3-libsemanage x86_64 2.9-8.el8 baseos 127 k
- python3-libxml2 x86_64 2.9.7-13.el8_6.1 baseos 236 k
- python3-policycoreutils noarch 2.9-19.el8 baseos 2.2 M
- python3-pydbus noarch 0.6.0-5.el8 appstream 52 k
- python3-setools x86_64 4.3.0-3.el8 baseos 623 k
- python3-systemd x86_64 234-8.el8 baseos 80 k
- rocky-logos-httpd noarch 85.0-4.el8 baseos 22 k
- setroubleshoot-plugins noarch 3.3.14-1.el8 appstream 357 k
- Installing weak dependencies:
- apr-util-bdb x86_64 1.6.1-6.el8.1 appstream 23 k
- apr-util-openssl x86_64 1.6.1-6.el8.1 appstream 26 k
- Enabling module streams:
- httpd 2.4
-
- Transaction Summary
- ====================================================================================================================
- Install 36 Packages
- Upgrade 5 Packages
-
- Total download size: 12 M
- Downloading Packages:
- Rocky Linux 8 - AppStream 104% [=======================================-] 11 kB/s | 3.7 kB --:-- ET(1/41): apr-1.6.3-12.el8.x86_64.rpm 2.8 MB/s | 128 kB 00:00
- (2/41): apr-util-1.6.1-6.el8.1.x86_64.rpm 1.8 MB/s | 104 kB 00:00
- (3/41): apr-util-bdb-1.6.1-6.el8.1.x86_64.rpm 405 kB/s | 23 kB 00:00
- (4/41): apr-util-openssl-1.6.1-6.el8.1.x86_64.rpm 4.6 MB/s | 26 kB 00:00
- (5/41): cairo-gobject-1.15.12-6.el8.x86_64.rpm 4.4 MB/s | 32 kB 00:00
- (6/41): httpd-filesystem-2.4.37-47.module+el8.6.0+985+b8ff6398.2.noarch.rpm 8.0 MB/s | 40 kB 00:00
- (7/41): httpd-tools-2.4.37-47.module+el8.6.0+985+b8ff6398.2.x86_64.rpm 12 MB/s | 107 kB 00:00
- (8/41): cairo-1.15.12-6.el8.x86_64.rpm 19 MB/s | 718 kB 00:00
- (9/41): libX11-common-1.6.8-5.el8.noarch.rpm 21 MB/s | 157 kB 00:00
- (10/41): libXau-1.0.9-3.el8.x86_64.rpm 10 MB/s | 36 kB 00:00
- (11/41): libXext-1.3.4-1.el8.x86_64.rpm 10 MB/s | 44 kB 00:00
- (12/41): libX11-1.6.8-5.el8.x86_64.rpm 18 MB/s | 610 kB 00:00
- (13/41): libXrender-0.9.10-7.el8.x86_64.rpm 4.9 MB/s | 32 kB 00:00
- (14/41): httpd-2.4.37-47.module+el8.6.0+985+b8ff6398.2.x86_64.rpm 21 MB/s | 1.4 MB 00:00
- (15/41): mod_http2-1.15.7-5.module+el8.6.0+823+f143cee1.x86_64.rpm 7.5 MB/s | 153 kB 00:00
- (16/41): libxcb-1.13.1-1.el8.x86_64.rpm 8.6 MB/s | 228 kB 00:00
- (17/41): python3-cairo-1.16.3-6.el8.x86_64.rpm 15 MB/s | 89 kB 00:00
- (18/41): pixman-0.38.4-2.el8.x86_64.rpm 16 MB/s | 256 kB 00:00
- (19/41): python3-gobject-3.28.3-2.el8.x86_64.rpm 4.1 MB/s | 25 kB 00:00
- (20/41): python3-pydbus-0.6.0-5.el8.noarch.rpm 8.7 MB/s | 52 kB 00:00
- (21/41): setroubleshoot-plugins-3.3.14-1.el8.noarch.rpm 23 MB/s | 357 kB 00:00
- (22/41): setroubleshoot-server-3.3.26-3.el8.x86_64.rpm 14 MB/s | 388 kB 00:00
- (23/41): checkpolicy-2.9-1.el8.x86_64.rpm 12 MB/s | 345 kB 00:00
- (24/41): dejavu-fonts-common-2.35-7.el8.noarch.rpm 3.8 MB/s | 73 kB 00:00
- (25/41): fontpackages-filesystem-1.44-22.el8.noarch.rpm 4.0 MB/s | 15 kB 00:00
- (26/41): mailcap-2.1.48-3.el8.noarch.rpm 8.6 MB/s | 38 kB 00:00
- (27/41): fontconfig-2.13.1-4.el8.x86_64.rpm 19 MB/s | 273 kB 00:00
- (28/41): python3-audit-3.0.7-2.el8.2.x86_64.rpm 14 MB/s | 86 kB 00:00
- (29/41): policycoreutils-python-utils-2.9-19.el8.noarch.rpm 24 MB/s | 252 kB 00:00
- (30/41): python3-libsemanage-2.9-8.el8.x86_64.rpm 22 MB/s | 127 kB 00:00
- (31/41): python3-libxml2-2.9.7-13.el8_6.1.x86_64.rpm 18 MB/s | 236 kB 00:00
- (32/41): dejavu-sans-fonts-2.35-7.el8.noarch.rpm 29 MB/s | 1.5 MB 00:00
- (33/41): python3-systemd-234-8.el8.x86_64.rpm 12 MB/s | 80 kB 00:00
- (34/41): rocky-logos-httpd-85.0-4.el8.noarch.rpm 5.0 MB/s | 22 kB 00:00
- (35/41): audit-3.0.7-2.el8.2.x86_64.rpm 27 MB/s | 262 kB 00:00
- (36/41): audit-libs-3.0.7-2.el8.2.x86_64.rpm 21 MB/s | 122 kB 00:00
- (37/41): python3-setools-4.3.0-3.el8.x86_64.rpm 14 MB/s | 623 kB 00:00
- (38/41): libsemanage-2.9-8.el8.x86_64.rpm 23 MB/s | 167 kB 00:00
- (39/41): python3-policycoreutils-2.9-19.el8.noarch.rpm 30 MB/s | 2.2 MB 00:00
- (40/41): policycoreutils-2.9-19.el8.x86_64.rpm 15 MB/s | 373 kB 00:00
- (41/41): libxml2-2.9.7-13.el8_6.1.x86_64.rpm 14 MB/s | 695 kB 00:00
- --------------------------------------------------------------------------------------------------------------------
- Total 18 MB/s | 12 MB 00:00
- Running transaction check
- Transaction check succeeded.
- Running transaction test
- Transaction test succeeded.
- Running transaction
- Preparing : 1/1
- Running scriptlet: audit-libs-3.0.7-2.el8.2.x86_64 1/1
- Upgrading : audit-libs-3.0.7-2.el8.2.x86_64 1/46
- Installing : apr-1.6.3-12.el8.x86_64 2/46
- Running scriptlet: apr-1.6.3-12.el8.x86_64 2/46
- Installing : apr-util-bdb-1.6.1-6.el8.1.x86_64 3/46
- Installing : apr-util-openssl-1.6.1-6.el8.1.x86_64 4/46
- Installing : apr-util-1.6.1-6.el8.1.x86_64 5/46
- Running scriptlet: apr-util-1.6.1-6.el8.1.x86_64 5/46
- Installing : python3-audit-3.0.7-2.el8.2.x86_64 6/46
- Upgrading : libsemanage-2.9-8.el8.x86_64 7/46
- Installing : fontpackages-filesystem-1.44-22.el8.noarch 8/46
- Installing : pixman-0.38.4-2.el8.x86_64 9/46
- Installing : dejavu-fonts-common-2.35-7.el8.noarch 10/46
- Installing : dejavu-sans-fonts-2.35-7.el8.noarch 11/46
- Installing : fontconfig-2.13.1-4.el8.x86_64 12/46
- Running scriptlet: fontconfig-2.13.1-4.el8.x86_64 12/46
- Installing : python3-libsemanage-2.9-8.el8.x86_64 13/46
- Upgrading : policycoreutils-2.9-19.el8.x86_64 14/46
- Running scriptlet: policycoreutils-2.9-19.el8.x86_64 14/46
- Installing : httpd-tools-2.4.37-47.module+el8.6.0+985+b8ff6398.2.x86_64 15/46
- Upgrading : audit-3.0.7-2.el8.2.x86_64 16/46
- Running scriptlet: audit-3.0.7-2.el8.2.x86_64 16/46
- Upgrading : libxml2-2.9.7-13.el8_6.1.x86_64 17/46
- Installing : python3-libxml2-2.9.7-13.el8_6.1.x86_64 18/46
- Installing : rocky-logos-httpd-85.0-4.el8.noarch 19/46
- Installing : python3-systemd-234-8.el8.x86_64 20/46
- Installing : python3-setools-4.3.0-3.el8.x86_64 21/46
- Installing : mailcap-2.1.48-3.el8.noarch 22/46
- Installing : checkpolicy-2.9-1.el8.x86_64 23/46
- Installing : python3-policycoreutils-2.9-19.el8.noarch 24/46
- Installing : policycoreutils-python-utils-2.9-19.el8.noarch 25/46
- Installing : python3-pydbus-0.6.0-5.el8.noarch 26/46
- Installing : libXau-1.0.9-3.el8.x86_64 27/46
- Installing : libxcb-1.13.1-1.el8.x86_64 28/46
- Installing : libX11-common-1.6.8-5.el8.noarch 29/46
- Installing : libX11-1.6.8-5.el8.x86_64 30/46
- Installing : libXext-1.3.4-1.el8.x86_64 31/46
- Installing : libXrender-0.9.10-7.el8.x86_64 32/46
- Installing : cairo-1.15.12-6.el8.x86_64 33/46
- Installing : cairo-gobject-1.15.12-6.el8.x86_64 34/46
- Installing : python3-cairo-1.16.3-6.el8.x86_64 35/46
- Installing : python3-gobject-3.28.3-2.el8.x86_64 36/46
- Installing : setroubleshoot-plugins-3.3.14-1.el8.noarch 37/46
- Running scriptlet: setroubleshoot-server-3.3.26-3.el8.x86_64 38/46
- Installing : setroubleshoot-server-3.3.26-3.el8.x86_64 38/46
- Running scriptlet: setroubleshoot-server-3.3.26-3.el8.x86_64 38/46
- Running scriptlet: httpd-filesystem-2.4.37-47.module+el8.6.0+985+b8ff6398.2.noarch 39/46
- Installing : httpd-filesystem-2.4.37-47.module+el8.6.0+985+b8ff6398.2.noarch 39/46
- Installing : mod_http2-1.15.7-5.module+el8.6.0+823+f143cee1.x86_64 40/46
- Installing : httpd-2.4.37-47.module+el8.6.0+985+b8ff6398.2.x86_64 41/46
- Running scriptlet: httpd-2.4.37-47.module+el8.6.0+985+b8ff6398.2.x86_64 41/46
- Running scriptlet: policycoreutils-2.9-16.el8.x86_64 42/46
- Cleanup : policycoreutils-2.9-16.el8.x86_64 42/46
- Running scriptlet: audit-3.0-0.17.20191104git1c2f876.el8.1.x86_64 43/46
- Cleanup : audit-3.0-0.17.20191104git1c2f876.el8.1.x86_64 43/46
- Running scriptlet: audit-3.0-0.17.20191104git1c2f876.el8.1.x86_64 43/46
- Cleanup : libsemanage-2.9-6.el8.x86_64 44/46
- Cleanup : audit-libs-3.0-0.17.20191104git1c2f876.el8.1.x86_64 45/46
- Cleanup : libxml2-2.9.7-11.el8.x86_64 46/46
- Running scriptlet: httpd-2.4.37-47.module+el8.6.0+985+b8ff6398.2.x86_64 46/46
- Running scriptlet: libxml2-2.9.7-11.el8.x86_64 46/46
- Running scriptlet: fontconfig-2.13.1-4.el8.x86_64 46/46
- Verifying : apr-1.6.3-12.el8.x86_64 1/46
- Verifying : apr-util-1.6.1-6.el8.1.x86_64 2/46
- Verifying : apr-util-bdb-1.6.1-6.el8.1.x86_64 3/46
- Verifying : apr-util-openssl-1.6.1-6.el8.1.x86_64 4/46
- Verifying : cairo-1.15.12-6.el8.x86_64 5/46
- Verifying : cairo-gobject-1.15.12-6.el8.x86_64 6/46
- Verifying : httpd-2.4.37-47.module+el8.6.0+985+b8ff6398.2.x86_64 7/46
- Verifying : httpd-filesystem-2.4.37-47.module+el8.6.0+985+b8ff6398.2.noarch 8/46
- Verifying : httpd-tools-2.4.37-47.module+el8.6.0+985+b8ff6398.2.x86_64 9/46
- Verifying : libX11-1.6.8-5.el8.x86_64 10/46
- Verifying : libX11-common-1.6.8-5.el8.noarch 11/46
- Verifying : libXau-1.0.9-3.el8.x86_64 12/46
- Verifying : libXext-1.3.4-1.el8.x86_64 13/46
- Verifying : libXrender-0.9.10-7.el8.x86_64 14/46
- Verifying : libxcb-1.13.1-1.el8.x86_64 15/46
- Verifying : mod_http2-1.15.7-5.module+el8.6.0+823+f143cee1.x86_64 16/46
- Verifying : pixman-0.38.4-2.el8.x86_64 17/46
- Verifying : python3-cairo-1.16.3-6.el8.x86_64 18/46
- Verifying : python3-gobject-3.28.3-2.el8.x86_64 19/46
- Verifying : python3-pydbus-0.6.0-5.el8.noarch 20/46
- Verifying : setroubleshoot-plugins-3.3.14-1.el8.noarch 21/46
- Verifying : setroubleshoot-server-3.3.26-3.el8.x86_64 22/46
- Verifying : checkpolicy-2.9-1.el8.x86_64 23/46
- Verifying : dejavu-fonts-common-2.35-7.el8.noarch 24/46
- Verifying : dejavu-sans-fonts-2.35-7.el8.noarch 25/46
- Verifying : fontconfig-2.13.1-4.el8.x86_64 26/46
- Verifying : fontpackages-filesystem-1.44-22.el8.noarch 27/46
- Verifying : mailcap-2.1.48-3.el8.noarch 28/46
- Verifying : policycoreutils-python-utils-2.9-19.el8.noarch 29/46
- Verifying : python3-audit-3.0.7-2.el8.2.x86_64 30/46
- Verifying : python3-libsemanage-2.9-8.el8.x86_64 31/46
- Verifying : python3-libxml2-2.9.7-13.el8_6.1.x86_64 32/46
- Verifying : python3-policycoreutils-2.9-19.el8.noarch 33/46
- Verifying : python3-setools-4.3.0-3.el8.x86_64 34/46
- Verifying : python3-systemd-234-8.el8.x86_64 35/46
- Verifying : rocky-logos-httpd-85.0-4.el8.noarch 36/46
- Verifying : audit-3.0.7-2.el8.2.x86_64 37/46
- Verifying : audit-3.0-0.17.20191104git1c2f876.el8.1.x86_64 38/46
- Verifying : audit-libs-3.0.7-2.el8.2.x86_64 39/46
- Verifying : audit-libs-3.0-0.17.20191104git1c2f876.el8.1.x86_64 40/46
- Verifying : libsemanage-2.9-8.el8.x86_64 41/46
- Verifying : libsemanage-2.9-6.el8.x86_64 42/46
- Verifying : libxml2-2.9.7-13.el8_6.1.x86_64 43/46
- Verifying : libxml2-2.9.7-11.el8.x86_64 44/46
- Verifying : policycoreutils-2.9-19.el8.x86_64 45/46
- Verifying : policycoreutils-2.9-16.el8.x86_64 46/46
-
- Upgraded:
- audit-3.0.7-2.el8.2.x86_64 audit-libs-3.0.7-2.el8.2.x86_64 libsemanage-2.9-8.el8.x86_64
- libxml2-2.9.7-13.el8_6.1.x86_64 policycoreutils-2.9-19.el8.x86_64
- Installed:
- apr-1.6.3-12.el8.x86_64
- apr-util-1.6.1-6.el8.1.x86_64
- apr-util-bdb-1.6.1-6.el8.1.x86_64
- apr-util-openssl-1.6.1-6.el8.1.x86_64
- cairo-1.15.12-6.el8.x86_64
- cairo-gobject-1.15.12-6.el8.x86_64
- checkpolicy-2.9-1.el8.x86_64
- dejavu-fonts-common-2.35-7.el8.noarch
- dejavu-sans-fonts-2.35-7.el8.noarch
- fontconfig-2.13.1-4.el8.x86_64
- fontpackages-filesystem-1.44-22.el8.noarch
- httpd-2.4.37-47.module+el8.6.0+985+b8ff6398.2.x86_64
- httpd-filesystem-2.4.37-47.module+el8.6.0+985+b8ff6398.2.noarch
- httpd-tools-2.4.37-47.module+el8.6.0+985+b8ff6398.2.x86_64
- libX11-1.6.8-5.el8.x86_64
- libX11-common-1.6.8-5.el8.noarch
- libXau-1.0.9-3.el8.x86_64
- libXext-1.3.4-1.el8.x86_64
- libXrender-0.9.10-7.el8.x86_64
- libxcb-1.13.1-1.el8.x86_64
- mailcap-2.1.48-3.el8.noarch
- mod_http2-1.15.7-5.module+el8.6.0+823+f143cee1.x86_64
- pixman-0.38.4-2.el8.x86_64
- policycoreutils-python-utils-2.9-19.el8.noarch
- python3-audit-3.0.7-2.el8.2.x86_64
- python3-cairo-1.16.3-6.el8.x86_64
- python3-gobject-3.28.3-2.el8.x86_64
- python3-libsemanage-2.9-8.el8.x86_64
- python3-libxml2-2.9.7-13.el8_6.1.x86_64
- python3-policycoreutils-2.9-19.el8.noarch
- python3-pydbus-0.6.0-5.el8.noarch
- python3-setools-4.3.0-3.el8.x86_64
- python3-systemd-234-8.el8.x86_64
- rocky-logos-httpd-85.0-4.el8.noarch
- setroubleshoot-plugins-3.3.14-1.el8.noarch
- setroubleshoot-server-3.3.26-3.el8.x86_64
-
- Complete!
- [root@799b431e9d3b ~]# sed -i 's/DocumentRoot\ "\/var\/www\/html"/DocumentRoot\ "\/web"/' /etc/httpd/conf/httpd.conf[root@799b431e9d3b ~]# mkdir /web
- [root@799b431e9d3b ~]# echo welcome to web > /web/index.html
- [root@799b431e9d3b ~]# systemctl enable --now httpd
- Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
- [root@799b431e9d3b ~]#
提示无权限,

Why?
根据提示是无权限。那么我们运行httpd的账号是否有权限读取/web/index.html文件。下图可见是有权限的,

当服务器上服务不正常work时,通常是SeLinux导致。我们可以这样测试一下,在httpd所在的服务器,将SeLinux关闭再来访问测试下,

关掉SeLinux,并将httpd配置文件的Directory目录配置为/web,可以访问了。我们再将SeLinux打开试下,

查看日志,


$(journalctl | grep sealert | tail -1 | sed -n -e 's/^.*run: //p') | less
修复/web/目录,参考/var/www目录,

验证:
生效了!