nginx安装

nginx-1.4.1 centos安装手册

1、权限
请以root权限登陆
如果非root权限登陆,请运行sudo su - 命令切换到root权限

2、准备好编译环境(如果安装了可以省略)
yum -y install wget gcc gcc-c++ ncurses-devel cmake make perl openssl openssl-devel

服务器支持ssl证书(一般服务器默认支持)
yum -y install openssl
yum -y install openssl-devel

3、准备好centos所需要的用户组(如果创建了可以省略)
3.1、新增用户组
groupadd www

3.2、新增用户
useradd www -g www

4、准备好源代码安装目录(如果创建了可以省略)
mkdir -p /root/src
cd /root/src

5、下载、编译pcre库
5.1、下载pcre源代码压缩包
wget http://sourceforge.net/projects/pcre/files/pcre/8.32/pcre-8.32.tar.gz/download

5.2、解压源代码
tar -vxzf pcre-8.32.tar.gz

5.3、进入源代码目录
cd pcre-8.32

5.4、通过configure生成Makefile
./configure

5.5、编译pcre
make

5.5、安装pcre
make install

6、下载、编译nginx和配置nginx
6.1、下载nginx源代码压缩包
wget http://nginx.org/download/nginx-1.4.1.tar.gz

6.2、解压源代码
tar -vxzf nginx-1.4.1.tar.gz

6.3、进入源代码目录
cd nginx-1.4.1

6.4、通过configure生成Makefile
./configure --prefix=/usr/local/nginx --with-pcre --with-http_ssl_module

prefix是指安装目录,一般安装在/usr/local/nginx

==========================================
mynote:如果出现错误:./configure: error: the HTTP gzip module requires the zlib library.
You can either disable the module by using --without-http_gzip_module
option, or install the zlib library into the system, or build the zlib library
statically from the source with nginx by using --with-zlib= option.
则执行yum install -y zlib-devel,后重新生成Makefile

6.5、编译nginx
make

6.5、安装nginx
make install

6.6 检查
/usr/local/nginx/sbin/nginx -t
若出现:
/usr/local/nginx/sbin/nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory
修改软链接
ln -s /usr/local/lib/libpcre.so.1 /lib64/

修改 ulimit限制
vim /etc/security/limits.conf
最下面加入

  • soft nofile 65535
  • hard nofile 65535
    重新打开ssh连接即可

kill -QUIT 2072

原文地址:https://www.cnblogs.com/zhirusi/p/10129046.html