Heim >Betrieb und Instandhaltung >Nginx >So verwenden Sie Supervisor zum Verwalten von Nginx- und Tomcat-Containern
Anforderungen:
Verwenden Sie Docker, um Nginx + Tomcat-Dual-Prozesse zu starten. In tatsächlichen Anwendungen sind mehrere Prozesse relativ häufig.
1: Erstellen Sie ein Docker-Dateiverzeichnis Centos – Kopieren Sie die Konfigurationsdatei base.repo in den Container und ersetzen Sie sie
mkdir -p /docker/web
4: Ein-Klick-Installations-Supervisor: /docker/web/supervisor_install.sh
from centos7 maintainer lin test@163.com copy centos-base.repo /etc/yum.repos.d/centos-base.repo copy nginx_install.sh /tmp/nginx_install.sh run sh /tmp/nginx_install.sh; \rm -rf /usr/local/src/* run sed -i -e '/worker_processes/a daemon off;' /usr/local/nginx/conf/nginx.conf; copy jdk-8u162-linux-x64.tar.gz /usr/local/src/jdk-8u162-linux-x64.tar.gz copy tomcat_install.sh /tmp/tomcat_install.sh run sh /tmp/tomcat_install.sh; \rm -rf /usr/local/src/* copy supervisor_install.sh /tmp/supervisor_install.sh copy supervisord.conf /etc/supervisord.conf copy start_tomcat.sh /usr/local/tomcat/bin/mystart.sh run sh /tmp/supervisor_install.sh; \rm -rf /tmp/*.sh
5: Supervisor-Konfigurationsdatei: /docker/web/supervisord.conf
copy centos-base.repo /etc/yum.repos.d/centos-base.repo [root@docker web]# cat centos-base.repo [base] name=centos-$releasever - base baseurl=http://mirrors.163.com/centos/$releasever/os/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/rpm-gpg-key-centos-7 #released updates [updates] name=centos-$releasever - updates baseurl=http://mirrors.163.com/centos/$releasever/updates/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/rpm-gpg-key-centos-7 #additional packages that may be useful [extras] name=centos-$releasever - extras baseurl=http://mirrors.163.com/centos/$releasever/extras/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/rpm-gpg-key-centos-7 #additional packages that extend functionality of existing packages [centosplus] name=centos-$releasever - plus baseurl=http://mirrors.163.com/centos/$releasever/centosplus/$basearch/ gpgcheck=1 enabled=0 gpgkey=file:///etc/pki/rpm-gpg/rpm-gpg-key-centos-7
6: Tomcat-Startskript/docker/web/start_tomcat .sh
[root@docker web]# cat nginx_install.sh yum install -y wget tar gcc gcc-c++ make pcre pcre-devel zlib zlib-devel openssl openssl-devel cd /usr/local/src wget 'http://nginx.org/download/nginx-1.12.2.tar.gz' tar -zxvf nginx-1.12.2.tar.gz cd nginx-1.12.2 ./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-stream --with-stream_ssl_module make make install exit 0
7: Spiegel erstellen
[root@docker web]# cat tomcat_install.sh yum install -y wget tar cd /usr/local/src/ tar -zxvf jdk-8u162-linux-x64.tar.gz mv jdk1.8.0_162 /usr/local/ #/usr/local/jdk1.8.0_162/bin/java -version #配置java环境变量 echo 'java_home=/usr/local/jdk1.8.0_162/' >>/etc/profile echo 'path=$path:$java_home/bin' >>/etc/profile echo 'classpath=.:$java_home/lib/tools.jar:$java_home/lib/dt.jar:$classpath' >>/etc/profile source /etc/profile wget https://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-8/v8.5.38/bin/apache-tomcat-8.5.38.tar.gz tar -zxvf apache-tomcat-8.5.38.tar.gz mv apache-tomcat-8.5.38 /usr/local/tomcat
8: Containertest starten
[root@docker web]# ll total 185384 -rw-r--r-- 1 root root 835 mar 9 01:12 centos-base.repo -rw-r--r-- 1 root root 669 mar 9 01:11 dockerfile -rw-r--r-- 1 root root 189815615 mar 9 01:15 jdk-8u162-linux-x64.tar.gz -rw-r--r-- 1 root root 340 mar 9 01:13 nginx_install.sh -rw-r--r-- 1 root root 581 mar 9 01:17 tomcat_install.sh
9. Testüberprüfung:
yum -y install epel-release yum -y install python2-pip pip install supervisor10. Containerüberprüfung: Curl Nginx 11. Containerüberprüfung: Curl Kater
Das obige ist der detaillierte Inhalt vonSo verwenden Sie Supervisor zum Verwalten von Nginx- und Tomcat-Containern. Für weitere Informationen folgen Sie bitte anderen verwandten Artikeln auf der PHP chinesischen Website!