Ubuntu源码安装nginx 「爱情、让人受尽委屈。」 2024-04-19 11:38 19阅读 0赞 1、 安装依赖 更新源 sudo apt-get update 安装c++依赖库 sudo apt-get install build-essential sudo apt-get install libtool 安装openssl依赖库 sudo apt-get install openssl 安装pcre依赖库 sudo apt-get install libpcre3 libpcre3-dev 安装zlib依赖库 sudo apt-get install zlib1g-dev 2、下载nginx包地址:[http://nginx.org/download/nginx-1.12.2.tar.gz][http_nginx.org_download_nginx-1.12.2.tar.gz] nginx下载的网页地址:[http://nginx.org/en/download.html][http_nginx.org_en_download.html] ![2019102121012844.png][] 3、创建nginx用户并安装nginx root@mall-prod:/home/prod/nginx-1.10.1# useradd -s /sbin/nologin -M nginx root@mall-prod:/home/prod/nginx-1.10.1# apt-get install libpcre3 libpcre3-dev openssl libssl-dev libpcre3 libpcre3-dev zlib1g-dev build-essential root@mall-prod:/home/prod/nginx-1.10.1# tar -xf nginx-1.10.1.tar.gz root@mall-prod:/home/prod/nginx-1.10.1# cd nginx-1.10.1/ root@mall-prod:/home/prod/nginx-1.10.1# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_v2_module --with-http_stub_status_module --with-pcre root@mall-prod:/home/prod/nginx-1.10.1# make root@mall-prod:/home/prod/nginx-1.10.1# make install 报错一、 cc1: all warnings being treated as errors objs/Makefile:460: recipe for target 'objs/src/core/ngx_murmurhash.o' failed make[1]: *** [objs/src/core/ngx_murmurhash.o] Error 1 make[1]: Leaving directory '/home/wzj/tools/nginx/nginx-1.11.3' Makefile:8: recipe for target 'build' failed make: *** [build] Error 2 解决办法: 找到对应的Maakefile文件,将gcc参数中的-Werror去掉。 我上面显示的是objs/Makefile文件,我打开看了下,将第三行的-Werror去掉就可以 ![20190917221215752.png][] 报错二、 src/event/ngx_event_openssl.c: In function ‘ngx_ssl_connection_error’: src/event/ngx_event_openssl.c:1941:21: error: ‘SSL_R_NO_CIPHERS_PASSED’ undeclared (first use in this function) || n == SSL_R_NO_CIPHERS_PASSED /* 182 */ ^ src/event/ngx_event_openssl.c:1941:21: note: each undeclared identifier is reported only once for each function it appears in objs/Makefile:980: recipe for target 'objs/src/event/ngx_event_openssl.o' failed make[1]: *** [objs/src/event/ngx_event_openssl.o] Error 1 make[1]: Leaving directory '/usr/local/src/nginx-1.10.1' Makefile:8: recipe for target 'build' failed make: *** [build] Error 2 解决办法:(主要是openssl版本的问题下载1.0.2的版本解压后直接用) root@mall-prod:/home/prod/# wget https://www.openssl.org/source/openssl-1.0.2l.tar.gz --no-check-certificate root@mall-prod:/home/prod/# tar -xf openssl-1.0.2l.tar.gz root@mall-prod:/home/prod/nginx-1.10.1# ./configure --prefix=/home/prod/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_v2_module --with-http_stub_status_module --with-pcre --with-openssl=/home/prod/openssl-1.0.2l 4、启动nginx root@mall-prod:/home/prod/nginx-1.10.1# cd /home/prod/nginx/sbin root@mall-prod:/home/prod/nginx-1.10.1# ./nginx -c /home/deploy/nginx/conf/nginx.conf 5、验证nginx是否启动(看到进程已启动) ![20191021210328794.png][] [http_nginx.org_download_nginx-1.12.2.tar.gz]: http://nginx.org/download/nginx-1.12.2.tar.gz [http_nginx.org_en_download.html]: http://nginx.org/en/download.html [2019102121012844.png]: https://image.dandelioncloud.cn/pgy_files/images/2024/04/18/3c3c1a59c12d4682833979644a62d7ae.png [20190917221215752.png]: https://image.dandelioncloud.cn/pgy_files/images/2024/04/18/d5286b0a2fea4276bc1e4678ba36b02e.png [20191021210328794.png]: https://image.dandelioncloud.cn/pgy_files/images/2024/04/18/543cb29c6be2459aad658d2ad3ae8408.png
还没有评论,来说两句吧...