zl程序教程

您现在的位置是:首页 >  其他

当前栏目

Nginx 笔记与总结(1)编译安装

安装笔记Nginx 总结 编译
2023-09-11 14:17:03 时间

Nginx 可以承受 3 万并发连接数,Apache 默认最大连接数是 256 个。

 

编译安装

① 下载

在 Nginx 的主页 http://nginx.org/ 下载最新的 stable version(稳定版)Nginx 1.8.0(http://nginx.org/en/download.html-http://nginx.org/download/nginx-1.8.0.tar.gz),ftp 传输到 /usr/local/src 目录下(CentOS 6.6)

 

② 解压

tar zxvf nginx-1.8.0.tar.gz 

 

③ 进入目录

cd nginx-1.8.0

 

④ 配置

 ./configure  --prefix=/usr/local/nginx

 

如果报错:

./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.

解决方案:

PCRE library 是正则表达式库,安装 pcre 包(二进制包):

mount /dev/cdrom /mnt/cdrom #挂载光盘
yum install pcre

 

如果还是报同样的错,可以安装相应的 develop(头文件):

yum install pcre-devel 

 

重新配置:

 ./configure  --prefix=/usr/local/nginx

没有报错。

 

⑤ 编译、安装

make && make install

完毕。

 

 

此时在 /usr/local 下能看到 nginx 目录:

 

进入nginx 目录:

cd nginx
ll

conf:配置文件目录

html:网页文件目录

logs:日志文件目录

sbin:主要二进制程序

sbin/nginx:主程序

 

 

启动 Nginx:

[root@localhost sbin]# cd ../
[root@localhost nginx]# ./sbin/nginx 

 

查看 80 端口的使用情况:

netstat -antp

 

或者

netstat -tunpl | grep 80