python html5 bootstrap 视频教程

德云社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 4174|回复: 2

在本地局域网 Windows 7 下安装 Nginx 1.7.8

[复制链接]

172

主题

258

帖子

1114

积分

版主

Rank: 7Rank: 7Rank: 7

金钱
663
金币
7
威望
0
贡献
0
发表于 2014-12-26 00:29:10 | 显示全部楼层 |阅读模式
AI人工智能 语音助理 人工翻译 教程

       Nginx ("engine x") 是高性能 HTTP反向代理服务器,也是 IMAP/POP3/SMTP 代理服务器。 Nginx 是由 Igor Sysoev 为俄罗斯访问量第二的 Rambler.ru 站点开发的,第一公开版本 0.1.0 发布于 2004 年 10 月 4 日。源代码以BSD-like 许可证的形式发布,因其稳定性、丰富功能集、示例配置文件、低系统资源消耗而闻名。2011 年 6 月 1 日,nginx 1.0.4 发布。

      其特点是:占有内存少、并发能力强。事实上,nginx 的并发能力确实在同类型网页服务器中表现较好,中国大陆使用 nginx 网站用户有:新浪网易腾讯等。

1、安装 Nginx 1.7.8
      下载软件,下载链接http://pan.baidu.com/s/1pJFjTcJ 密码:9hvp

      将解压出来的 nginx 拷贝到 x:\Program Files 目录下

      双击x:\Program Files\nginx\nginx.exe 启动 Nginx

2、在 FireFox 或 IE 浏览器中键入 http://localhost/http://127.0.0.1/  (或服务器 IP 地址);若出现 “Welcome to nginx!” 信息,说明安装成功:
Welcome to nginx!

If you see this page, the nginx web server is successfully installed andworking. Further configuration is required.

For online documentation and support please refer to nginx.org.
Commercial support is available at nginx.com.

Thank you for using nginx.
3、结束 Nginx 进程,编辑 Nginx 配置文件:
      用记事本打开 x:\Program Files\nginx\conf\nginx.conf 文件,修改相应选项。

      修改前的配置文件内容:
  1. #user  nobody;      #运行用户
  2. worker_processes  1;     #启动进程,通常设置成与 cpu 数量相等

  3. #全局错误日志
  4. #error_log  logs/error.log;                                   
  5. #error_log  logs/error.log  notice;
  6. #error_log  logs/error.log  info;

  7. #pid        logs/nginx.pid;     #PID 文件

  8. #工作模式及连接数上限
  9. events {
  10.     worker_connections  1024;     #连接数上限
  11. }


  12. http {       #设定 http 服务器,利用它的反向代理功能提供负载均衡支持
  13.     include       mime.types;        #设定 mime 类型,类型由 mime.type 文件定义
  14.     default_type  application/octet-stream;     #默认文件类型

  15.     #设定日志格式
  16.     #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '   
  17.     #                  '$status $body_bytes_sent "$http_referer" '
  18.     #                  '"$http_user_agent" "$http_x_forwarded_for"';

  19.     #access_log  logs/access.log  main;

  20.     sendfile        on;      #开启高效文件传输模式,sendfile 指令指定 nginx 是否调用 sendfile 函数来输出文件,对于普通应用设为 on,如果用来进行下载等应用磁盘 IO 重负载应用,可设置为 off,以平衡磁盘与网络 I/O 处理速度,降低系统的负载。注意:如果图片显示不正常把这个改成 off。
  21.     #tcp_nopush     on;      #防止网络阻塞

  22.     #keepalive_timeout  0;            
  23.     keepalive_timeout  65;  #长连接超时时间,单位为秒

  24.     #gzip  on;    #开启 gzip 压缩

  25.     server {       #设定虚拟主机,默认为监听 80 端口,改成其他端口会出现问题   
  26.         listen       80;
  27.         server_name  localhost;

  28.         #charset koi8-r;

  29.         #access_log  logs/host.access.log  main;

  30.         location / {        #默认请求
  31.             root   html;     #定义服务器的默认网站根目录位置;由于 Nginx 在 windows 下不太稳定,建议不作修改
  32.             index  index.html index.htm;    #定义首页索引文件名称
  33.         }

  34.         #error_page  404              /404.html;            

  35.         # redirect server error pages to the static page /50x.html
  36.         #
  37.         error_page   500 502 503 504  /50x.html;     #定义错误提示页面
  38.         location = /50x.html {
  39.             root   html;
  40.         }

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

  46.         # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000   
  47.         #
  48.         #location ~ \.php$ {      #PHP 脚本请求全部转发到 FastCGI 处理. 使用 FastCGI 默认配置
  49.         #    root           html;
  50.         #    fastcgi_pass   127.0.0.1:9000;
  51.         #    fastcgi_index  index.php;
  52.         #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
  53.         #    include        fastcgi_params;
  54.         #}

  55.         # deny access to .htaccess files, if Apache's document root
  56.         # concurs with nginx's one
  57.         #
  58.         #location ~ /\.ht {     #禁止访问 .htaccess 文件
  59.         #    deny  all;
  60.         #}
  61.     }


  62.     # another virtual host using mix of IP-, name-, and port-based configuration
  63.     #
  64.     #server {
  65.     #    listen       8000;
  66.     #    listen       somename:8080;
  67.     #    server_name  somename  alias  another.alias;

  68.     #    location / {
  69.     #        root   html;
  70.     #        index  index.html index.htm;
  71.     #    }
  72.     #}


  73.     # HTTPS server
  74.     #
  75.     #server {
  76.     #    listen       443 ssl;
  77.     #    server_name  localhost;

  78.     #    ssl_certificate      cert.pem;
  79.     #    ssl_certificate_key  cert.key;

  80.     #    ssl_session_cache    shared:SSL:1m;
  81.     #    ssl_session_timeout  5m;

  82.     #    ssl_ciphers  HIGH:!aNULL:!MD5;
  83.     #    ssl_prefer_server_ciphers  on;

  84.     #    location / {
  85.     #        root   html;
  86.     #        index  index.html index.htm;
  87.     #    }
  88.     #}

  89. }
