blog
blog copied to clipboard
nginx 安装及使用技巧
第一步:安装 epel 库
sudo yum install epel-release
第二步:安装 nginx
sudo yum install nginx
安装好之后 nginx 应该会自动添加到系统变量中,可以用指令测试一下 nginx 的是不是安装好了和获取配置文件位置。
nginx -t
如果能够正常显示 nginx 的配置文件路径的话,代表 nginx 已经成功安装,但这时候它还没被启动,你需要通过以下命令来启动它:
systemctl start nginx
以下是一些常用的 nginx 命令
| 作用 | 命令 |
|---|---|
| 测试 nginx 配置是否正确 | nginx -t |
| 设置 nginx 为自启动 | systemctl enable nginx |
| 启动 nginx | systemctl start nginx |
| 重启 nginx | nginx -s reload |