安装环境及工具:
操作系统: linux 内核版本:2.6.18-194.el5xen
Nginx版本: 1.2.6
pcre版本: 8.32(rewrite module requires pcre library)
zlib版本: 1.2.5 (gzip module requires zlib library)
openssl版本: 1.0.0(ssl support requires openssl library)
安装之前请确定系统中已经安装了gcc相关软件包(rpm -qa|grep gcc)
安装步骤:
1.安装PCRE库
1). cd /usr/local/src 进入到pcre-8.32.tar.gz源文件压缩目录
2). tar -zxvf pcre-8.32.tar.gz 解压缩
3). cd pcre-8.32 进入到源文件目录,运行./configure 命令 进行配置
4).运行 make & make install 命令进行编译安装
2.安装ZLIB库
1). cd /usr/local/src 进入到zlib-1.2.5.tar.gz源文件压缩目录
2). tar -zxvf zlib-1.2.5.tar.gz解压缩
3). cd zlib-1.2.5 进入到源文件目录,运行./configure 命令 进行配置
4).运行 make & make install 命令进行编译安装
3.安装OPENSSL库
1). cd /usr/local/src 进入到openssl-1.0.0.tar.gz源文件压缩目录
2). tar -zxvf openssl-1.0.0.tar.gz解压缩
3). cd openssl-1.0.0 进入到源文件目录,运行./configure命令 进行配置
4).运行 make & make install 命令进行编译安装
4.Nginx安装
1). cd /usr/local/src 进入到nginx-1.2.6.tar.gz源文件压缩目录
2). tar -zxvf nginx-1.2.6.tar.gz解压缩
3). cd nginx-1.2.6.tar.gz进入到源文件目录,运行./configure --help命令 设置各个模块的使用情况。例如对不需要的http_ssi模块,可通过“--without-http_ssi_module”方式关闭。同理,如果需要“http_perl”模块,那么可以通过“--with-http_perl_module”方式进行安装。
4).运行./configure
--user=root
--group=root
--prefix=/usr/local/nginx(nginx的安装目录)
--with-http_stub_status_module
--with-http_ssl_module
--with-http_realip_module
--with-pcre=/usr/local/src/pcre-8.32
--with-zlib=/usr/local/src/zlib-1.2.5
命令 配置nginx
5).make 编译
6).make install 安装
7).运行 /usr/local/nginx/sbin/nginx -t 测试nginx的配置参数,此步骤中会出现一下错误信息:error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory
解决办法: 32位系统创建软连接 ln -s /usr/local/lib/libpcre.so.1 /lib
64位系统创建软连接 ln -s /usr/local/lib/libpcre.so.1 /lib64
再次运行 /usr/local/nginx/sbin/nginx -t 则显示成功
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
5.Nginx启动与关闭
运行/usr/local/nginx/sbin/nginx 命令启动nginx ;
运行 ps -ef|grep nginx 查看进程:
root 12497 1 0 15:00 ? 00:00:00 nginx: master process ./nginx
root 12498 12497 0 15:00 ? 00:00:00 nginx: worker process
运行/usr/local/nginx/sbin/nginx -s stop 命令关闭nginx ;
附加:
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/28624388/viewspace-2163904/
,如需转载,请注明出处,否则将追究法律责任。