The source of the Docker container installation Nginx:
[Email protected] ~]# mkdir/nginx-1.8/
[[email protected] nginx-1.8]# ls
nginx-1.8.0 nginx-1.8.0.tar.gz
[[email protected] nginx-1.8.0]#./configure--prefix=/export/server/nginx--with-http_ssl_module--with-http_stub_status_module
Checking for OS
+ Linux 2.6.32-504.el6.x86_64 x86_64
Checking for C compiler ... found
+ using GNU C compiler
+ gcc version:4.8.3 20140911 (Red Hat 4.8.3-9) (GCC)
Checking for gcc-pipe switch ... found
。。。。。。。
Configuration Summary
+ Using System PCRE Library
+ OpenSSL Library is not used
+ Using BUILTIN MD5 code
+ SHA1 Library is not found
+ using Zlib library:/nginx-1.8/nginx-1.8.0/auto/lib/zlib
Nginx path prefix: "/export/server/nginx"
Nginx binary file: "/export/server/nginx/sbin/nginx"
Nginx configuration prefix: "/export/server/nginx/conf"
Nginx configuration file: "/export/server/nginx/conf/nginx.conf"
Nginx pid file: "/export/server/nginx/logs/nginx.pid"
Nginx error log file: "/export/server/nginx/logs/error.log"
Nginx HTTP access log file: "/export/server/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"
Configuration Complete!
Start the installation compilation
[[email protected] nginx-1.8.0]# make && make install
MAKE[1]: Leaving directory '/nginx-1.8/nginx-1.8.0 '
Make-f Objs/makefile Install
MAKE[1]: Entering directory '/nginx-1.8/nginx-1.8.0 '
test-d '/export/server/nginx ' | | Mkdir-p '/export/server/nginx '
test-d '/export/server/nginx/sbin ' | | Mkdir-p '/export/server/nginx/sbin '
Test! -F '/export/server/nginx/sbin/nginx ' | | MV '/export/server/nginx/sbin/nginx '/export/server/nginx/sbin/nginx.old '
CP Objs/nginx '/export/server/nginx/sbin/nginx '
test-d '/export/server/nginx/conf ' | | Mkdir-p '/export/server/nginx/conf '
CP Conf/koi-win '/export/server/nginx/conf '
CP Conf/koi-utf '/export/server/nginx/conf '
CP Conf/win-utf '/export/server/nginx/conf '
Test-f '/export/server/nginx/conf/mime.types ' | | CP conf/mime.types '/export/server/nginx/conf '
CP conf/mime.types '/export/server/nginx/conf/mime.types.default '
Test-f '/export/server/nginx/conf/fastcgi_params ' | | CP Conf/fastcgi_params '/export/server/nginx/conf '
CP Conf/fastcgi_params '/export/server/nginx/conf/fastcgi_params.default '
Test-f '/export/server/nginx/conf/fastcgi.conf ' | | CP conf/fastcgi.conf '/export/server/nginx/conf '
CP conf/fastcgi.conf '/export/server/nginx/conf/fastcgi.conf.default '
Test-f '/export/server/nginx/conf/uwsgi_params ' | | CP Conf/uwsgi_params '/export/server/nginx/conf '
CP Conf/uwsgi_params '/export/server/nginx/conf/uwsgi_params.default '
Test-f '/export/server/nginx/conf/scgi_params ' | | CP Conf/scgi_params '/export/server/nginx/conf '
CP Conf/scgi_params '/export/server/nginx/conf/scgi_params.default '
Test-f '/export/server/nginx/conf/nginx.conf ' | | CP conf/nginx.conf '/export/server/nginx/conf/nginx.conf '
CP conf/nginx.conf '/export/server/nginx/conf/nginx.conf.default '
test-d '/export/server/nginx/logs ' | | Mkdir-p '/export/server/nginx/logs '
test-d '/export/server/nginx/logs ' | | Mkdir-p '/export/server/nginx/logs '
test-d '/export/server/nginx/html ' | | Cp-r html '/export/server/nginx '
test-d '/export/server/nginx/logs ' | | Mkdir-p '/export/server/nginx/logs '
MAKE[1]: Leaving directory '/nginx-1.8/nginx-1.8.0
Nginx source code compiled successfully!
[[email protected] nginx]# pwd
/export/server/nginx
View Nginx's file directory!
[Email protected] nginx]# LS *
Conf
fastcgi.conf fastcgi_params koi-utf mime.types nginx.conf scgi_params uwsgi_ Params Win-utf
Fastcgi.conf.default fastcgi_params.default koi-win mime.types.default nginx.conf.default scgi_params.default uwsgi_ Params.default
Html:
50x.html index.html
Logs
Sbin
Nginx
View Container CPU information!
[Email protected] conf]#Cat/proc/cpuinfo
processor:0
Vendor_id:genuineintel
CPU Family:6
model:58
Model Name:intel (R) Core (TM) i5-3230m CPU @ 2.60GHz
Stepping:9
Microcode:25
CPU mhz:2600.219
Cache size:6144 KB
Physical id:0
Siblings:1
Core id:0
CPU Cores:1
apicid:0
Initial apicid:0
Fpu:yes
Fpu_exception:yes
CPUID Level:5
Wp:yes
FLAGS:FPU VME de PSE TSC MSR PAE MCE cx8 APIC Sep MTRR PGE MCA cmov Pat PSE36 Clflush MMX fxsr SSE SSE2 syscall N X rdtscp lm CONSTANT_TSC up rep_good PNI monitor SSSE3 LAHF_LM
bogomips:5200.43
Clflush size:64
Cache_alignment:64
Address sizes:36 bits physical, bits virtual
Simple Configuration Nginx Access:
[[email protected] nginx-1.8.0]# Cd/export/server/nginx
[[email protected] nginx]# ls
Client_body_temp conf fastcgi_temp HTML logs proxy_temp sbin scgi_temp uwsgi_temp
[Email protected] nginx]#Cat/proc/cpuinfo | grep processor View the container kernel to configure Nginx
processor:0
[Email protected] nginx]# vi/export/server/nginx/conf/nginx.conf
User Nginx Nginx;
Worker_processes 6;
Error_log Logs/error.log;
PID Logs/nginx.pid;
Events {
Use Epoll;
Worker_connections 1024;
}
HTTP {
Include Mime.types;
Default_type Application/octet-stream;
Log_format Main ' $remote _addr-$remote _user [$time _local] "$request" '
' $status $body _bytes_sent ' $http _referer '
' "$http _user_agent" "$http _x_forwarded_for";
Access_log Logs/access.log Main;
Sendfile on;
Tcp_nopush on;
Keepalive_timeout 65;
#gzip on;
server {
Listen 80;
server_name localhost;
Location/{
Root/export/app;
Index index.html index.htm;
}
Error_page 404/404.html;
Error_page 502 503 504/50x.html;
Location =/50x.html {
root HTML;
}
}
}
Remember, nGinx's work process is performed by nginx users., so you need to add Nginx users!
Configuration complete and detect the integrity and correctness of the configuration! (then start #/export/server/nginx/sbin/nginx)
[Email protected] nginx]#/export/server/nginx/sbin/nginx-t
Nginx:the configuration file/export/server/nginx/conf/nginx.conf syntax is OK
Nginx:configuration file/export/server/nginx/conf/nginx.conf Test is successful
[Email protected] Nginx]# Ps-ef | grep nginx
Root 11065 1 0 07:17? 00:00:00 nginx:master process./nginx
Nginx 11066 11065 0 07:17? 00:00:00 Nginx:worker Process
Nginx 11067 11065 0 07:17? 00:00:00 Nginx:worker Process
Nginx 11068 11065 0 07:17? 00:00:00 Nginx:worker Process
Nginx 11069 11065 0 07:17? 00:00:00 Nginx:worker Process
Nginx 11070 11065 0 07:17? 00:00:00 Nginx:worker Process
Nginx 11071 11065 0 07:17? 00:00:00 Nginx:worker Process
Root 11088 1 0 07:25? 00:00:00 grep--color=auto Nginx
Test:
In the configuration file, the index.html (hostname/container ID) file is placed by default under/export/app/(that is, the default publishing directory, be sure to pay attention to the permissions OH)
[[email protected] nginx]# Curl http://localhost
465d13a11ffa
Write Nginx system startup script!
#vim/etc/init.d/nginx
#!/bin/bash
#
# Chkconfig:-85 15
# Description:nginx is a world Wide Web server. It's used to serve
# Source Function Library
# Nginx Settings
Nginx_sbin= "/export/server/nginx/sbin/nginx"
nginx_conf= "/export/server/nginx/conf/nginx.conf"
Nginx_pid= "/export/server/nginx/logs/nginx.pid"
Retval=0
Prog= "Nginx"
Start () {
Echo-n $ "Starting $prog:"
Mkdir-p/dev/shm/nginx_temp
$NGINX _sbin-c $NGINX _conf
Retval=$?
If [$RETVAL-eq 0];then
echo "ok!"
Else
echo "Error,please test the $NGINX _conf"
Fi
}
Stop () {
Echo-n $ "Stopping $prog:"
Pkill Nginx
Rm-rf/dev/shm/nginx_temp
Retval=$?
If [$RETVAL-eq 0];then
echo "ok!"
Else
echo "Error,please test the $NGINX _conf"
Fi
}
Reload () {
Echo-n $ "Reloading $prog:"
$NGINX _sbin-s Reload
Retval=$?
If [$RETVAL-eq 0];then
echo "ok!"
Else
echo "Error,please test the $NGINX _conf"
Fi
}
Restart () {
Stop
Start
}
Configtest () {
$NGINX _sbin-c $NGINX _conf-t
return 0
}
Case "$" in
Start
Start
;;
Stop
Stop
;;
Reload
Reload
;;
Restart
Restart
;;
Configtest)
Configtest
;;
*)
echo $ "Usage: $ {start|stop|reload|restart|configtest}"
Retval=1
Esac
Exit $RETVAL
External network test:
[email protected] ~]# Curl http://10.0.0.2/index.html
465d13a11ffa
(think: In the Docker admin section you can access, how to set up the network can be accessed on the Windows host!) )
Deploy container nginx based on the source of Docker environment