摘要:Docker容器下環(huán)境安裝Nginx筆記闯传,中途遇到些問題希望高手指教飒货。
1批狐、下載依賴包和Nginx
wgethttp://zlib.net/zlib-1.2.11.tar.gz
wgethttps://www.openssl.org/source/openssl-1.0.2l.tar.gz
wgethttps://jaist.dl.sourceforge.net/project/pcre/pcre/8.38/pcre-8.38.tar.gz
wgethttp://nginx.org/download/nginx-1.8.0.tar.gz
2瓮下、解壓縮并按照openssl開發(fā)包
[root@7e0590732abb ng]# ll
total 9060
-rw-r--r--. 1 root root 832104 Apr 21 2015 nginx-1.8.0.tar.gz
-rw-r--r--. 1 root root 5365054 May 25 13:09 openssl-1.0.2l.tar.gz
-rw-r--r--. 1 root root 409600 Jul 4 13:42 pcre-8.38.tar.gz
-rw-r--r--. 1 root root 2053336 Jan 12 2016 pcre-8.38.tar.gz.1
-rw-r--r--. 1 root root 607698 Jan 15 18:13 zlib-1.2.11.tar.gz
[root@7e0590732abb ng]# tar -zvxf openssl-1.0.2l.tar.gz
[root@7e0590732abb ng]# tar -zvxf pcre-8.38.tar.gz
[root@7e0590732abb ng]# tar zvxf zlib-1.2.11.tar.gz
[root@7e0590732abb ng]# tar -zvxf nginx-1.8.0.tar.gz
[root@7e0590732abb ng]# ll
total 8676
drwxr-xr-x. 8 1001 1001 4096 Apr 21 2015 nginx-1.8.0
-rw-r--r--. 1 root root 832104 Apr 21 2015 nginx-1.8.0.tar.gz
drwxr-xr-x. 21 root root 4096 Jul 4 13:55 openssl-1.0.2l
-rw-r--r--. 1 root root 5365054 May 25 13:09 openssl-1.0.2l.tar.gz
drwxr-xr-x. 7 1169 1169 4096 Nov 23 2015 pcre-8.38
-rw-r--r--. 1 root root 2053336 Jan 12 2016 pcre-8.38.tar.gz
drwxr-xr-x. 14 501 games 4096 Jan 15 17:36 zlib-1.2.11
-rw-r--r--. 1 root root 607698 Jan 15 18:13 zlib-1.2.11.tar.gz
安裝openssl開發(fā)包:
[root@7e0590732abb include]# yum -y install openssl-devel
3记劈、安裝make工具,后面編譯安裝時會用到。
[root@7e0590732abb nginx-1.8.0]# yum -y install make
configure: error: You need a C++ compiler for C++ support.
make[1]: *** [/ng/pcre-8.38/Makefile] Error 1
make[1]: Leaving directory `/ng/nginx-1.8.0'
make: *** [build] Error 2
4浓镜、在安裝make時提示需要安裝C++
[root@7e0590732abb nginx-1.8.0]# yum -y install gcc gcc-c++
5溃列、編譯安裝
[root@7e0590732abb nginx-1.8.0]# ./configure --sbin-path=/ng/nginx-1.8.0/nginx --conf-path=/ng/nginx-1.8.0/nginx.conf --pid-path=/ng/nginx-1.8.0/nginx.pid --with-http_ssl_module --with-pcre=/ng/pcre-8.38 --with-zlib=/ng/zlib-1.2.11 --with-openssl=/ng/openssl-1.0.2l
checking for OS
........
............
Configuration summary
using PCRE library: /ng/pcre-8.38
using OpenSSL library: /ng/openssl-1.0.2l
md5: using OpenSSL library
sha1: using OpenSSL library
using zlib library: /ng/zlib-1.2.11
nginx path prefix: "/usr/local/nginx"
nginx binary file: "/ng/nginx-1.8.0/nginx"
nginx configuration prefix: "/ng/nginx-1.8.0"
nginx configuration file: "/ng/nginx-1.8.0/nginx.conf"
nginx pid file: "/ng/nginx-1.8.0/nginx.pid"
nginx error log file: "/usr/local/nginx/logs/error.log"
nginx http access log file: "/usr/local/nginx/logs/access.log"
nginx http client request body temporary files: "client_body_temp"
nginx http proxy temporary files: "proxy_temp"
nginx http fastcgi temporary files: "fastcgi_temp"
nginx http uwsgi temporary files: "uwsgi_temp"
nginx http scgi temporary files: "scgi_temp"
[root@7e0590732abb nginx-1.8.0]# make
make -f objs/Makefile
......
.........
make[2]: Leaving directory/ng/openssl-1.0.2l'
Operating system: x86_64-whatever-linux2
You need Perl 5.
make[1]: *** [/ng/openssl-1.0.2l/.openssl/include/openssl/ssl.h] Error 1
make[1]: Leaving directory/ng/nginx-1.8.0'
make: *** [build] Error 2
[root@7e0590732abb nginx]# pwd
/usr/local/nginx
[root@7e0590732abb nginx]# cd sbin
[root@7e0590732abb sbin]# ls
nginx
[root@7e0590732abb sbin]# ./nginx
[root@7e0590732abb sbin]# ss -tnl | nginx
bash: nginx: command not found
bash: ss: command not found
[root@7e0590732abb sbin]# yum -y install netstat
Loaded plugins: fastestmirror, ovl
Loading mirror speeds from cached hostfile
base: mirror.bit.edu.cn
extras: mirror.bit.edu.cn
updates: mirror.bit.edu.cn ...... .......... Complete! [root@7e0590732abb sbin]# netstat -an | grep 80 tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN
6、因為上面的容器在啟動時沒有映射端口膛薛,容器保存后映射端口并運行听隐。
[root@docker01 ~]# docker run -it -p 80:80 --name ngx00 -v /ng:/ng c367c7a906d8 /bin/bash
[root@a4f55a7586e4 sbin]# ./nginx
[root@a4f55a7586e4 sbin]# netstat -an | grep 80
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN
7、使用宿主機IP+80端口訪問正常
問題:
在編譯安裝時仍然有報錯哄啄,如果高手看到幫忙分析一下雅任,目前還沒找到解決方案。
用云棲社區(qū)APP咨跌,舒服~