当前位置 主页 > 服务器问题 > nginx问题汇总 >

CentOS7下 yum方式安装Nginx的实现步骤

栏目:nginx问题汇总 时间:2018-10-26 11:54

这篇文章主要介绍了CentOS7下 yum方式安装Nginx的实现步骤的相关资料,希望通过本文能帮助到大家,需要的朋友可以参考下

CentOS7下 yum方式安装Nginx的实现步骤

Nginx 是一个很强大的高性能Web和反向代理服务器,它具有众多非常优越的特性。诸如低开销,高并发,支持缓存,支持正反向代理,支持负载均衡,支持正则,支持rewrite等等不一而足。所以众多粉丝们也是不计其数。本文基于CentOS 7简要描述yum方式的安装部署,供大家参考。

如果是编译安装可以参考:Linux 6下安装编译安装Nginx

有关Nginx的常用配置可参考:Nginx 概述及日常管理

一、配置nginx yum源

演示环境[root@centos7-router ~]# more /etc/redhat-releaseCentOS Linux release 7.2.1511 (Core)[root@centos7-router ~]# vim /etc/yum.repos.d/nginx.repo[nginx]name=nginx repobaseurl=http://nginx.org/packages/OS/OSRELEASE/$basearch/gpgcheck=0enabled=1将上述配置文件中的OS替换为rhel或者centos,OSRELEASE替换为6或者7,即当前的Linux为6还是7版本查看本机ip[root@centos7-router ~]# ip addr|grep inet|grep globalinet 172.24.8.254/24 brd 172.24.8.255 scope global eno16777728inet 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/upgrade/usr/sbin/nginx/usr/sbin/nginx-debug/usr/share/doc/nginx-1.12.2/usr/share/doc/nginx-1.12.2/COPYRIGHT/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

启动nginxroot@centos7-router ~]# systemctl start nginx[root@centos7-router ~]# systemctl enable nginx ###配置自启动[root@centos7-router ~]# ss -nltp|grep nginxLISTEN 0 128 *:80 *:* users:(("nginx",pid=65418,fd=6),("nginx",pid=65415,fd=6))查看nginx的版本[root@centos7-router ~]# nginx -vnginx version: nginx/1.12.2查看或修改配置文件[root@centos7-router ~]# more /etc/nginx/nginx.confuser nginx;worker_processes 1;error_log /var/log/nginx/error.log warn;pid /var/run/nginx.pid;events {worker_connections 1024;}http {include /etc/nginx/mime.types;  ### Author : Leshamidefault_type application/octet-stream; ### Blog : http://blog.csdn.net/leshamilog_format main '$remote_addr - $remote_user [$time_local] "$request" ''$status $body_bytes_sent "$http_referer" ''"$http_user_agent" "$http_x_forwarded_for"';access_log /var/log/nginx/access.log main;sendfile on;#tcp_nopush on;keepalive_timeout 65;#gzip on;include /etc/nginx/conf.d/*.conf;}[root@centos7-router ~]# firewall-cmd --add-service=http --permanent[root@centos7-router ~]# firewall-cmd --reload从其他机器验证nginx[root@centos7-web ~]# curl http://172.24.8.254<!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 andworking. Further configuration is required.</p><p>For online documentation and support please refer to<a href="http://nginx.org/" rel="external nofollow" >nginx.org</a>.<br/>Commercial support is available at<a href="http://nginx.com/" rel="external nofollow" >nginx.com</a>.</p><p><em>Thank you for using nginx.</em></p></body></html>



缩小 缩小 缩小 缩小
IIS7整站下载工具 IIS7批量查询排名 IIS7远程桌面连接工具 iis7-iis网站批量管理 iis7批量替换工具 IIS7服务器专用下载工具 IIS7日志分析工具 IIS7批量PING,服务器批量添加网卡IP小工具 IIS7远程同步备份工具
IIS7网站监控 站群批量SEO查询 批量获取排名域名 批量关键词排名查询 模拟各种蜘蛛 批量友情链接监测 批量检测死链 搜索引擎大全 批量查询外链
批量查询网站标题 批量查询KeyWords 批量查询描述 批量查询网站IP 批量百度收录查询 批量查询百度日收录 批量查询百度周收录 批量查询百度月收录 批量查询360总收录 批量查询360日收录 批量查询网站年龄 批量查询360PC权重 批量查询爱站移动权重 批量查询站长移动权重 批量查询360移动权重 批量查询神马权重 批量查询谷歌PR 批量查询搜狗PR 批量查询百度反链 批量查询爱站首页反链 批量查询爱站内页反链 批量查询百度快照 批量查询搜狗快照 批量icp备案查询 批量网站ip地址查询 批量查询导出链接 批量查询百度V认证 批量查询百度安全 批量查询站长PC权重 批量查询爱站PC权重 批量查询搜狗总收录 站长资源大全 IIS7-cms大全 IIS7站群大全 IIS7虚拟空间大全 IIS7服务器大全 IIS7-VPS大全