python html5 bootstrap 视频教程
德云社区 门户 IT 编程 Linux & Unix Ubuntu & Debian 查看内容

在 Ubuntu Server 14.04 下安装 Nginx 1.4.6

2014-12-29 12:05| 发布者: digitser| 查看: 4566| 评论: 0|原作者: liangsheng

摘要: 在 Ubuntu Server 14.04 下安装 Nginx 1.4.6 Nginx (engine x) 是高性能 HTTP、反向代理服务器,也是 IMAP/POP3/SMTP 代理服务器。 Nginx 是由 Igor Sysoev 为俄罗斯访问量第二的 Rambler.ru 站点开发的,第一公 ...
自动立式分页纸箱赋码系统 ── 全自动 专业 立式分页 瓦楞纸 水性油墨 贴标 喷码 检测系统

       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. apt-get install 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 配置文件
  1. vi /etc/nginx/sites-available/default
复制代码
     修改前的配置文件内容:
  1. # You may add here your
  2. # server {
  3. #        ...
  4. # }
  5. # statements for each of your virtual hosts to this file

  6. ##
  7. # You should look at the following URL's in order to grasp a solid understanding
  8. # of Nginx configuration files in order to fully unleash the power of Nginx.
  9. # http://wiki.nginx.org/Pitfalls
  10. # http://wiki.nginx.org/QuickStart
  11. # http://wiki.nginx.org/Configuration
  12. #
  13. # Generally, you will want to move this file somewhere, and start with a clean
  14. # file but keep this around for reference. Or just disable in sites-enabled.
  15. #
  16. # Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
  17. ##

  18. server {    #设定虚拟主机,默认为监听 80 端口,改成其他端口会出现问题   
  19.         listen 80 default_server;
  20.         listen [::]:80 default_server ipv6only=on;

  21.         root /usr/share/nginx/html;      #定义服务器默认网站根目录位置
  22.         index index.html index.htm;     #定义首页索引文件名称

  23.         # Make site accessible from http://localhost/
  24.         server_name localhost;      #域名可以有多个,使用空格分隔

  25.         location / {     #默认请求
  26.                 # First attempt to serve request as file, then
  27.                 # as directory, then fall back to displaying a 404.
  28.                 try_files $uri $uri/ =404;
  29.                 # Uncomment to enable naxsi on this location
  30.                 # include /etc/nginx/naxsi.rules
  31.         }

  32.         # Only for nginx-naxsi used with nginx-naxsi-ui : process denied requests
  33.         #location /RequestDenied {
  34.         #        proxy_pass http://127.0.0.1:8080;   
  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 /usr/share/nginx/html;
  42.         #}

  43.         # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000  
  44.         #
  45.         #location ~ \.php$ {     #PHP 脚本请求全部转发到 FastCGI 处理. 使用 FastCGI 默认配置
  46.         #        fastcgi_split_path_info ^(.+\.php)(/.+)$;
  47.         #        # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
  48.         #
  49.         #        # With php5-cgi alone:
  50.         #        fastcgi_pass 127.0.0.1:9000;
  51.         #        # With php5-fpm:
  52.         #        fastcgi_pass unix:/var/run/php5-fpm.sock;
  53.         #        fastcgi_index index.php;
  54.         #        include fastcgi_params;
  55.         #}

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


  63. # another virtual host using mix of IP-, name-, and port-based configuration
  64. #
  65. #server {
  66. #        listen 8000;
  67. #        listen somename:8080;
  68. #        server_name somename alias another.alias;
  69. #        root html;
  70. #        index index.html index.htm;
  71. #
  72. #        location / {
  73. #                try_files $uri $uri/ =404;
  74. #        }
  75. #}


  76. # HTTPS server
  77. #
  78. #server {
  79. #        listen 443;
  80. #        server_name localhost;
  81. #
  82. #        root html;
  83. #        index index.html index.htm;
  84. #
  85. #        ssl on;
  86. #        ssl_certificate cert.pem;
  87. #        ssl_certificate_key cert.key;
  88. #
  89. #        ssl_session_timeout 5m;
  90. #
  91. #        ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
  92. #        ssl_ciphers "HIGH:!aNULL:!MD5 or HIGH:!aNULL:!MD5:!3DES";
  93. #        ssl_prefer_server_ciphers on;
  94. #
  95. #        location / {
  96. #                try_files $uri $uri/ =404;
  97. #        }
  98. #}

复制代码
      修改后的配置文件内容:
  1. # You may add here your
  2. # server {
  3. #    ...
  4. # }
  5. # statements for each of your virtual hosts to this file

  6. ##
  7. # You should look at the following URL's in order to grasp a solid understanding
  8. # of Nginx configuration files in order to fully unleash the power of Nginx.
  9. # http://wiki.nginx.org/Pitfalls
  10. # http://wiki.nginx.org/QuickStart
  11. # http://wiki.nginx.org/Configuration
  12. #
  13. # Generally, you will want to move this file somewhere, and start with a clean
  14. # file but keep this around for reference. Or just disable in sites-enabled.
  15. #
  16. # Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
  17. ##

  18. server {    #设定虚拟主机,默认为监听 80 端口,改成其他端口会出现问题
  19.     listen 80 default_server;
  20.     listen [::]:80 default_server ipv6only=on;

  21.     root /usr/share/nginx/html;      #定义服务器默认网站根目录位置
  22.     index index.html index.htm;     #定义首页索引文件名称

  23.     # Make site accessible from http://localhost/
  24.     server_name localhost;    #域名可以有多个,使用空格分隔

  25.     location /  {    #默认请求
  26.         # First attempt to serve request as file, then
  27.         # as directory, then fall back to displaying a 404.
  28.         try_files $uri $uri/ =404;
  29.         # Uncomment to enable naxsi on this location
  30.         # include /etc/nginx/naxsi.rules
  31.     }

  32.     #图片缓存时间设置
  33.     location ~.*/\.(jpg|jpeg|png|gif|swf)$
  34.     {
  35.         expires 30d;
  36.     }

  37.     location ~.*/\.(js|css)?$;    #JS 和 CSS 缓存时间设置
  38.     {
  39.         expires 1h;
  40.     }

  41.     # Only for nginx-naxsi used with nginx-naxsi-ui : process denied requests
  42.     #location /RequestDenied {
  43.     #    proxy_pass http://127.0.0.1:8080;   
  44.     #}

  45.     #error_page 404 /404.html;

  46.     # redirect server error pages to the static page /50x.html
  47.     #
  48.     #error_page 500 502 503 504 /50x.html;
  49.     #location = /50x.html {     # 定义错误提示页面
  50.     #    root /usr/share/nginx/html;
  51.     #}

  52.     # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
  53.     #      
  54.     #location ~ \.php$ {      #PHP 脚本请求全部转发到 FastCGI 处理. 使用 FastCGI 默认配置
  55.     #    fastcgi_split_path_info ^(.+\.php)(/.+)$;
  56.     #    # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
  57.     #
  58.     #    # With php5-cgi alone:
  59.     #    fastcgi_pass 127.0.0.1:9000;
  60.     #    # With php5-fpm:
  61.     #    fastcgi_pass unix:/var/run/php5-fpm.sock;
  62.     #    fastcgi_index index.php;
  63.     #    include fastcgi_params;
  64.     #}

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


  72. # another virtual host using mix of IP-, name-, and port-based configuration
  73. #
  74. #server {
  75. #    listen 8000;
  76. #    listen somename:8080;
  77. #    server_name somename alias another.alias;
  78. #    root html;
  79. #    index index.html index.htm;
  80. #
  81. #    location / {
  82. #        try_files $uri $uri/ =404;
  83. #    }
  84. #}


  85. # HTTPS server
  86. #
  87. #server {
  88. #    listen 443;
  89. #    server_name localhost;
  90. #
  91. #    root html;
  92. #    index index.html index.htm;
  93. #
  94. #    ssl on;
  95. #    ssl_certificate cert.pem;
  96. #    ssl_certificate_key cert.key;
  97. #
  98. #    ssl_session_timeout 5m;
  99. #
  100. #    ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
  101. #    ssl_ciphers "HIGH:!aNULL:!MD5 or HIGH:!aNULL:!MD5:!3DES";
  102. #    ssl_prefer_server_ciphers on;
  103. #
  104. #    location / {
  105. #        try_files $uri $uri/ =404;
  106. #    }
  107. #}

复制代码
4、重载测试 Nginx 配置文件
  1. root:# /usr/sbin/nginx -s reload (或 service nginx reload)
  2. root:# /usr/sbin/nginx -t
  3. nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
  4. nginx: configuration file /etc/nginx/nginx.conf test is successful
  5. root:#
复制代码
5、重启 Nginx
  1. root:# /etc/init.d/nginx restart
  2. * Restarting nginx nginx                                                                                                [ OK ]
  3. root:#
复制代码
6、发布您的网站:
      将您网站带有 index.html 文件的目录下的所有文件、目录上传到 /var/www 目录下

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

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


路过

雷人

握手

鲜花

鸡蛋
AI人工智能 语音助理 人工翻译 教程

相关阅读

最新评论

CSS3 官方中文文档编制 手册教程 人工翻译 更新日志
CSS3 官方中文文档编制 手册教程 人工翻译 更新日志 CSS3 中文文档编制采用机器辅助 + 全人工翻译,完全采用 数字翻译 的文档翻译流程进行汉化 (未采用任何第 3 方工具),[884/2022-07-31]
CSS3 官方中文文档编制 手册教程 帮助文件 人工翻译
CSS3 官方中文文档编制 手册教程 帮助文件 人工翻译 CSS3 中文文档编制采用机器辅助 + 全人工翻译,完全采用 数字翻译 的文档翻译流程进行汉化 (未采用任何第 3 方工具),[1004/2022-07-31]
SolidWorks 2020 非对称Conic Rho圆角 抽壳出现模型穿刺
SolidWorks 2020 非对称Conic Rho圆角 抽壳出现模型穿刺 标准对称圆角最常用,但有时偶尔也会用到非对称圆角。 特别是模具、五金、电子、手饰、汽车、家具、玩具、等对圆[881/2022-05-25]
NumPy 1.22 官方中文文档编制 手册帮助 更新日志
NumPy 1.22 官方中文文档编制 手册帮助 更新日志 以后不再上传 en-US 官方原版文档编制,目前上传的最新 zh-CN 人工翻译版本为 NumPy 1.22。 NumPy 1.22 中文文档编制采用[573/2022-05-22]
NumPy 1.22 官方中文文档编制 手册帮助 全人工翻译
NumPy 1.22 官方中文文档编制 手册帮助 全人工翻译 以后不再上传 en-US 官方原版文档编制,目前上传的最新 zh-CN 人工翻译版本为 NumPy 1.22。 NumPy 1.22 中文文档编制采[647/2022-05-22]
Pillow 9.1.1 官方中文文档编制 手册帮助 更新日志
Pillow 9.1.1 官方中文文档编制 手册帮助 更新日志 以后不再上传 en-US 官方原版文档编制,目前上传的最新 zh-CN 人工翻译版本为 Pillow 9.1.1。 Pillow 9.1.1 中文文档编[616/2022-05-22]
Pillow 9.1.1 官方中文文档编制 手册帮助 全人工翻译
Pillow 9.1.1 官方中文文档编制 手册帮助 全人工翻译 以后不再上传 en-US 官方原版文档编制,目前上传的最新 zh-CN 人工翻译版本为 Pillow 9.1.1。 Pillow 9.1.1 中文文档[568/2022-05-22]
PyMuPDF 1.19.6 官方中文文档编制 手册帮助 更新日志
PyMuPDF 1.19.6 官方中文文档编制 手册帮助 更新日志 以后不再上传 en-US 官方原版文档编制,目前上传的最新 zh-CN 人工翻译版本为 PyMuPDF 1.19.6。 PyMuPDF 1.19.6 中文[1148/2022-05-22]
PyMuPDF 1.19.6 官方中文文档编制 手册帮助 全人工翻译
PyMuPDF 1.19.6 官方中文文档编制 手册帮助 全人工翻译 以后不再上传 en-US 官方原版文档编制,目前上传的最新 zh-CN 人工翻译版本为 PyMuPDF 1.19.6。 PyMuPDF 1.19.6 中[983/2022-05-22]
Qt 6.3.0 官方中文文档编制 手册教程 帮助文件 人工翻译
Qt 6.3.0 官方中文文档编制 手册教程 帮助文件 人工翻译 以后不再上传 en-US 官方原版文档编制,目前上传的最新 zh-CN 人工翻译版本为 Qt 6.3.0。 Qt 6.3.0 中文文档编制[2435/2022-05-02]
Qt 6.3.0 官方中文文档编制 手册教程 人工翻译更新日志
Qt 6.3.0 官方中文文档编制 手册教程 人工翻译更新日志 以后不再上传 en-US 官方原版文档编制,目前上传的最新 zh-CN 人工翻译版本为 Qt 6.3.0。 Qt 6.3.0 中文文档编制采[2016/2022-05-02]
MAGIX Music Maker Premium - 易学易用 功能强大的可视化编曲软件
MAGIX Music Maker Premium - 易学易用 功能强大的可视化编曲软件 MAGIX Music Maker 是德国 Magix 出品的可视化编曲软件,功能强大、使用简单、容易上手。 MAGIX Music Ma[1728/2022-04-11]
MQTT - 消息队列遥测技术 M2M机器到机器 IoT物联网 通信协议
MQTT - 消息队列遥测技术 M2M机器到机器 IoT物联网 通信协议 MQTT 是 Message Queuing Telemetry Transport 的缩写,中文译为消息队列遥测传输。 MQTT 是 ISO 标准 (ISO/I[606/2022-02-24]
数字 Python IDE 2022 注册机 注册码生成器 附详细破解方法
数字 Python IDE 2022 注册机 注册码生成器 附详细破解方法 数字 Python IDE 目前还在不断研发 进步中,虽不太成熟,但其新理念很有特色 特别适于多版本 多文档 多工程并行[669/2022-02-01]
数字翻译 2022 注册机 注册码生成器 内存破解器 附详细用法
数字翻译 2022 注册机 注册码生成器 内存破解器 附详细用法 数字翻译目前还在不断研发 进步中,虽不太成熟,但其新理念很有特色 特别适于 HTML 文档本地化 (面向高精度 超[623/2022-02-01]

Archiver|Sitemap|小黑屋|德云社区   

GMT+8, 2024-4-20 00:41 , Processed in 0.044421 second(s), 27 queries .

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

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

返回顶部