Nginx-1 yum安装
2020-01-08 本文已影响0人
Habit_1027
Web服务器介绍nginx
Nginx基本使用**
获取Nginx
Nginx的官方主页: http://nginx.org
关闭防火墙关闭selinux
[root@soso666 ~]# systemctl stop firewalld #关闭防火墙
[root@soso666 ~]# systemctl disable firewalld #开机关闭防火墙
[root@soso666 ~]# setenforce 0 #临时关闭selinux
[root@soso666 ~]# getenforce #查看selinux状态
Nginx安装:
[root@soso666 ~]# cd /etc/yum.repos.d/
[root@soso666 yum.repos.d]# vi nginx.repo
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1
[root@soso666 yum.repos.d]# yum clean all
[root@soso666 yum.repos.d]# yum makecache
[root@soso666 ~]# yum install -y nginx #安装nginx
[root@soso666 ~]# systemctl start nginx #启动
[root@soso666 ~]# systemctl restart nginx #重启
[root@soso666 ~]# systemctl enable nginx #开机启动
[root@soso666 ~]# systemctl stop nginx #关闭
1.查看nginx状态
[root@soso666 ~]# ps aux | grep nginx
root 3927 0.0 0.0 46384 968 ? Ss 18:46 0:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
nginx 3928 0.0 0.1 46792 1932 ? S 18:46 0:00 nginx: worker process
root 3932 0.0 0.0 112660 968 pts/1 R+ 18:47 0:00 grep --color=auto nginx
2.查看nginx端口
[root@soso666 ~]# netstat -lntp | grep 80
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 3927/nginx: master
#注意:nginx默认端口为80
3.测试主页是否可以访问:
[root@soso666 ~]# curl -I http://127.0.0.1
HTTP/1.1 200 OK
Server: nginx/1.16.1
Date: Sat, 16 Nov 2019 10:49:48 GMT
Content-Type: text/html
Content-Length: 635
Last-Modified: Fri, 11 Oct 2019 06:45:33 GMT
Connection: keep-alive
ETag: "5da0250d-27b"
Accept-Ranges: bytes
image.png