一、docker安裝
[root@localhost ~]# ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:8e:16:84 brd ff:ff:ff:ff:ff:ff
inet 192.168.0.129/24 brd 192.168.0.255 scope global noprefixroute ens33
valid_lft forever preferred_lft forever
inet6 fe80::8834:847b:a121:ff19/64 scope link noprefixroute
valid_lft forever preferred_lft forever
3: docker0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default
link/ether 02:42:bc:0b:7a:4c brd ff:ff:ff:ff:ff:ff
inet 172.17.0.1/16 scope global docker0
valid_lft forever preferred_lft forever
inet6 fe80::42:bcff:fe0b:7a4c/64 scope link
valid_lft forever preferred_lft forever
5: veth90cf204@if4: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master docker0 state UP group default
link/ether 7e:f9:fe:6a:42:52 brd ff:ff:ff:ff:ff:ff link-netnsid 0
inet6 fe80::7cf9:feff:fe6a:4252/64 scope link
valid_lft forever preferred_lft forever
[root@localhost ~]# docker search nginx
INDEX NAME DESCRIPTION STARS OFFICIAL AUTOMATED
docker.io docker.io/nginx Official build of Nginx. 13596 [OK]
docker.io docker.io/jwilder/nginx-proxy Automated Nginx reverse proxy for docker c... 1858 [OK]
......
[root@localhost ~]# docker pull docker.io/nginx
......
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/nginx latest 08393e824c32 7 days ago 132 MB
......
[root@localhost ~]# docker run -d -p 81:80 --name mynginx docker.io/nginx:latest
......
[root@localhost ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
b6d52eabcbf0 docker.io/nginx:latest "/docker-entrypoin..." 52 minutes ago Up 52 minutes 0.0.0.0:81->80/tcp mynginx
[root@localhost ~]# docker exec -it b6d52eabcbf0 /bin/sh
# ls
bin boot dev docker-entrypoint.d docker-entrypoint.sh etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var
二、*.tar.gz安裝
[root@localhost soft]# pwd
/home/soft
[root@localhost soft]# ls
nginx-1.8.1.tar.gz
[root@localhost soft]# tar -zxvf nginx-1.8.1.tar.gz nginx-1.8.1
[root@localhost soft]# ll
total 816
drwxr-xr-x. 8 1001 1001 158 Jan 26 2016 nginx-1.8.1
-rw-r--r--. 1 root root 833473 Sep 8 2018 nginx-1.8.1.tar.gz
# --- 安裝make:yum -y install autoconf automake make
# --- 安裝g++: yum -y install gcc gcc-c++
[root@localhost soft]# yum -y install autoconf automake make
......
[root@localhost soft]# yum -y install gcc gcc-c++
......
# --- 安裝nginx依賴的庫
[root@localhost soft]# yum -y install pcre pcre-devel
......
[root@localhost soft]# yum -y install zlib zlib-devel
......
[root@localhost soft]# yum install -y openssl openssl-devel
......
#--prefix指定安裝目錄
#--with-http_ssl_module安裝https模塊
#creating objs/Makefile 代表編譯成功
[root@localhost nginx-1.8.1]# ./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
checking for OS
+ Linux 3.10.0-862.el7.x86_64 x86_64
checking for C compiler ... found
+ using GNU C compiler
+ gcc version: 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC)
checking for gcc -pipe switch ... found
checking for gcc builtin atomic operations ... found
checking for C99 variadic macros ... found
checking for gcc variadic macros ... found
checking for unistd.h ... found
checking for inttypes.h ... found
checking for limits.h ... found
checking for sys/filio.h ... not found
checking for sys/param.h ... found
checking for sys/mount.h ... found
checking for sys/statvfs.h ... found
checking for crypt.h ... found
checking for Linux specific features
checking for epoll ... found
checking for EPOLLRDHUP ... found
checking for O_PATH ... found
checking for sendfile() ... found
checking for sendfile64() ... found
checking for sys/prctl.h ... found
checking for prctl(PR_SET_DUMPABLE) ... found
checking for sched_setaffinity() ... found
checking for crypt_r() ... found
checking for sys/vfs.h ... found
checking for nobody group ... found
checking for poll() ... found
checking for /dev/poll ... not found
checking for kqueue ... not found
checking for crypt() ... not found
checking for crypt() in libcrypt ... found
checking for F_READAHEAD ... not found
checking for posix_fadvise() ... found
checking for O_DIRECT ... found
checking for F_NOCACHE ... not found
checking for directio() ... not found
checking for statfs() ... found
checking for statvfs() ... found
checking for dlopen() ... not found
checking for dlopen() in libdl ... found
checking for sched_yield() ... found
checking for SO_SETFIB ... not found
checking for SO_ACCEPTFILTER ... not found
checking for TCP_DEFER_ACCEPT ... found
checking for TCP_KEEPIDLE ... found
checking for TCP_FASTOPEN ... found
checking for TCP_INFO ... found
checking for accept4() ... found
checking for eventfd() ... found
checking for int size ... 4 bytes
checking for long size ... 8 bytes
checking for long long size ... 8 bytes
checking for void * size ... 8 bytes
checking for uint64_t ... found
checking for sig_atomic_t ... found
checking for sig_atomic_t size ... 4 bytes
checking for socklen_t ... found
checking for in_addr_t ... found
checking for in_port_t ... found
checking for rlim_t ... found
checking for uintptr_t ... uintptr_t found
checking for system byte ordering ... little endian
checking for size_t size ... 8 bytes
checking for off_t size ... 8 bytes
checking for time_t size ... 8 bytes
checking for setproctitle() ... not found
checking for pread() ... found
checking for pwrite() ... found
checking for sys_nerr ... found
checking for localtime_r() ... found
checking for posix_memalign() ... found
checking for memalign() ... found
checking for mmap(MAP_ANON|MAP_SHARED) ... found
checking for mmap("/dev/zero", MAP_SHARED) ... found
checking for System V shared memory ... found
checking for POSIX semaphores ... not found
checking for POSIX semaphores in libpthread ... found
checking for struct msghdr.msg_control ... found
checking for ioctl(FIONBIO) ... found
checking for struct tm.tm_gmtoff ... found
checking for struct dirent.d_namlen ... not found
checking for struct dirent.d_type ... found
checking for sysconf(_SC_NPROCESSORS_ONLN) ... found
checking for openat(), fstatat() ... found
checking for getaddrinfo() ... found
checking for PCRE library ... found
checking for PCRE JIT support ... found
checking for OpenSSL library ... found
checking for zlib library ... found
creating objs/Makefile
Configuration summary
+ using system PCRE library
+ using system OpenSSL library
+ md5: using OpenSSL library
+ sha1: using OpenSSL library
+ using system zlib library
nginx path prefix: "/usr/local/nginx"
nginx binary file: "/usr/local/nginx/sbin/nginx"
nginx configuration prefix: "/usr/local/nginx/conf"
nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
nginx pid file: "/usr/local/nginx/logs/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"
#make編譯
#make install安裝
[root@localhost nginx-1.8.1]# make && make install
[root@localhost nginx]# pwd
/usr/local/nginx
[root@localhost nginx]# ll
total 4
drwxr-xr-x. 2 root root 4096 Aug 17 11:10 conf # 配置文件
drwxr-xr-x. 2 root root 40 Aug 17 11:10 html # 網頁文件
drwxr-xr-x. 2 root root 6 Aug 17 11:10 logs # 日誌文件
drwxr-xr-x. 2 root root 19 Aug 17 11:10 sbin # 二進制程序
三、nginx常用命令
啓停命令: cd sbin
./nginx -c conf/nginx.conf的文件。如果不指定,默認爲NGINX_HOME/conf/nginx.conf
./nginx -s stop 停止
./nginx -s quit退出
./nginx -s reload 重新加載nginx.conf
發送信號的方式
kill -QUIT 進程號 安全停止
kill -TERM 進程號 立即停止