1. yum install gcc-c++
2.yum install pcre pcre-devel
yum -c /etc/yum.conf --installroot=/usr/local --releasever=/ install nginx
该命令简单解释如下:
-c /etc/yum.conf 表示指定yum配置文件地址
--installroot=/usr/local 表示指定自定义的安装目录
上面这个命令是通过yum 安装软件到指定路径
3.yum install zlib zlib-devel
4.yum install openssl openssl--devel
5. wget http://nginx.org/download/nginx-1.9.14.tar.gz
6. tar xvzf nginx-1.9.14.tar.gz
第七步和第八步都是切换到解压过后的文件夹执行命令
7. ./configure
这步如果不修改,会默认安装到,/usr/local/nginx 这个目录
这样 ./configure --prefix=/usr/local/nginx-1.6 --with-pcre \ 会默认寻找pcre
rpm -ql pcre 查看prce的安装路径
8.make && make install
9. cd /usr/local/nginx/sbin
修改配置文件 配置ngnix的负载均衡方式
启动命令是在 /usr/local/nginx/sbin 目录下执行的
10. ./nginx 启动
容易遇到的错误:
cc1: all warnings being treated as errors
objs/Makefile:458: recipe for target 'objs/src/core/ngx_murmurhash.o' failed
make[1]: *** [objs/src/core/ngx_murmurhash.o] Error 1
make[1]: Leaving directory '/nginx-1.10.3'
Makefile:8: recipe for target 'build' failed
解决:
找到 -Werro 并去掉,在重新make && make install
容易遇到的错误:
也是在make的时候遇到的错误,版本不匹配
src/os/unix/ngx_user.c: In function ‘ngx_libc_crypt’:
src/os/unix/ngx_user.c:36:7: error: ‘struct crypt_data’ has no member named ‘current_salt’
cd.current_salt[0] = ~salt[0];
^
make[1]: *** [objs/Makefile:774: objs/src/os/unix/ngx_user.o] Error 1
make[1]: Leaving directory '/root/nginx-1.10.1'
make: *** [Makefile:8: build] Error 2
根据提示,到解压的文件夹,注释文件中的 cd.current_salt[0] = ~salt[0]
重新编译打包