使用epel

  1. [root@nginx /]# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo

下载nginx 1.6.3

  1. [root@nginx /]# wget http://nginx.org/download/nginx-1.6.3.tar.gz

安装前准备

安装pcre (安装pcre库是为了Nginx支持HTTP Rewrite 模块)

  1. [root@nginx /]# yum -y install pcre pcre-devel

安装openssl

  1. [root@nginx /]# yum -y install openssl openssl-devel

gcc编译器

  1. [root@nginx /]# yum -y install gcc gcc-c++

解压

  1. [root@nginx /]# ll nginx-1.6..tar.gz
  2. -rw-r--r-- root root Apr nginx-1.6..tar.gz
  3. [root@nginx /]# tar zxvf nginx-1.6..tar.gz
  4. [root@nginx /]# cd nginx-1.6.
  5. [root@nginx nginx-1.6.]# pwd
  6. /nginx-1.6.

创建nginx用户

  1. [root@nginx nginx-1.6.]# useradd nginx -s /sbin/nologin -M

配置、编译、安装

  1. [root@nginx nginx-1.6.]# ./configure --user=nginx --group=nginx --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
  2. [root@nginx nginx-1.6.]# echo $?
  3.  
  4. [root@nginx nginx-1.6.]# make && make install
  5. [root@nginx nginx-1.6.]# echo $?
  6. 0
    [root@nginx nginx-1.6.3]# ln -s /usr/local/nginx/sbin/* /usr/local/sbin

启动nginx

  1. [root@nginx nginx-1.6.]# /usr/local/sbin/nginx -t
  2. nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
  3. nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
  4. [root@nginx nginx-1.6.]# /usr/local/sbin/nginx
  5. [root@nginx nginx-1.6.]# netstat -lntup | grep nginx
  6. tcp 0.0.0.0: 0.0.0.0:* LISTEN /nginx
  7. [root@nginx nginx-1.6.]# lsof -i :
  8. COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
  9. nginx root 6u IPv4 0t0 TCP *:http (LISTEN)
  10. nginx nginx 6u IPv4 0t0 TCP *:http (LISTEN)

浏览器访问:http://192.168.161.134

关闭防火墙或修改防火墙规则

  1. [root@nginx nginx-1.6.]# /etc/init.d/iptables stop
  2. iptables: Setting chains to policy ACCEPT: filter [ OK ]
  3. iptables: Flushing firewall rules: [ OK ]
  4. iptables: Unloading modules: [ OK ]
  1. root@nginx nginx-1.6.]# iptables -I INPUT -p tcp --dport -j ACCEPT
  2. [root@nginx nginx-1.6.]# /etc/init.d/iptables save
  3. iptables: Saving firewall rules to /etc/sysconfig/iptables: [ OK ]

或本机测试

  1. [root@nginx nginx-1.6.]# curl 192.168.161.134
  2. <!DOCTYPE html>
  3. <html>
  4. <head>
  5. <title>Welcome to nginx!</title>
  6. <style>
  7. body {
  8. width: 35em;
  9. margin: auto;
  10. font-family: Tahoma, Verdana, Arial, sans-serif;
  11. }
  12. </style>
  13. </head>
  14. <body>
  15. <h1>Welcome to nginx!</h1>
  16. <p>If you see this page, the nginx web server is successfully installed and
  17. working. Further configuration is required.</p>
  18.  
  19. <p>For online documentation and support please refer to
  20. <a href="http://nginx.org/">nginx.org</a>.<br/>
  21. Commercial support is available at
  22. <a href="http://nginx.com/">nginx.com</a>.</p>
  23.  
  24. <p><em>Thank you for using nginx.</em></p>
  25. </body>
  26. </html>

