介绍
这篇文章给大家分享的是有关CentOS7中如何通过百胜方式安装Nginx的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。
<强> CentOS7下百胜方式安装Nginx的实现步骤强>
Nginx是一个很强大的高性能的Web和反向代理服务器,它具有众多非常优越的特性。诸如低开销,高并发,支持缓存,支持正反向代理,支持负载均衡,支持正则,支持重写等等不一而足,所以众多粉丝们也是不计其数。本文基于CentOS 7简要描述百胜方式的安装部署,供大家参考。
如果是编译安装可以参考:Linux 6下安装编译安装Nginx
有关Nginx的常用配置可参考:Nginx概述及日常管理
<强>一、配置Nginx百胜源强>
演示环境 (root@centos7-router ~) #, more /etc/redhat-release CentOS Linux  release 7.2.1511 (核心) (root@centos7-router ~) #, vim /etc/yum.repos.d/nginx.repo (nginx) name=nginx 回购 baseurl=http://nginx.org/packages/OS/OSRELEASE/basearch美元/gpgcheck=0 启用=1 将上述配置文件中的OS替换为rhel或者centos, OSRELEASE替换为6或7者,即当前的Linux为6还版是7本 查看本机ip (root@centos7-router ~) #, ip addr | grep inet | grep 全球 inet 172.24.8.254/24  brd 172.24.8.255 scope  global eno16777728 inet 192.168.1.175/24 brd  192.168.1.255 scope  global dynamic eno33554960
<强>二、安装nginx 强>
[root@centos7-router ~] #, yum install nginx - y (root@centos7-router ~) #, yum install nginx-module-perl.x86_64 -y 查看生程的相关文件 (root@centos7-router ~) #, rpm -ql nginx/etc/logrotate.d/nginx/etc/nginx/etc/nginx/conf.d/etc/nginx/conf.d/default.conf/etc/nginx/fastcgi_params/etc/nginx/koi-utf/etc/nginx/koi-win/etc/nginx/mime.types/etc/nginx/modules/etc/nginx/nginx.conf/etc/nginx/scgi_params/etc/nginx/uwsgi_params/etc/nginx/win-utf/etc/sysconfig/nginx/etc/sysconfig/nginx-debug/usr/lib/systemd/system/nginx-debug.service/usr/lib/systemd/system/nginx.service/usr/lib64/nginx/usr/lib64/nginx/modules/usr/libexec/initscripts/legacy-actions/nginx/usr/libexec/initscripts/legacy-actions/nginx/check-reload/usr/libexec/initscripts/legacy-actions/nginx/升级/usr/sbin/nginx/usr/sbin/nginx-debug/usr/share/doc/nginx-1.12.2/usr/share/doc/nginx-1.12.2/版权/usr/share/man/man8/nginx.8.gz/usr/share/nginx/usr/share/nginx/html/usr/share/nginx/html/50x.html/usr/share/nginx/html/index.html/var/cache/nginx/var/log/nginx
<强>三、验证nginx 强>
启动nginx root@centos7-router ~] #, systemctl start nginx (root@centos7-router ~) #, systemctl enable nginx # # #配置自启动 (root@centos7-router ~) #, ss -nltp | grep nginx *:LISTEN 0, 128, 80, *: *,用户:((“nginx" pid=65418, fd=6), (“nginx" pid=65415, fd=6)) 查看nginx的版本 (root@centos7-router ~) #, nginx - v nginx 版本:nginx/1.12.2 查看或修改配置文件 (root@centos7-router ~) #, more /etc/nginx/nginx.conf user nginx; worker_processes 1; error_log /var/log/nginx error.log 警告; pid /var/运行/nginx.pid; events { worker_connections 1024; } http { include /etc/nginx/mime.types;,, # # #, Author : Leshami default_type 应用程序/八进制,# # #,Blog : http://blog.csdn.net/leshami log_format main & # 39; remote_addr 美元;作用;remote_user 美元;[time_local美元],“request"美元;,& # 39; & # 39;status 美元;body_bytes_sent 美元;“http_referer"美元;,& # 39; & # 39;“http_user_agent"美元;,“http_x_forwarded_for"美元;& # 39;; access_log /var/log/nginx access.log 主要; sendfile ; # tcp_nopush ; keepalive_timeout 65; # gzip ; include /etc/nginx/conf.d/* . conf; } (root@centos7-router ~) #, firewall-cmd ——添加服务=http 永久的 (root@centos7-router ~) #, firewall-cmd ——重载 从其他机器验证nginx (root@centos7-web ~) #, curl http://172.24.8.254 & lt; ! DOCTYPE html> & lt; html> & lt; head> & lt; title> Welcome 用nginx ! & lt;/title> & lt; style> body { 宽度:35 em; 保证金:0,汽车; 大河马字体,字体类型:还以为,Verdana, Arial,,无衬线; } & lt;/style> & lt;/head> & lt; body> & lt; h2> Welcome 用nginx ! & lt;/h2> & lt; p> If 你阅读却;能够页面,从而nginx web server is successfully installed 工作只Further configuration  is 需要灵活;/p> & lt; p> For online  documentation 以及support please refer https://www.yisu.com/zixun/& lt; a  href=" http://nginx.org/" nginx.org rel="外部nofollow”>CentOS7中如何通过百胜方式安装Nginx