1、指定在每天凌晨4:00将该时间点之前的系统日志信息(/var/log/messages )备份到目录下/backup,备份后日志文件名显示格式logfileYY-MM-DD-HH-MM
[root@localhost ~]# mkdir /backup
[root@localhost ~]# crontab -e
no crontab for root - using an empty one
'''
0 4 * * * /usr/bin/rsync -avz /var/log/messages /backup/logfile$(date +%Y-%m-%d-%H-%M).log
~
~
~
~
~
2、配置ssh免密登陆:客户端主机通过redhat用户基于秘钥验证方式进行远程连接服务器的root用户。
[root@localhost ~]# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa
Your public key has been saved in /root/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:ZBQJ7JlhZDXPbKbnisOwuaCnuF/UwUrNMsA414EM5Wk root@localhost.localdomain
The key's randomart image is:
+---[RSA 3072]----+
|.*oo.++o=o |
|o.=o.=+..= |
| oE +o=+o * |
| . . =++ + |
| o . S . |
| .. o |
| . .= . |
|...oo o. . |
|==. ..... |
+----[SHA256]-----+
[root@localhost ~]# ll /root/.ssh
总用量 8
-rw-------. 1 root root 2610 11月 21 20:39 id_rsa
-rw-r--r--. 1 root root 580 11月 21 20:39 id_rsa.pub
[root@localhost ~]# ssh-copy-id 192.168.53.212
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: ERROR: ssh: connect to host 192.168.53.212 port 22: Connection refused
[root@localhost ~]#
3、搭建一个web网站,网站显示hello world内容
[root@localhost ~]# ll /etc/yum.repos.d/
总用量 4
-rw-r--r--. 1 root root 358 11月 21 20:39 redhat.repo
[root@localhost ~]# vim /etc/yum.repos.d/aliyun.repo
[root@localhost ~]# yum install httpd -y
正在更新 Subscription Management 软件仓库。
无法读取客户身份
本系统尚未在权利服务器中注册。可使用 subscription-manager 进行注册。
aliyun-base 3.2 MB/s | 7.9 MB 00:02
aliyun-app 5.2 MB/s | 18 MB 00:03
上次元数据过期检查:0:00:01 前,执行于 2023年11月21日 星期二 20时48分17秒。
依赖关系解决。
====================================================================================
软件包 架构 版本 仓库 大小
====================================================================================
安装:
httpd x86_64 2.4.57-5.el9 aliyun-app 47 k
安装依赖关系:
apr x86_64 1.7.0-11.el9 aliyun-app 123 k
apr-util x86_64 1.6.1-23.el9 aliyun-app 95 k
apr-util-bdb x86_64 1.6.1-23.el9 aliyun-app 13 k
centos-logos-httpd noarch 90.4-1.el9 aliyun-app 252 k
httpd-core x86_64 2.4.57-5.el9 aliyun-app 1.4 M
httpd-filesystem noarch 2.4.57-5.el9 aliyun-app 14 k
httpd-tools x86_64 2.4.57-5.el9 aliyun-app 81 k
安装弱的依赖:
apr-util-openssl x86_64 1.6.1-23.el9 aliyun-app 15 k
mod_http2 x86_64 1.15.19-5.el9 aliyun-app 149 k
mod_lua x86_64 2.4.57-5.el9 aliyun-app 61 k
事务概要
====================================================================================
安装 11 软件包
总下载:2.2 M
安装大小:6.4 M
下载软件包:
(1/11): apr-util-bdb-1.6.1-23.el9.x86_64.rpm 32 kB/s | 13 kB 00:00
(2/11): apr-1.7.0-11.el9.x86_64.rpm 246 kB/s | 123 kB 00:00
(3/11): apr-util-1.6.1-23.el9.x86_64.rpm 183 kB/s | 95 kB 00:00
(4/11): apr-util-openssl-1.6.1-23.el9.x86_64.rpm 120 kB/s | 15 kB 00:00
(5/11): httpd-2.4.57-5.el9.x86_64.rpm 138 kB/s | 47 kB 00:00
(6/11): centos-logos-httpd-90.4-1.el9.noarch.rpm 492 kB/s | 252 kB 00:00
(7/11): httpd-filesystem-2.4.57-5.el9.noarch.rpm 88 kB/s | 14 kB 00:00
(8/11): httpd-core-2.4.57-5.el9.x86_64.rpm 1.9 MB/s | 1.4 MB 00:00
(9/11): mod_http2-1.15.19-5.el9.x86_64.rpm 600 kB/s | 149 kB 00:00
(10/11): httpd-tools-2.4.57-5.el9.x86_64.rpm 179 kB/s | 81 kB 00:00
(11/11): mod_lua-2.4.57-5.el9.x86_64.rpm 172 kB/s | 61 kB 00:00
------------------------------------------------------------------------------------
总计 1.4 MB/s | 2.2 MB 00:01
运行事务检查
事务检查成功。
运行事务测试
事务测试成功。
运行事务
准备中 : 1/1
安装 : apr-1.7.0-11.el9.x86_64 1/11
安装 : apr-util-bdb-1.6.1-23.el9.x86_64 2/11
安装 : apr-util-openssl-1.6.1-23.el9.x86_64 3/11
安装 : apr-util-1.6.1-23.el9.x86_64 4/11
安装 : httpd-tools-2.4.57-5.el9.x86_64 5/11
运行脚本: httpd-filesystem-2.4.57-5.el9.noarch 6/11
安装 : httpd-filesystem-2.4.57-5.el9.noarch 6/11
安装 : httpd-core-2.4.57-5.el9.x86_64 7/11
安装 : mod_lua-2.4.57-5.el9.x86_64 8/11
安装 : centos-logos-httpd-90.4-1.el9.noarch 9/11
安装 : mod_http2-1.15.19-5.el9.x86_64 10/11
安装 : httpd-2.4.57-5.el9.x86_64 11/11
运行脚本: httpd-2.4.57-5.el9.x86_64 11/11
验证 : apr-1.7.0-11.el9.x86_64 1/11
验证 : apr-util-1.6.1-23.el9.x86_64 2/11
验证 : apr-util-bdb-1.6.1-23.el9.x86_64 3/11
验证 : apr-util-openssl-1.6.1-23.el9.x86_64 4/11
验证 : centos-logos-httpd-90.4-1.el9.noarch 5/11
验证 : httpd-2.4.57-5.el9.x86_64 6/11
验证 : httpd-core-2.4.57-5.el9.x86_64 7/11
验证 : httpd-filesystem-2.4.57-5.el9.noarch 8/11
验证 : httpd-tools-2.4.57-5.el9.x86_64 9/11
验证 : mod_http2-1.15.19-5.el9.x86_64 10/11
验证 : mod_lua-2.4.57-5.el9.x86_64 11/11
已更新安装的产品。
已安装:
apr-1.7.0-11.el9.x86_64 apr-util-1.6.1-23.el9.x86_64
apr-util-bdb-1.6.1-23.el9.x86_64 apr-util-openssl-1.6.1-23.el9.x86_64
centos-logos-httpd-90.4-1.el9.noarch httpd-2.4.57-5.el9.x86_64
httpd-core-2.4.57-5.el9.x86_64 httpd-filesystem-2.4.57-5.el9.noarch
httpd-tools-2.4.57-5.el9.x86_64 mod_http2-1.15.19-5.el9.x86_64
mod_lua-2.4.57-5.el9.x86_64
完毕!
[root@localhost ~]# systemctl enable --now httpd
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
[root@localhost ~]# systemctl disable --now firewalld
Removed "/etc/systemd/system/multi-user.target.wants/firewalld.service".
Removed "/etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service".
[root@localhost ~]# echo "hello world" > /var/www/html/index.html
[root@localhost ~]#