复制代码
     修改后的配置文件内容:

  1. #user  nobody;     #运行用户
  2. worker_processes  1;    #启动进程,通常设置成与 cpu 数量相等

  3. #全局错误日志
  4. error_log  logs/error.log;
  5. error_log  logs/error.log  notice;
  6. error_log  logs/error.log  info;

  7. pid        logs/nginx.pid;    #PID 文件

  8. #工作模式及连接数上限
  9. events {
  10.     worker_connections  1024;     #连接数上限
  11. }


  12. http {      #设定 http 服务器,利用它的反向代理功能提供负载均衡支持
  13.     include       mime.types;     #设定 mime 类型,类型由 mime.type 文件定义
  14.     default_type  application/octet-stream;     #默认文件类型

  15.     #设定日志格式
  16.     #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
  17.                       '$status $body_bytes_sent "$http_referer" '
  18.                       '"$http_user_agent" "$http_x_forwarded_for"';

  19.     #access_log  logs/access.log  main;

  20.     sendfile        on;     #开启高效文件传输模式,sendfile 指令指定 nginx 是否调用 sendfile 函数来输出文件,对于普通应用设为
  21. on,如果用来进行下载等应用磁盘 IO 重负载应用,可设置为 off,以平衡磁盘与网络 I/O
  22. 处理速度,降低系统的负载。注意:如果图片显示不正常把这个改成 off。
  23.     tcp_nopush     on;     #防止网络阻塞

  24.     #keepalive_timeout  0;
  25.     keepalive_timeout  65;    #长连接超时时间,单位为秒

  26.     gzip  on;      #开启 gzip 压缩

  27.     server {      #设定虚拟主机,默认为监听 80 端口,改成其他端口会出现问题
  28.         listen       80;
  29.         server_name  localhost;

  30.         #charset koi8-r;

  31.         #access_log  logs/host.access.log  main;

  32.         location / {      #默认请求
  33.             root   html;      #定义服务器的默认网站根目录位置;由于 Nginx 在 windows 下不太稳定,建议不作修改
  34.             index  index.html index.htm;    #定义首页索引文件名称
  35.         }

  36.         #error_page  404              /404.html;

  37.         # redirect server error pages to the static page /50x.html
  38.         #
  39.         error_page   500 502 503 504  /50x.html;    #定义错误提示页面
  40.         location = /50x.html {
  41.             root   html;
  42.         }

  43.         #图片缓存时间设置
  44.         location ~.*/\.(jpg|jpeg|png|gif|swf)$
  45.         {
  46.             expires 30d;
  47.         }

  48.        #JS 和 CSS 缓存时间设置
  49.         location ~.*/\.(js|css)?$
  50.         {
  51.             expires 1h;
  52.         }

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

  58.         # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
  59.         #
  60.         #location ~ \.php$ {    #PHP 脚本请求全部转发到 FastCGI 处理. 使用 FastCGI 默认配置
  61.         #    root           html;
  62.         #    fastcgi_pass   127.0.0.1:9000;
  63.         #    fastcgi_index  index.php;
  64.         #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
  65.         #    include        fastcgi_params;
  66.         #}

  67.         # deny access to .htaccess files, if Apache's document root
  68.         # concurs with nginx's one
  69.         #
  70.         #location ~ /\.ht {    #禁止访问 .htaccess 文件
  71.         #    deny  all;
  72.         #}
  73.     }


  74.     # another virtual host using mix of IP-, name-, and port-based configuration
  75.     #
  76.     #server {
  77.     #    listen       8000;
  78.     #    listen       somename:8080;
  79.     #    server_name  somename  alias  another.alias;

  80.     #    location / {
  81.     #        root   html;
  82.     #        index  index.html index.htm;
  83.     #    }
  84.     #}


  85.     # HTTPS server
  86.     #
  87.     #server {
  88.     #    listen       443 ssl;
  89.     #    server_name  localhost;

  90.     #    ssl_certificate      cert.pem;
  91.     #    ssl_certificate_key  cert.key;

  92.     #    ssl_session_cache    shared:SSL:1m;
  93.     #    ssl_session_timeout  5m;

  94.     #    ssl_ciphers  HIGH:!aNULL:!MD5;
  95.     #    ssl_prefer_server_ciphers  on;

  96.     #    location / {
  97.     #        root   html;
  98.     #        index  index.html index.htm;
  99.     #    }
  100.     #}

  101. }
