Nginx简单介绍

Nginx ("engine x") 是一个高性能的 HTTP 和 反向代理 server,也是一个 IMAP/POP3/SMTP server。Nginx作为负载均衡server:Nginx 既能够在内部直接支持 Rails 和 PHP 程序对外进行服务。也能够支持作为 HTTP代理server对外进行服务。

nginx站点国内的用户有:百度、新浪、网易、腾讯等等。

长处:高并发(10万并发)。部署简单。内存消耗小,成本低。

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

Nginx的安装

下载Nginx(http://nginx.org/en/download.html)。最新的好像是nginx-1.9.3。

下载:wget  http://nginx.org/download/nginx-1.9.3.tar.gz

安装:在安装前安装ngxin所需的模块,以及编译c,c++的软件

yum install gcc-c++

yum -y install zlib zlib-devel openssl openssl-devel pcre pcre-devel

在Ubuntu下使用例如以下:

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

下载nginx的第三方模块,动静分离proxy_cache做缓存,下载网址下载最新的文件,和nginx的下包放在一起(http://labs.frickle.com/files/)

wget http://labs.frickle.com/files/ngx_cache_purge-2.3.tar.gz ./

解压:比方文件下载在/home/andy/文件夹下

tar xzvf nginx-1.9.3.tar.gz

cd nginx-1.9.3

安装Nginx所需的模块

# nginx -V              //能够看到原来的编译选项,以下用到
        # ./configure ... --add-module=..       //你的第三方模块

./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-http_realip_module --without-http-cache --add-module=../ngx_cache_purge-2.3

编译安装

make //make后不要install,改用手动拷贝。

先备份

make install

安装完毕后在/usr/local/会多nginx文件夹,然后

cd /usr/local/nginx

启动Nginx

cd sbin

./nginx

又一次启动

cd sbin

./nginx -s reload

卸载方法

# 删除nginx,保留配置文件
          apt-get remove nginx
         #删除配置文件
         rm -rf /home/nginx

安装出现的问题

假设启动时出现例如以下问题时

1:port被占用

watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" />

说明:80port已被占用

netstat -anp | grep 80   查询占用80port的进程

杀死该进程

kill  -s 9  pid(进程id)

2:错误为:./configure: error: the HTTP rewrite module requires thePCRE library.

解决的方法:安装pcre-devel模块

yum -y install pcre-devel

3.Ubuntu下用apt-get 取代全部的yum

(配置VMwareUbuntu下的静态ip:

1 将虚拟的网络连接设置为桥接模式

2 sudo ifconfig eth0 192.168.1.155 netmask 255.255.255.0

4.缺少安装的OpenSSL库

make: *** No rule to make target `build', needed by `default'.  Stop.
./configure: error: SSL modules require the OpenSSL library.
You can either do not enable the modules, or install the OpenSSL library
into the system, or build the OpenSSL library statically from the source
with nginx by using --with-openssl=<path> option.
 
 
     ubuntu下解决的方法:
      apt-get install openssl
      apt-get install libssl-dev
 
     centos下解决的方法:
       yum -y install openssl openssl-devel

安装完毕。

最新文章

  1. 【C#】获取网页内容及HTML解析器HtmlAgilityPack的使用
  2. vim 编辑器的光标操作
  3. mac 下jetbrains IDE系列IDE主题
  4. mysql in 子查询 效率慢 优化(转)
  5. JSP_EL使用
  6. UILabel字体加粗等属性和特效
  7. Fedora 21 中添加及更新源的命令
  8. 下一代hadoop
  9. Node.js之断言处理
  10. Windows内核中的内存管理
  11. Linux 快速执行历史命令,用 !编号
  12. 怎么样启用红米手机5的ROOT权限
  13. AndroidManifest.xml 最全详解
  14. int 的重载
  15. c# Tuple新特性
  16. IntelliJ idea 的破解
  17. MVC的简单分页【转】
  18. react.js 之 create-react-app 命令行工具系统讲解
  19. centos和ubuntu的网络属性配置
  20. 决Ubuntu使用`make menuconfig`配置Linux 内核时,出现缺少&#39;ncurses-devel&#39;库支持。

热门文章

  1. HTML习题附答案
  2. jQuery闪烁提示,让新消息在网页标题显示
  3. CodeForces - 1105D Kilani and the Game(多源BFS+暴力)
  4. 2019天梯赛练习题(L1专项练习)
  5. Mybatis 头信息
  6. mysql5.7配置
  7. PLSQL Developer连接数据库报错ora-12514解决
  8. shiro配置文件
  9. LeetCode(25)Reverse Nodes in k-Group
  10. 关于markdown 的简单使用(已更新)