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