什么是Nginx

一款服务器软件,类似于Apache、Tomcat

Nginx还是一款HTTP和反向代理服务器,同时也是一个代理邮件服务器。除了实现网站发布的功能外,还可以提供负载均衡。

所谓负载均衡,就是当大量用户访问服务器的时候,为了减少服务器的压力,我们需要将用户分别引入各个服务器,分担服务器的压力

/缺点

优点:高并发、部署简单、内存消耗小、成本低

缺点:rewrite功能不够强大,模块没有Apache多

Nginx环境搭建

Mac系统中搭建Nginx(Linux与此类似)

1、下载Nginx  http://nginx.org/en/download.html

2、解压下载的压缩包

3、cd 进入解压后的文件夹

4、去 http://www.pcre.org  下载  PCRE.

5、安装PCE

$ tar xvzf pcre-8.5

$ cd pcre-8.5

$ sudo ./configure --prefix=/usr/local

$ sudo make

$ sudo make install

6、./configure,所有配置使用默认值

输出如下

nginx path prefix: "/usr/local/nginx"

nginx binary file: "/usr/local/nginx/sbin/nginx"

nginx modules path: "/usr/local/nginx/modules"

nginx configuration prefix: "/usr/local/nginx/conf"

nginx configuration file: "/usr/local/nginx/conf/nginx.conf"

nginx pid file: "/usr/local/nginx/logs/nginx.pid"

nginx error log file: "/usr/local/nginx/logs/error.log"

nginx http access log file: "/usr/local/nginx/logs/access.log"

nginx http client request body temporary files: "client_body_temp"

nginx http proxy temporary files: "proxy_temp"

nginx http fastcgi temporary files: "fastcgi_temp"

nginx http uwsgi temporary files: "uwsgi_temp"

nginx http scgi temporary files: "scgi_temp"

7、安装

sudo make

sudo make install

8、将/usr/local/nginx/sbin加入到环境变量里

vi ~/.bash_profile

NG_HOME=/usr/local/nginx

PATH=$PATH:$NG_HOME/sbin

export NG_HOME

export PATH

添加如上

source ~/.bash_profile  使配置文件生效

9、验证

sudo nginx  运行

在浏览器输入:http://localhost

sudo nginx -s stop  停止

文件说明

在 NG_HOME下,

conf文件夹:配置文件;

sbin文件夹:存放了一个nginx命令;

html文件夹:网页程序;

log文件夹:日志文件

最新文章

  1. win7 下安装RVCT
  2. iTerm 2 && Oh My Zsh
  3. JS--事件模块
  4. 查找字符串(C++实现)
  5. windows server 2008 asp连接数据库sql2000失败
  6. 在Linux下sqlplus 登录时显示SID 和用户名
  7. H-JATG:NAND_FLASH的参数设置
  8. GUI(JMenuBar+JMenu+JMenuItem)
  9. python进阶之 进程编程
  10. gitlab小结
  11. shell 多行注释 块注释
  12. WKWebView 使用及注意事项
  13. mybatis中如果存在参数不再实体中的是如何处理
  14. spring boot实战(第一篇)第一个案例
  15. 本地计算机上的OracleOraDb11g_home2TNSListener服务启动又停止了。一些服务自动停止,如果他们没有什么可做的 .
  16. BZOJ1026:[SCOI2009]windy数——题解
  17. thinkphp模板中for循环与switch的使用
  18. Hive知识
  19. VSX-1 概述
  20. ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock'

热门文章

  1. 【转】iOS学习笔记(八)——iOS网络通信http之NSURLConnection
  2. winform下读取excel文件并绑定datagridview例子
  3. 如何查看连接到手机热点的ip地址
  4. 项目实战8.2-Linux下Tomcat开启查看GC信息
  5. hashlib模块常用功能
  6. 绘制字符串:imagestring()
  7. python3 练习题100例 (十五)
  8. 自动发现项目中的URL,django1版本和django2版本
  9. firewall-cmd 防火墙命令详解 及 TCP Wrappers
  10. 14,UA池和代理池