ITPub博客

首页 > 数据库 > Oracle > Nginx初探之安装

Nginx初探之安装

原创 Oracle 作者:幕南风 时间:2014-07-03 14:11:28 0 删除 编辑

本文介绍的环境是RHEL-5.7

因为很多预先编译好的安装包都比较陈旧,多数情况下推荐直接从源码编译安装

编译Nginx要求如下:

① GCC编译器以及相关工具:yum -y install gcc gcc-c++ autoconf automake

②模块依赖性:Nginx的一些模块需要其他第三方库的支持,例如gzip模块需要zlib库,rewrite模块需要pcre库,ssl功能需要openssl库:yum -y install zlib zlib-devel openssl openssl-devel pcre pcre-devel

注释:

1)pcre(perl compatible regular expressions:perl兼容正则表达式),如果我们在nginx.conf里面使用正则表达式,那么在编译Nginx时就必须把PCRE库编译进Nginx,因为Nginx的HTTP模块要靠它来解析正则表达式

2)zlib:如果我们在nginx.conf里面配置gzip on对http包进行gzip格式压缩以减少网络传输量,那么就必须把zlib库编译进Nginx


㈠ 创建nginx用户和组

   
   # groupadd nginx
   # useradd -g nginx nginx 
   
㈡ 安装
   
   # cp -r nginx-1.4.2 /home/nginx/
   # chown -R nginx:nginx /home/nginx/nginx-1.4.2/
   $ ./configure --prefix=/home/nginx/nginx --user=nginx --group=nginx

   $ make && make install

注释


㈢ 修改Linux配置

    在/etc/sysctl.conf里面修改如下选项以支持高并发

fs.file-max = 999999    
net.ipv4.tcp_tw_reuse = 1 
net.ipv4.tcp_keepalive_time = 600 
net.ipv4.tcp_fin_timeout = 30 
net.ipv4.tcp_max_tw_buckets = 5000 
net.ipv4.ip_local_port_range = 1024    61000  
net.ipv4.tcp_rmem = 4096 32768 262142  
net.ipv4.tcp_wmem = 4096 32768 262142  
net.core.netdev_max_backlog = 8096 
net.core.rmem_default = 262144 
net.core.wmem_default = 262144 
net.core.rmem_max = 2097152 
net.core.wmem_max = 2097152 
net.ipv4.tcp_syncookies = 1 
net.ipv4.tcp_max_syn.backlog=1024 
    然后执行sysctl -p命令,使上述修改生效

㈣ 启动
   
   因为1024以下端口大多数需要root访问权限,而Nginx是80,这里我们就用root启动Nginx
   # ./nginx
   查看:
   # ps -ef | grep nginx
   # netstat -lntp | grep 80
   # lsof -i :80
   

在浏览器上面输入 http://localhost ,如果出现如下:


<!-- Baidu Button BEGIN -->

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/26515977/viewspace-1208233/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: xtrabackup 增量备份和部分备份
下一篇: innobackupex介绍与使用
请登录后发表评论 登录
全部评论
腾讯数据库工程师

注册时间:2012-05-10

最新文章