linux系统中安装nginx
本文主要分享个人在linux系统centos7 安装nginx的方法,并遇到的问题和解决办法。
安装之前可在linux创建一个专门保存软件相关的路径,方便以后查询和管理。例如我这边文件位置都是:/alidata/server/ ,安装都是在该路径下进行。
安装过程中可能会遇到一些问题,出现的问题和解决办法汇总到最后的问题和解决。
1.安装 openssl
OpenSSL是一个SSL协议的开源实现,采用C语言作为开发语言,具备了跨平台的能力,支持Unix/Linux、Windows、Mac OS等多种平台。
安装openssl之前先看一下自己是否安装有openssl,有得话就不用安装了

没有的话,可以通过命令进行安装
yum -y install openssl openssl-devel
2.获取ngxin 安装包
nginx包下载可通过nginx 官网进行:https://nginx.org/en/download.html
这里我是直接在linux 系统进行下载:
cd /alidata/server
wget -c https://nginx.org/download/nginx-1.4.0.tar.gz
3.解压安装包
tar -zxvf nginx-1.4.0.tar.gz
4.安装配置
cd nginx-1.4.0
./configure --prefix=/alidata/server/nginx --sbin-path=/usr/local/nginx/sbin/nginx --with-http_ssl_module
5.编译并安装
make
make install
6.配置快捷命令
sudo cp /usr/local/nginx/sbin/nginx /usr/local/bin/
7. 查看nginx 版本,
nginx -V

遇到的问题:
1.Nginx安装时出现In function ‘ngx_murmur_hash2’等错误
解决:使用编辑器打开 objs/Makefile

2. 报错
src/os/unix/ngx_user.c: In function ‘ngx_libc_crypt’:
src/os/unix/ngx_user.c:35:7: error: ‘struct crypt_data’ has no member named ‘current_salt’
cd.current_salt[0] = ~salt[0];
^
make[1]: *** [objs/Makefile:712: objs/src/os/unix/ngx_user.o] Error 1
解决:修改ngx_user.c /src/os/unix/ngx_user.c 注释掉蓝色这一行

3. #./configure: error: C compiler cc is not found
解决:yum -y install gcc gcc-c++ autoconf automake make
4. #./configure: error: the HTTP rewrite module requires the PCRE library
解决:yum -y install pcre-devel
5.#./configure: error: the HTTP gzip module requires the zlib library.
解决:yum install -y zlib-devel