修改nginx.conf

  1. [root@nginx nginx-1.6.]# cd /usr/local/nginx/conf/
  2. [root@nginx conf]# pwd
  3. /usr/local/nginx/conf
  4. [root@nginx conf]# vim nginx.conf
  5. user nginx;
  6. worker_processes ;
  7.  
  8. log_format main '$remote_addr - $remote_user [$time_local] "$request" '
  9. '$status $body_bytes_sent "$http_referer" '
  10. '"$http_user_agent" "$http_x_forwarded_for"';
  11.  
  12. access_log logs/access.log main;
  13. sendfile on;
  14. tcp_nopush on;
  15. gzip on;
  16.  
  17. server {
  18. listen ;
  19. server_name www.httpd.com;
  20.  
  21. charset utf-;
  22.  
  23. access_log logs/host.access.log main;
  24.  
  25. location / {
  26. root html;
  27. index index.html index.htm;
  28. }
  29.  
  30. error_page /.html;
  31.  
  32. error_page /50x.html;
  33. location = /50x.html {
  34. root html;
  35. }

CentOS 6.5 安装nginx 1.6.3的更多相关文章

  1. 在CentOS 7中安装nginx服务器

    简要地介绍一下,如何在CentOS 7中安装nginx服务器  下载对应当前系统版本的nginx包(package) # wget  http://nginx.org/packages/centos/ ...

  2. Linux系统运维笔记(四),CentOS 6.4安装Nginx

    Linux系统运维笔记(四),CentOS 6.4安装Nginx 1,安装编译工具及库文件 yum -y install make zlib zlib-devel gcc-c++ libtool op ...

  3. 如何在 CentOS 7 上安装 Nginx

    本文首发:开发指南:如何在 CentOS 7 上安装 Nginx Nginx 读作 engine x, 是一个免费的.开源的.高性能的 HTTP 和反向代理服务,主要负责负载一些访问量比较大的站点. ...

  4. CentOS 7 源代码安装Nginx

    本篇简要介绍CentOS 7 源代码安装Nginx. Preface # yum install epel-release -y # yum group install "Developme ...

  5. Centos 7下安装nginx,使用yum install nginx,提示没有可用的软件包

    Centos 7下安装nginx,使用yum install nginx,提示没有可用的软件包. 18 (flaskApi) [root@67 flaskDemo]# yum -y install n ...

  6. centos 下yum 安装nginx

    centos 下yum 安装nginx 1. 直接yum install nginx不行,要先处理下源: rpm -ivh http://nginx.org/packages/centos/6/noa ...

  7. centos直接yum安装nginx

    Ubuntu下安装nginx,直接apt-get install nginx就行了,很方便. 但是今天装了CentOS6.2,直接yum install nginx不行,要先处理下源,下面是安装完整流 ...

  8. centos系统编译安装nginx+php环境另加独立mysql教程

    以前看过的安装nginx+php环境都带了mysql数据库了,这个是因为很多站长都是nginx+php+mysql都在同一台服务器了,那么今天我们是单独处理了,一个是nginx+php环境,然后mys ...

  9. 腾讯云CentOS 6.6安装 Nginx

    一.下载Nginx 从Nginx的官网(http://nginx.org/en/download.html)下载Nginx的最新版本,这里我下载的是nginx-1.9.12. 下载完成后,得到一个如下 ...

  10. CentOS 6.5 安装Nginx 1.7.4

    一.安装准备 首先由于nginx的一些模块依赖一些lib库,所以在安装nginx之前,必须先安装这些lib库,这些依赖库主要有g++.gcc.openssl-devel.pcre-devel和zlib ...

随机推荐

  1. linux 内核 RCU机制详解

    RCU(Read-Copy Update)是数据同步的一种方式,在当前的Linux内核中发挥着重要的作用.RCU主要针对的数据对象是链表,目的是提高遍历读取数据的效率,为了达到目的使用RCU机制读取数 ...

  2. NOIp 0904 出题报告

    T1 huajitree 纯模拟,把S拆成二进制查一下有多少个1,然后把这个数和N*M求一下gcd,除一下输出就好了.说求期望值可能对新高一不太友好…. //huajitree //2016.8.22 ...

  3. POJ1144Network(求割点个数)

    题目链接 题意:一共n割点,然后若干行,每行第一个输入一个点,然后若干个点表示与他相连,0单独一行表示一个样例的结束.然后求图中的割点个数 割点:去掉该点之后得到的图不在连通,那么该店就是割点 一般割 ...

  4. import_site

    http://kfd.me/ https://google.kfd.me/webhp?newwindow=1&safe=active http://googlebridge.com/searc ...

  5. 远程连接实验室的VPN

    Windows 7 (win8类似)的用户请按以下步骤进行操作:1.点击“开始”菜单,然后点击“控制面板”,然后点击“查看网络和任务”.2.点击“设置新连接或网络”.3.点击“连接到工作区”,然后点击 ...

  6. CentOS7+hadoop2.6.4+spark-1.6.1

    环境: CentOS7 hadoop2.6.4已安装两个节点:master.slave1 过程: 把下载的scala.spark压缩包拷贝到/usr/hadoop-2.6.4/thirdparty目录 ...

  7. Java——UDP

    import java.net.DatagramPacket; import java.net.DatagramSocket; import java.net.InetAddress; //===== ...

  8. time模块

    In [1]: import time In [2]: import datetime In [3]: date_time = datetime.datetime.now() In [4]: prin ...

  9. json 是个什么东西?

    JSONP原理 JSONP(JSON with Padding),就是异步请求跨域的服务器端时,不是直接返回数据,而是返回一个js方法,把数据作为参数传过来.如果只是跨域传递数据那么这种方式是比较好的 ...

  10. Array subscript is not an integer

    字典的字母写成大写了,也不能查成出来,没有报没有这个字典,反而报这个错……找了好久