コンテナを作成する [root@server1 ~]# docker run -it --name nginx1 -v /opt/data/web2:/web -p 81:80 centos:latest /bin/bash [ルート@608de4875036 /]# Webディレクトリに入り、nginxパッケージをダウンロードします [root@608de4875036 web]# wget http://nginx.org/download/nginx-1.20.1.tar.gz ディレクトリを解凍する [root@608de4875036 ウェブ]# ls nginx-1.20.1 nginx-1.20.1.tar.gz 依存パッケージをインストールする [root@608de4875036 web]# yum -y インストール pcre-devel openssl openssl-devel gd-devel gcc gcc-c++ make [root@608de4875036 web]# yum -y groups mark install '開発ツール' ユーザーを作成 [root@608de4875036 web]# useradd -r -M -s /sbin/nologin nginx [root@608de4875036 web]# id nginx uid=998(nginx) gid=996(nginx) グループ=996(nginx) ログ保存ファイルアドレスを作成する [root@6ad47178bdd6 web]# mkdir ログ コンパイルしてインストールする [root@608de4875036 ウェブ]# ls ログ nginx-1.20.1 nginx-1.20.1.tar.gz [root@608de4875036 web]# cd nginx-1.20.1 [root@608de4875036 nginx-1.20.1]# ls 自動設定 html README 変更 ライセンス src を構成する CHANGES.ru 貢献者 [root@608de4875036 nginx-1.20.1]# ./configure \ --prefix=/web/nginx \ --user=nginx \ --group=nginx \ --デバッグあり\ --http_ssl_module \ で始まる --http_realip_module \ で始まる --http_image_filter_module \ で始まる --with-http_gunzip_module \ --with-http_gzip_static_module \ --with-http_stub_status_module \ --http-log-path=/web/log/access.log \ --error-log-path=/web/log/error.log [root@608de4875036 nginx-1.20.1]# make && make install カタログを見る [root@6ad47178bdd6 ウェブ]# ls ログ nginx nginx-1.20.1 nginx-1.20.1.tar.gz [root@608de4875036 web]# cd nginx [root@608de4875036 nginx]# ls conf html ログ sbin 環境変数の設定 [root@608de4875036 nginx]# ls conf html ログ sbin [root@608de4875036 nginx]# cd sbin/ [root@608de4875036 sbin]# ls nginx [root@608de4875036 sbin]# pwd ウェブサーバ [root@608de4875036 sbin]# echo "export PATH=/web/nginx/sbin:\$PATH" > /etc/profile.d/nginx.sh [root@608de4875036 sbin]# ソース /etc/profile.d/nginx.sh [root@608de4875036 sbin]# どのnginx nginx の sbin ディレクトリに、 サービスを開始する [root@608de4875036 sbin]# ss -antl 状態 受信Q 送信Q ローカルアドレス:ポート ピアアドレス:ポート プロセス 聞く 0 128 0.0.0.0:80 0.0.0.0:* コンテナ上のサービスを表示する [root@608de4875036 ウェブ]# ls nginx nginx-1.20.1 nginx-1.20.1.tar.gz [root@608de4875036 web]# cd nginx [root@608de4875036 nginx]# ls client_body_temp html sbin conf ログ scgi_temp fastcgi_temp プロキシー_temp uwsgi_temp ホストマシンで表示 [root@server1 ~]# cd /opt/data/ [root@server1 データ]# ls ウェブ1 ウェブ2 [root@server1 データ]# cd web2 [root@server1 web2]# ls ログ nginx nginx-1.20.1 nginx-1.20.1.tar.gz [root@server1 web2]# cd nginx [root@server1 nginx]# ls client_body_temp html sbin conf ログ scgi_temp fastcgi_temp プロキシー_temp uwsgi_temp データが同期されたことがわかります ホスト上の構成ファイルを変更する xyという名前のディレクトリを作成し、ゲームコードをこのディレクトリにコピーします。 [root@server1 html]# パスワード /opt/data/web2/nginx/html [root@server1 html]# mkdir yx [root@server1 html]# cd yx [root@server1 yx]# ls 画像 index.html js ディレクトリテストを作成する [root@server1 html]# mkdir テスト [root@server1 html]# ls [root@server1 html]# ls 50x.html index.html テスト yx [root@server1 html]# mv 50x.html index.html test/ [root@server1 html]# ls テストyx nginx.conf設定ファイルを変更する [root@server1 conf]# vi nginx.conf ........ サーバー{ 8080を聴く; サーバー名 test.example.com; 位置 / { root /web/nginx/html/test; #コンテナ内のファイルアドレス index index.html index.htm; } } サーバー{ 聞く 80; サーバー名 xy.example.com; #文字セット koi8-r; #access_log ログ/host.access.log メイン; 位置 / { root /web/nginx/html/yx; #コンテナ内のファイルアドレス index index.html index.htm; } ..... しかし、この変更には問題があります。 1 つのポートのみがマップされ、他のポートはマップされません。 [root@server1 conf]# docker ポート 608de4875036 80/tcp -> 0.0.0.0:81 80/TCP -> :::81 どうすれば解決できますか? このコンテナを削除する [root@server1 ~]# docker stop 608de4875036 608de4875036 [root@server1 ~]# docker rm 608de4875036 608de4875036 ここのデータはまだホストマシン上に残っています [root@server1 web2]# ls ログ nginx nginx-1.20.1 nginx-1.20.1.tar.gz このディレクトリをコンテナマッピングとして再作成します [root@server1 ~]# docker run -it --name nginx2 -v /opt/data/web2:/web -p 80:80 -p 8080:8080 centos:latest /bin/bash [ルート@6ad47178bdd6 /]# ホストマシンで表示 [root@server1 ~]# docker ps コンテナID イメージ コマンド 作成ステータス ポート名 6ad47178bdd6 centos:latest "/bin/bash" 23 秒前 22 秒前にアップ 0.0.0.0:80->80/tcp、:::80->80/tcp、0.0.0.0:8080->8080/tcp、:::8080->8080/tcp nginx2 [root@server1 ~]# docker ポート 6ad47178bdd6 80/tcp -> 0.0.0.0:80 80/tcp -> :::80 8080/tcp -> 0.0.0.0:8080 8080/tcp -> :::8080 コンテナ内でデータが同期されているかどうかを確認する [root@6ad47178bdd6 /]# ls bin ホーム lost+found opt 実行 sys var dev lib メディア proc sbin tmp web など lib64 mnt ルート srv usr [root@6ad47178bdd6 /]# cd web/ [root@6ad47178bdd6 ウェブ]# ls nginx nginx-1.20.1 nginx-1.20.1.tar.gz [root@6ad47178bdd6 web]# cd nginx [root@6ad47178bdd6 nginx]# ls client_body_temp html sbin conf ログ scgi_temp fastcgi_temp プロキシー_temp uwsgi_temp #データ同期 サービスを開始する #環境変数を記述する [root@6ad47178bdd6 /]# cat /etc/profile.d/nginx.sh PATH=/web/nginx/sbin:$PATH をエクスポートします #nginxユーザーを作成 [root@6ad47178bdd6 /]# useradd -r -M -s /sbin/nologin nginx [ルート@6ad47178bdd6 /]# nginx [root@6ad47178bdd6 /]# ss -antl 状態 受信Q 送信Q ローカルアドレス:ポート ピアアドレス:ポート プロセス 聞く 0 128 0.0.0.0:80 0.0.0.0:* 聞く 0 128 0.0.0.0:8080 0.0.0.0:* 192.168.244.145:80 にアクセス 192.168.244.145:8080にアクセスしてください 独立した nginx コンテナ設定ファイルの実装に関するこの記事はこれで終わりです。関連する独立した nginx コンテナ設定ファイルの詳細については、123WORDPRESS.COM の以前の記事を検索するか、以下の関連記事を引き続き参照してください。今後とも 123WORDPRESS.COM をよろしくお願いいたします。 以下もご興味があるかもしれません:
|
<<: MySQLの整数および文字列インデックスの無効化または暗黙的な変換に関する簡単な説明
>>: 便利で使いやすいウェブアプリケーションを設計するための 10 のヒント
背景要件:ビジネスがどんどん大きくなると、サーバーの数も増え、さまざまなアクセスログ、アプリケーショ...
プログラマーは MySQL を扱う機会が多く、毎日触れているとも言えますが、MySQL テーブルには...
目次動作原理:ブラウザは何をするのですか?ホストファイル index.htmlメイン.jsその他のベ...
序文新しい VPS を購入しました。新しい VPS のデータ ディスクはデフォルトではシステムにマウ...
今では多くの人がウェブサイト作成に参加していますが、ウェブサイトはどのように作成すればよいのでしょう...
1. HTML タグを使用してテーブルを作成します。コードをコピーコードは次のとおりです。 <...
平行ボックスの余白 (二重余白の重なり) に関する面接の質問: 1 つのボックスに上余白があり、もう...
目次1. dfコマンド2. duコマンド3. fsckファイルシステム修復コマンド4. ディスクステ...
今日ふと、HTML でチェックボックスのスタイルを変更できる範囲が限られていることと、チェックボック...
jsx/tsxファイルを直接作成できます今回のプロジェクト構成は以下のとおりです。 vueファイルで...
GreaseMokey (中国語では Grease Monkey Script と呼んでいます) は...
vmware vSphere 6.5 は vSphere ソフトウェアのクラシック バージョンであ...
目次1. 本来の定義2. JS操作、幅の変更を例に3. 効果: 幅が変更されました 1. 本来の定義...
目次1. 構造文字列2. タプルを返す3. Dict辞書にアクセスする4. 図書館を利用する5. リ...