复制代码
4、发布您的网站:
      将您网站带有 index.html 文件的目录下的所有文件、目录拷贝到 nginx\html 目录下

5、浏览网站:
       双击 x:\Program Files\nginx\nginx.exe 启动 Nginx

       在 FireFox 或 IE 浏览器中键入 http://localhost/http://127.0.0.1/  (或服务器 IP 地址),浏览您的网站;

版权声明:
本文为独家原创稿件,版权归 德云社区,未经许可不得转载;否则,将追究其法律责任。


AI人工智能 语音助理 人工翻译 教程
回复

使用道具 举报

172

主题

258

帖子

1114

积分

版主

Rank: 7Rank: 7Rank: 7

金钱
663
金币
7
威望
0
贡献
0
 楼主| 发表于 2014-12-26 00:30:13 | 显示全部楼层
在线订购 便捷实惠 品质保证 终生保修
回复 支持 反对

使用道具 举报

172

主题

258

帖子

1114

积分

版主

Rank: 7Rank: 7Rank: 7

金钱
663
金币
7
威望
0
贡献
0
 楼主| 发表于 2014-12-26 00:30:21 | 显示全部楼层
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|Sitemap|小黑屋|德云社区 |网站地图  

GMT+8, 2024-4-24 23:32 , Processed in 0.406802 second(s), 27 queries .

工业和信息化部: 粤ICP备14079481号-2

技术支持 乐数软件     版权所有 © 2014-2021 德云社区    

快速回复 返回顶部 返回列表