===================================================

ubuntu

1.到nginx官网下载源码包。最好下载稳定版本,nginx官网http://www.nginx.org/

2.安装nginx依赖包运行命令:

sudo apt-get install libssl-dev
sudo apt-get install libpcre3 libpcre3-dev

3.解压下载的nginx源码包。检查编译环境 ./configure --prefix=/usr/local/nginx

4.编译安装 make && make install

5.到nginx安装目录执行启动命令:/usr/local/nginx/sbin/nginx

关闭命令:/usr/local/sbin/nginx -s stop (停止)
重启命令:/usr/local/sbin/nginx -s reload (重启)

启动之后浏览器中http://localhost/查看是否成功。

6.nginx配置文件所在目录/usr/local/nginx/conf/nginx.conf

配置文件详解如下:

#运行用户 
#user  nobody;
#启动进程 
worker_processes  1;

#全局错误日志及PID文件 
#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;

#工作模式及连接数上限 
events {
    use epoll; 
       worker_connections  1024;
}

#设定http服务器,利用它的反向代理功能提供负载均衡支持 
http {
    #设定mime类型 
    include       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  logs/access.log  main;

sendfile        on;
        #tcp_nopush     on;

#keepalive_timeout  0;
        #客户端和nginx之间空闲链接超时时间
        keepalive_timeout  120;

#设定负载均衡的服务器列表
    upstream mysvr {
        #weigth参数表示权值,权值越高被分配到的几率越大
        #本机上的Squid开启3128端口
        server 127.0.0.1:8080 weight=1;
        #server 119.254.82.237:8080  weight=1;
    } 
    #是否开启gzip模块 
    #gzip  on;
    #gzip_min_length  1100;
    #gzip_buffers    4 8k;
    #gzip_types      text/plain; 
    #设定虚拟主机 
    server {
        listen       80;
        server_name  localhost;
        #charset koi8-r;
        #设定本虚拟主机的访问日志 
        #access_log  logs/host.access.log  main;
        #location / {
        #    root   html;
        #    index  index.html index.htm;
               # }
        #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   html;
        }

# proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

# deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}

#对 "/" 启用负载均衡
        location / {
            proxy_pass      http://mysvr;
            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;
            #客户端body中最大数据量
            client_max_body_size    10m;
            client_body_buffer_size 128k;
            # 链接到主机超时时间
            proxy_connect_timeout  90;
            # 向主机发送数据超时时间
            proxy_send_timeout      90;
            # 从主机读取数据超时时间
            proxy_read_timeout      90;
            proxy_buffer_size      4k;
            proxy_buffers          4 32k;
            proxy_busy_buffers_size 64k;
            proxy_temp_file_write_size 64k;
        } 
    }
    # another virtual host using mix of IP-, name-, and port-based configuration
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

#    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}
}

转载于:https://www.cnblogs.com/isohybrid/archive/2013/05/09/nginx.html

nginx cocos2dx and so on相关推荐

  1. nginx程序访问linux任意目录,通过nginx访问linux目录

    http { ...... autoindex on; autoindex_exact_size off; autoindex_localtime on; server { listen 80; .. ...

  2. nginx配置http、https访问,nginx指定ssl证书,阿里云腾讯云华为云设置nginx https安全访问

    nginx配置http.https访问 要设置https访问需要从对应的云厂商申请证书,并下载Nginx证书到服务器. 我这里从阿里云申请了免费的域名证书,然后将证书放置在服务器的/etc/ssl/. ...

  3. Web项目使用nginx实现代理端口访问,看这篇就够了

    在搭建服务器的时候,项目部署在tomcat上,要访问项目,则需要加上端口号,如何隐藏端口号来访问呢,这就用到了nginx. nginx可以在docker上安装,也可以在linux上安装,这里我建议使用 ...

  4. nginx介绍及常用功能

    什么是nginx nginx跟Apache一样,是一个web服务器(网站服务器),通过HTTP协议提供各种网络服务. Apache:重量级的,不支持高并发的服务器.在Apache上运行数以万计的并发访 ...

  5. Nginx搭建负载均衡集群

    (1).实验环境 youxi1 192.168.5.101 负载均衡器 youxi2 192.168.5.102 主机1 youxi3 192.168.5.103 主机2 (2).Nginx负载均衡策 ...

  6. 快速通过nginx配置域名访问

    配置nginx进行域名访问文件 在nginx安装目录下的conf目录下新建一个配置文件,比如你新加的域名为admin.hello.com,你希望通过这个域名访问admin项目,那么新建一个admin. ...

  7. Docker学习(七)-----Docker安装nginx

    基本安装 1. 拉取Nginx镜像 docker pull nginx:latest 2. 查看本地镜像列表(即可看到nginx) docker images 3. 运行容器 docker run - ...

  8. 使用阿里云服务器安装docker,并用nginx示例

    一.前言 之前对docker了解不多,自从使用了一次之后,就感觉这个产品对开发者实在是太友好了,可以迅速在Linux,window等平台部署服务.常见的有数据库,nginx,消息队列,redis等.利 ...

  9. Centos7.4安装Nginx

    Centos7.4安装Nginx 使用yum命令 一.安装准备 首先由于nginx的一些模块依赖一些lib库,所以在安装nginx之前,必须先安装这些lib库,这些依赖库主要有g++.gcc.open ...

最新文章

  1. php批量处理图片大小,word图片怎么批量调整大小
  2. Linux文字分段裁剪命令cut(转)
  3. python没有运行_Python没有执行__init__
  4. 会打乒乓球的机器人!
  5. nusoap php 7,nusoap-用php的NuSoap 访问webservice遇到的问题。
  6. js进阶 9-5 js如何确认form的提交和重置按钮
  7. Spring MVC常用注解,你会几个?
  8. 重用生成的JAXB类
  9. ajax遍历递归树数据,怎么用JS递归发送AJAX请求
  10. iOS 应用程序的生命周期浅析
  11. OpenShift 4 之Knative(1) - 创建Knative无服务器架构环境
  12. solr配置中文IK Analyzer分词器
  13. Atitit usrQBF2312 命名空间pkg 以及 api命名 spec规范
  14. Postgresql数据库介绍15——客户端认证
  15. Java中什么不是线程状态_并发基础(四) java中线程的状态
  16. Win10应用商店和UWP应用无法连接网络解决方法
  17. HTML的子代选择器
  18. 释放自我。回归本性。要成功。
  19. 【Django】Django 的员工信息系统
  20. 上门洗车系统搭建解决方案-上门服务系统

热门文章

  1. 【转】linux内核态和用户态的区别
  2. java 蓝桥杯算法训练 s01串(题解)
  3. linux vi 上下左右 ab,【Linux】Ubuntu vi 上下左右变ABCD及 apt-get install报错问题解决方法...
  4. java shiro实例_spring+shiro 整合实例代码详解
  5. Python之线程(一)
  6. ControllerChannelManager分析
  7. ensp中小型企业网配置_如何构建1000人规模的网络,详细配置?
  8. (06)FPGA工程师能力
  9. (20)System Verilog利用clocking块产生输出信号延迟激励
  10. 蓝桥杯小朋友排队java_1215. 小朋友排队