centos下安装nginx

官方教程:

http://nginx.org/en/linux_packages.html#RHEL-CentOS
一、安装指南(installtion instructions)
Before you install nginx for the first time on a new machine, you need to set up the nginx packages repository. Afterward, you can install and update nginx from the repository.
在第一次安装nginx之前,需要设置nginx安装包仓库,之后,安装和更新nginx都从这个仓库。
二、安装依赖(install the prerequisites)

sudo yum install yum-utils

三、设置yum仓库,在etc /yum.repos.d目录下创建文件 nginx.repo /etc/yum.repos.d/nginx.repo内容如下:(
To set up the yum repository, create the file named /etc/yum.repos.d/nginx.repo
with the following contents:)

[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/releasever/basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true

[nginx-mainline]
name=nginx mainline repo
baseurl=http://nginx.org/packages/mainline/centos/releasever/basearch/
gpgcheck=1
enabled=0
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true

四、By default, the repository for stable nginx packages is used.
If you would like to use mainline nginx packages, run the following command:
默认情况下,安装包使用的是稳定版本,如果想使用开发版本,运行下列命令:

sudo yum-config-manager --enable nginx-mainline

To install nginx, run the following command:(运行下列命令安装nginx)

sudo yum install nginx

When prompted to accept the GPG key,
verify that the fingerprint matches 573B FD6B 3D8F BC64 1079 A6AB ABF5 BD82 7BD9 BF62,
and if so, accept it.
当提示接收GPG密钥时,如果指纹是
573B FD6B 3D8F BC64 1079 A6AB ABF5 BD82 7BD9 BF62, 确认就行
这个指纹验证只有在第一次安装时才验证

启动nginx命令

systemctl start nginx

注意:当启动时报错:

Job for nginx.service failed because the control process exited with error code. See “systemctl status nginx.service” and “journalctl -xe” for details.
使用systemctl status nginx 查询发现80端口被占用时,找到default.conf配置文件修改端口号,如果修改后还提示
占用,多换几个端口试试!!



来自为知笔记(Wiz)


posted on 2020-11-11 23:06  白衣风云  阅读(211)  评论(0编辑  收藏  举报

导航