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的安装内容.使用源代码进行编 ...
随机推荐
- JavaScript target与currentTarget区别
1.DOM事件绑定到父元素 <!DOCTYPE html> <html lang="zh"> <head> <meta charset=& ...
- Pycharm中的scrapy安装教程
在利用pycharm安装scrapy包是遇到了挺多的问题.在折腾了差不多折腾了两个小时之后总算是安装好了.期间各种谷歌和百度,发现所有的教程都是利用命令行窗口安装的.发现安装scrapy需要的包真是多 ...
- Android事件的分发
1 http://blog.csdn.net/guolin_blog/article/details/9097463 2
- .Net 异步调用
.NET异步编程之新利器——Task与Await.Async 一. FrameWork 4.0之前的线程世界 在.NET FrameWork 4.0之前,如果我们使用线程.一般有以下几种方 ...
- Maven环境下搭建SSH框架之Spring整合Hibernate
© 版权声明:本文为博主原创文章,转载请注明出处 1.搭建环境 Spring:4.3.8.RELEASE Hibernate:5.1.7.Final MySQL:5.7.17 注意:其他版本在某些特性 ...
- C语言学习笔记(七)——其它运算符
第七章 其它运算符 逗号运算符 逗号运算符:即顺序点,逗号前先运行.后再运行. for循环的运行次数: for(i=n; i<m; + ...
- 自定义type='file'上传文件样式
改变默认的上传文件样式: 用label作为替代 <input id="file_-1" type="file" name="file" ...
- 利用NIO的Selector处理服务器-客户端模型
package NIOTEST; import java.io.IOException; import java.net.InetAddress; import java.net.InetSocket ...
- java中双向链表的增、删、查操作
import java.util.NoSuchElementException; public class DoublyLinkedListImpl<E> { private Node h ...
- 当客户端提交更新数据请求时,是先写入edits,然后再写入内存的
http://blog.sina.com.cn/s/blog_6f83c7470101b7d3.html http://blog.csdn.net/slq1023/article/details/49 ...