整理Nginx安装,常用命令,使用,配置。
安装
- 创建/etc/yum.repos.d/nginx.repo
sudo vim /etc/yum.repos.d/nginx.repo
- 填写内容
1
2
3
4
5
6
7
8
9
10
11
12
13[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
[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 - 使用mainline nginx的包
sudo yum-config-manager --enable nginx-mainline
- 安装 sudo yum install nginx
- 测试是否安装成功
nginx -v
查看版本nginx -t
返回:nginx: configuration file /etc/nginx/nginx.conf test is successful
sudo nginx
启动nginx
发现错误:nginx: [emerg] still could not bind()
原因:80端口被占用
解决:
sudo netstat -anp | grep 80
查看80端口使用情况