centos7rpm安装nginx
⼀、下载nginx rpm包
nginx停止命令地址为:
下载nginx-1.18.86_64包
[root@iZ2ze6bgt1xmvd4jc0v7nmZ src]# wget /packages/centos/7/x86_64/RPMS/nginx-1.18.86_64.rpm ⼆、查询是否已经安装了nginx
[root@iZ2ze6bgt1xmvd4jc0v7nmZ src]# rpm -qa|grep nginx
如果有安装了,执⾏ rpm  -e 进⾏卸载
三、执⾏rpm命令安装
rpm 安装⽅式nginx 默认安装位置在 /etc/nginx/ ⽬录下
[root@iZ2ze6bgt1xmvd4jc0v7nmZ src]# rpm -ivh nginx-1.18.86_64.rpm
warning: nginx-1.18.86_64.rpm: Header V4 RSA/SHA1 Signature, key ID 7bd9bf62: NOKEY
<                          >>>>>>### [100%]
Updating /
1:nginx-1:1.18.        >>>>>>### [100%]
----------------------------------------------------------------------
Thanks for using nginx!
Please find the official documentation for nginx here:
* /en/docs/
Please subscribe to nginx-announce mailing list to get
the most important news about nginx:
* /en/support.html
Commercial subscriptions for nginx are available on:
* nginx/products/
四、启动nginx
[root@iZ2ze6bgt1xmvd4jc0v7nmZ local]# systemctl start nginx
五、查询nginx
[root@iZ2ze6bgt1xmvd4jc0v7nmZ local]# systemctl status nginx
● nginx.service - nginx - high performance web server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
Active: active (running) since Tue 2021-04-0611:36:21 CST; 1min 38s ago
Docs: /en/docs/
Process: 2677 ExecStart=/usr/sbin/nginx -c /etc/f (code=exited, status=0/SUCCESS)
Main PID: 2678 (nginx)
Tasks: 2
Memory: 1.5M
CGroup: /system.slice/nginx.service
├─2678 nginx: master process /usr/sbin/nginx -c /etc/f
└─2679 nginx: worker process
Apr 0611:36:21 iZ2ze6bgt1xmvd4jc0v7nmZ systemd[1]: Starting nginx - high performance
Apr 0611:36:21 iZ2ze6bgt1xmvd4jc0v7nmZ systemd[1]: Started nginx - high performance web server.
[root@iZ2ze6bgt1xmvd4jc0v7nmZ local]#
六、访问web
[root@iZ2ze6bgt1xmvd4jc0v7noZ ~]# curl 172.27.6.3
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
body {
width: 35em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>
<p>For online documentation and support please refer to
<a href="/"&</a>.<br/>
Commercial support is available at
<a href="nginx/">nginx</a>.</p>
<p><em>Thank you for using nginx.</em></p>
</body>
</html>
[root@iZ2ze6bgt1xmvd4jc0v7noZ ~]#
七、设置开机⾃启动
查询nginx是否开机⾃启动
[root@iZ2ze6bgt1xmvd4jc0v7nmZ local]# systemctl list-unit-files |grep nginx
nginx-debug.service                          disabled
nginx.service                                disabled
[root@iZ2ze6bgt1xmvd4jc0v7nmZ local]#
设置允许开机⾃启动
[root@iZ2ze6bgt1xmvd4jc0v7nmZ local]# systemctl enable nginx
Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service 再次查询
[root@iZ2ze6bgt1xmvd4jc0v7nmZ local]# systemctl list-unit-files|grep nginx
nginx-debug.service                          disabled
nginx.service                                enabled
[root@iZ2ze6bgt1xmvd4jc0v7nmZ local]#
rpm 安装⽅式nginx 默认安装位置在 /etc/nginx/ ⽬录下
⼋、卸载
[root@iZ2ze6bgt1xmvd4jc0v7nmZ nginx]# rpm -qa|grep nginx
nginx-1.18.86_64
停⽌nginx服务
[root@iZ2ze6bgt1xmvd4jc0v7nmZ nginx]# systemctl stop nginx
卸载
[root@iZ2ze6bgt1xmvd4jc0v7nmZ nginx]# rpm -e nginx
删除⽬录
[root@iZ2ze6bgt1xmvd4jc0v7nmZ nginx]# rm -rf /etc/nginx/

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。

发表评论