zoukankan      html  css  js  c++  java
  • CentOS 6.5 安装nginx 1.6.3

    使用epel

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

    下载nginx 1.6.3

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

    安装前准备

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

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

    安装openssl

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

    gcc编译器

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

    解压

    复制代码
    [root@nginx /]# ll nginx-1.6.3.tar.gz 
    -rw-r--r-- 1 root root 805253 Apr  8  2015 nginx-1.6.3.tar.gz
    [root@nginx /]# tar zxvf nginx-1.6.3.tar.gz
    [root@nginx /]# cd nginx-1.6.3
    [root@nginx nginx-1.6.3]# pwd
    /nginx-1.6.3
    复制代码

    创建nginx用户 

    [root@nginx nginx-1.6.3]# useradd nginx -s /sbin/nologin -M

    配置、编译、安装

    复制代码
    [root@nginx nginx-1.6.3]# ./configure --user=nginx --group=nginx --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
    [root@nginx nginx-1.6.3]# echo $?
    0
    [root@nginx nginx-1.6.3]# make && make install
    [root@nginx nginx-1.6.3]# echo $?
    0
    [root@nginx nginx-1.6.3]# ln -s /usr/local/nginx/sbin/* /usr/local/sbin
    复制代码

    启动nginx

    复制代码
    [root@nginx nginx-1.6.3]# /usr/local/sbin/nginx -t
    nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
    nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
    [root@nginx nginx-1.6.3]# /usr/local/sbin/nginx
    [root@nginx nginx-1.6.3]# netstat -lntup | grep nginx
    tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      3556/nginx          
    [root@nginx nginx-1.6.3]# lsof -i :80
    COMMAND  PID  USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
    nginx   3556  root    6u  IPv4  17544      0t0  TCP *:http (LISTEN)
    nginx   3557 nginx    6u  IPv4  17544      0t0  TCP *:http (LISTEN)
    复制代码

    浏览器访问:http://192.168.161.134

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

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

    或本机测试

    复制代码
    [root@nginx nginx-1.6.3]# curl 192.168.161.134
    <!DOCTYPE html>
    <html>
    <head>
    <title>Welcome to nginx!</title>
    <style>
        body {
             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 and
    working. Further configuration is required.</p>
    
    <p>For online documentation and support please refer to
    <a href="http://nginx.org/">nginx.org</a>.<br/>
    Commercial support is available at
    <a href="http://nginx.com/">nginx.com</a>.</p>
    
    <p><em>Thank you for using nginx.</em></p>
    </body>
    </html>
    复制代码

     关闭 开启 nginx

     /usr/local/sbin/nginx -s stop   //关闭服务器
     /usr/local/sbin/nginx  开启服务器
    

      

    修改nginx.conf

    复制代码
    [root@nginx nginx-1.6.3]# cd /usr/local/nginx/conf/
    [root@nginx conf]# pwd
    /usr/local/nginx/conf
    [root@nginx conf]# vim nginx.conf
    user  nginx;
    worker_processes  1; 
    
    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  logs/access.log  main;
    sendfile        on;
        tcp_nopush     on;
    gzip  on;
    
     server {
            listen       80;
            server_name  www.httpd.com;
    
            charset utf-8;
    
            access_log  logs/host.access.log  main;
    
            location / {
                root   html;
                index  index.html index.htm;
            }
    
            error_page  404              /404.html;
    
     error_page   500 502 503 504  /50x.html;
            location = /50x.html {
                root   html;
            }
    复制代码
  • 相关阅读:
    浅谈HTML5单页面架构(一)——requirejs + angular + angular-route
    嵌入式开发之web---vue 前端 注册登录login
    嵌入式开发之web---vue 前端 admin 后台管理系统
    嵌入式开发之web---vue-demo webstorm goahead 嵌入式智能设备
    嵌入式开发之web---vue vscode和vue webstorm 开发环境搭建
    多媒体开发之h264---h264格式说明
    嵌入式开发之内核内存异常排查---关闭oom killer
    Elasticsearch cat api的用法
    Django Mysql SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED
    Django-基础-2-ORM
  • 原文地址:https://www.cnblogs.com/pangguoming/p/7387970.html
Copyright © 2011-2022 走看看