コンテナを作成する [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 のヒント
この記事では、JS掃海プロジェクトの概要を参考までに紹介します。具体的な内容は次のとおりです。プロジ...
序文Element Plus を例に、コンポーネントとスタイルのオンデマンド読み込みを構成します。環...
序文:ある日、DockerでMySQLサービスを構築したところ、MySQLのコマンドラインで中国語の...
この記事では、ネイティブ JS によって実装された動的読み込みプログレス バーの特殊効果を紹介します...
Dockerのインストール手順をスキップする1. postgresqlイメージを取得する docke...
HTML では、Web ページで使用されるエンコーディングを指定する必要があります。一般的な指定方法...
1. データを初期化する `test_01` が存在する場合はテーブルを削除します。 テーブル「te...
序文プロジェクト開発中、各人のコーディング習慣が異なるため、記述された CSS コードは十分に構造化...
border-radius で生成できる四角形やその他の図形に影を追加する場合 (「Adaptive...
解決 関数 mergeImgs(リスト) { const imgDom = document.cre...
目次EffectList コレクション最初のレンダリング時のEffectList EffectLis...
ウェブサイトが悪意を持ってリクエストされた場合、IP アドレスをブラックリストに登録することは重要な...
問題: MySQL がデータ ファイルを保存するパーティションの容量が小さく、現在いっぱいになってい...
1. package.jsonに追加する "メイン": "electr...
目次需要背景思考分析UI 表示始める1. 支払いコンポーネントテンプレートを作成する2. 支払いコン...