Centos8通过dnf安装certbot,设置nginx自启动

将centos8的软件库改为stream的

dnf --disablerepo '*' --enablerepo=extras swap centos-linux-repos centos-stream-repos

 

如果centos8默认软件包里没有certbot,就需要更新软件包:

dnf install epel-release
dnf upgrade

一般更新包后就可以安装了

dnf install certbot

nginx安装后设置自启动:

1、一般使用systemctl enable nginx,如果这个命令无效,可以使用其他的方法

2、直接修订文件/etc/rc.local,添加nginx启动命令即可(不推荐)

3、使用chkconfig(未亲测)
在/etc/init.d目录下新建一个脚本nginx.sh并设置执行权限,脚本开头加入以下代码:

#!/bin/sh
#chkconfig:2345 80 90
#description:自定义的脚本描述如nginx

#chkconfig:后面的数字暂不了解含义。
使用chkconfig命令将脚本添加到开机启动

chkconfig --add nginx.sh
chkconfig nginx.sh on

4、在/etc/profile.d/添加新脚本nginx.sh,不用设置执行权限(每次本账户登录都会执行一次)

service nginx start

 

posted @ 2022-09-29 10:21  刘镇维  阅读(254)  评论(0编辑  收藏  举报