centOS-64位通过YUM源安装nginx
第一步:在 /etc/yum.repos.d/ 目录下,建立名叫nginx.repo的软件源配置文件。
文件 nginx.repo 的内容是:
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1
第二步:使用命令 yum install nginx ,按照提示即可安装完毕;
第三步:使用命令 /etc/init.d/nginx start 启动nginx服务;
第四步:测试,在浏览器里输入服务器ip地址,即可出现 nginx 欢迎页面;

重启nginx命令:
service nginx restart;
nginx -s reload;
nginx安装路径:/etc/nginx
配置文件:/etc/nginx/nginx.conf
配置文件,首先修改/etc/nginx/nginx.conf文件:
[root@uxyc006060 nginx]# vi nginx.conf
user nginx;
worker_processes 2;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_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;
#upstream 后面的名字在后面还要用这里用的是backend
upstream backend
{
server 127.0.0.1:8080;
}
}
在修改/etc/nginx/conf.d文件
[root@uxyc006060 conf.d]# vi default.conf
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/log/host.access.log main;
# location / {
# root /usr/share/nginx/html;
# index index.html index.htm;
# }
location /{
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://backend;
}
#最后一行proxy_pass http://backend看着眼熟吧,backend就是前面upstream定义的名字
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
centOS-64位通过YUM源安装nginx的更多相关文章
- 阿里云 通过YUM源安装nginx
阿里云centOS-6.3-64位通过YUM源安装nginx 第一步:在 /etc/yum.repos.d/ 目录下,建立名叫nginx.repo的软件源配置文件. 文件 nginx.repo 的 ...
- 在CentOS 7上使用Yum源安装和卸载 MongoDB 3.4
在CentOS 7上使用Yum源安装和卸载 MongoDB 3.4 1.配置Yum源 vim /etc/yum.repos.d/mongodb-org-3.4.repo [mongodb-org-3. ...
- 【nginx】利用yum源安装nginx
先安装nginx的yum源 http://nginx.org/en/linux_packages.html#stable 找到链接,安装: rpm -ivh http://nginx.org/pack ...
- yum源安装nginx
nginx使用yum源安装 安装步骤 使用yum源安装依赖 yum install yum-utils 配置nginx.repo的yum文件 vim /etc/yum.repos.d/nginx.re ...
- CentOS 64位系统 yum安装32位软件包的方法
//假如你要安装libjpeg的32位版本 1.查询具体的32位版本,然后安装 yum search libjpeg.i686 yum -y install libjpeg.i386 2.一劳永逸的方 ...
- Linux - CentOS 7 通过Yum源安装 Nginx
添加源 sudo rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.no ...
- 用yum源安装Nginx
1.在/etc/yum.repos.d/目录下创建一个源配置文件nginx.repo: cd /etc/yum.repos.d/ vi nginx.repo 填写如下内容: [nginx] name= ...
- Centos7 通过yum源安装nginx
通过rpm 添加yum源 rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ng ...
- CentOS 7.4使用yum源安装MySQL5.7
从CentOS 7.0发布以来,yum源中开始使用Mariadb来代替MySQL的安装.即使你输入的是yum install -y mysql , 显示的也是Mariadb的安装内容.使用源代码进行编 ...
随机推荐
- react-native 详解
1.获取主屏幕尺寸 // 导入类库 var Dimensions = require('Dimensions'); // 样式 const styles = StyleSheet.create({ c ...
- Spring IOC源代码具体解释之容器初始化
Spring IOC源代码具体解释之容器初始化 上篇介绍了Spring IOC的大致体系类图,先来看一段简短的代码,使用IOC比較典型的代码 ClassPathResource res = new C ...
- STL学习笔记(移除性算法)
本节所列的算法是根据元素值或某一准则,在一个区间内移除某些元素. 这些算法并不能改变元素的数量,它们只是将原本置于后面的“不移除元素”向前移动,覆盖那些被移除的元素. 这些算法都返回逻辑上的新终点 移 ...
- Hadoop eclipse插件使用过程中出现的问题
http://download.csdn.net/detail/java2000_wl/4326323 转自http://www.ithao123.cn/content-945210.html 由于h ...
- 基于webmagic的种子网站爬取
代码地址如下:http://www.demodashi.com/demo/12175.html 1. 概述 因为无聊,闲来没事做,故突发奇想,爬个种子,顺便学习爬虫.本文将介绍使用Spring/Myb ...
- java调用本地默认浏览器
1 http://blog.csdn.net/casularm/article/details/3401018 2
- ESXi安装iso镜像添加驱动(esxi6.5,6.7)
准备工作:1.安装 Windows PowerShell 3.0 (需要启用Windows AutoUpdate服务,安装完毕计算机需要重启) https://www.microsoft.com/en ...
- Ubuntu Server 命令行下显示中文乱码(菱形)解决办法
如果Ubuntu Server在安装过程中,选择的是中文(很多新手都会在安装时选择中文,便于上手),这样在完成安装后,系统默认的语言将会是中文zh_CN.UTF- 8.但问题是我们安装的是服务器,只需 ...
- javascript 在js文件中获取路径
如果在*.js文件中获取当自己当前的路径是很重要的. 举个例子,如果一个css文件中引用图片,如background-img: url('./Images/bg.png').那么图片的路径,是相对于c ...
- SRIO常用缩写
HELLO:Header Encoded Logical Layer Optimized (HELLO) format FTYPE:format type TTYPE:transaction type ...