1. リソースの準備
dockerfile
# "ported" by adam miller <maxamillion@fedoraproject.org> from # https://github.com/fedora-cloud/fedora-dockerfiles # # originally written for fedora-dockerfiles by # scollier <scollier@redhat.com> from centos:centos7 maintainer the centos project <cloud-ops@centos.org> run yum -y update; yum clean all run yum -y install epel-release tar ; yum clean all run yum -y install nginx ; yum clean all add nginx.conf /opt/deploy/nginx/nginx.conf run echo "daemon off;" >> /opt/deploy/nginx/nginx.conf #run curl https://git.centos.org/sources/httpd/c7/acf5cccf4afaecf3afeb18c50ae59fd5c6504910 \ # | tar -xz -c /usr/local/nginx/html \ # --strip-components=1 #run sed -i -e 's/apache/nginx/g' -e '/apache_pb.gif/d' \ # /usr/local/nginx/html/index.html expose 80 #cmd [ "/usr/local/nginx/sbin" ]
注: パスはシステム上に存在し、
nginx.conf ファイルに対応する必要があります
# for more information on configuration, see: # * official english documentation: http://nginx.org/en/docs/ # * official russian documentation: http://nginx.org/ru/docs/ user nginx; worker_processes 1; error_log /usr/logs/nginx/error.log; #error_log /var/log/nginx/error.log notice; #error_log /var/log/nginx/error.log info; pid /run/nginx.pid; events { 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 /usr/logs/nginx/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; #gzip on; # load modular configuration files from the /etc/nginx/conf.d directory. # see http://nginx.org/en/docs/ngx_core_module.html#include # for more information. #include /etc/nginx/conf.d/*.conf; index index.html index.htm; server { listen 80; server_name localhost; root /usr/share/nginx/html; #charset koi8-r; #access_log /var/log/nginx/host.access.log main; location / { autoindex on; } # redirect server error pages to the static page /40x.html # error_page 404 /404.html; location = /40x.html { } # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { } # proxy the php scripts to apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the php scripts to fastcgi server listening on 127.0.0.1:9000 # #location ~ \.php$ { # root html; # fastcgi_pass 127.0.0.1:9000; # fastcgi_index index.php; # fastcgi_param script_filename /scripts$fastcgi_script_name; # include fastcgi_params; #} # deny access to .htaccess files, if apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} } # another virtual host using mix of ip-, name-, and port-based configuration # #server { # listen 8000; # listen somename:8080; # server_name somename alias another.alias; # root html; # location / { # } #} # https server # #server { # listen 443; # server_name localhost; # root html; # ssl on; # ssl_certificate cert.pem; # ssl_certificate_key cert.key; # ssl_session_timeout 5m; # ssl_protocols sslv2 sslv3 tlsv1; # ssl_ciphers high:!anull:!md5; # ssl_prefer_server_ciphers on; # location / { # } #} }
注: パスはシステム上に存在し、それに対応している必要があります
2. ビルド イメージ コマンドを実行します
コードをコピーしますコードは次のとおりです。次のように:
[root@localhost nginx]# sudo docker build --rm --tag os7/nginx:centos7 .
実行結果のスクリーンショット:
3. イメージがインストールされ、正常にビルドされたかどうかを確認します docker イメージ
#4. コンテナー docker run を作成します - i -t -d -p 192.168.32.129:81:80 os7/nginx / bin/bash
注: IP アドレスが 192.168.32.129 の場合は、
## を追加する必要があります。
# in /etc/hosts ##5. コンテナーが正常に作成されたかどうかを確認し、docker ps
を起動します6.curl http://192.168.32.129:81
に正常にアクセスできるかどうかをテストします。
「この接続は拒否されました」と表示されます。解決方法がありますので、まずはコンテナに入りましょう
7. コンテナに入ります docker exec -i -t small_hodgkin /bin/sh
#8. 次にコンテナ内で実行します (直接入力するだけです)
nginx
9.curl http://192.168.32.129:81
#成功しました。
以上がCentOS7 Docker Nginx をデプロイして実行する方法の詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

Nginxが人気がある理由は、速度、効率、制御における利点です。 1)速度:非同期および非ブロッキング処理を採用し、高い並行接続をサポートし、強力な静的ファイルサービス機能を備えています。 2)効率:低メモリの使用量と強力な負荷分散機能。 3)制御:柔軟な構成ファイル管理動作を通じて、モジュラー設計により拡張が容易になります。

コミュニティ、サポート、リソースの観点からのNginxとApacheの違いは次のとおりです。1。nginxコミュニティは小さくてもプロフェッショナルであり、公式サポートはNginxplusを通じて高度な機能と専門サービスを提供します。 2. Apacheには巨大でアクティブなコミュニティがあり、公式のサポートは主に豊富な文書とコミュニティリソースを通じて提供されます。

Nginxunitは、Python、PHP、Java、Goなどのさまざまなプログラミング言語とフレームワークをサポートするオープンソースアプリケーションサーバーです。1。動的構成をサポートし、サーバーを再起動せずにアプリケーション構成を調整できます。 2.NGINXUNITマルチ言語アプリケーションをサポートし、多言語環境の管理を簡素化します。 3.構成ファイルを使用すると、PythonやPHPアプリケーションの実行など、アプリケーションを簡単に展開および管理できます。 4.ルーティングやロードバランスなどの高度な構成もサポートして、アプリケーションの管理と拡張を支援します。

Nginxは、Webサイトのパフォーマンスと信頼性を改善できます。1。Webサーバーとしての静的コンテンツをプロセス。 2。逆プロキシサーバーとしての転送要求。 3。ロードバランサーとしてリクエストを割り当てます。 4.キャッシュサーバーとしてバックエンド圧力を下げます。 NGINXは、GZIP圧縮の有効化や接続プーリングの調整など、構成の最適化を通じてWebサイトのパフォーマンスを大幅に改善できます。

NginxServesWebContentAndActSasaReverseProxy、loadbalancer、andmore.1)itefficientlyServestaticContentlikehtmlandimages.2)ItfunctionsasareSareProxyandloadbalancer、distributing trafficacrosservers.3)

Nginxunitは、動的な構成と多言語サポートを使用して、アプリケーションの展開を簡素化します。 1)動的構成は、サーバーを再起動せずに変更できます。 2)Python、PHP、Javaなどの複数のプログラミング言語をサポートしています。 3)非同期非ブロッキングI/Oモデルを採用して、高い並行性処理パフォーマンスを改善します。

Nginxは最初にC10Kの問題を解決し、現在、ロードバランス、リバースプロキシ、APIゲートウェイを処理するオールラウンドに発展しています。 1)イベント駆動型のアーキテクチャや非ブロッキングアーキテクチャで有名であり、高い並行性に適しています。 2)Nginxは、IMAP/POP3をサポートするHTTPおよびリバースプロキシサーバーとして使用できます。 3)その作業原則は、イベント駆動型および非同期のI/Oモデルに基づいており、パフォーマンスが向上しています。 4)基本的な使用には、仮想ホストと負荷分散の構成が含まれ、高度な使用には複雑な負荷分散とキャッシュ戦略が含まれます。 5)一般的なエラーには、構成の構文エラーと許可の問題が含まれます。また、デバッグスキルには、nginx-Tコマンドとstub_statusモジュールの使用が含まれます。 6)パフォーマンスの最適化の提案には、GZIP圧縮の使用、ワーカーパラメーターの調整、および

nginxの一般的なエラーの診断とソリューションには、次のものが含まれます。1。ログファイルの表示、2。構成ファイルの調整、3。パフォーマンスを最適化します。ログを分析し、タイムアウト設定を調整し、キャッシュとロードバランスの最適化により、404、502、504などのエラーを効果的に解決して、ウェブサイトの安定性とパフォーマンスを向上させることができます。


ホットAIツール

Undresser.AI Undress
リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover
写真から衣服を削除するオンライン AI ツール。

Undress AI Tool
脱衣画像を無料で

Clothoff.io
AI衣類リムーバー

Video Face Swap
完全無料の AI 顔交換ツールを使用して、あらゆるビデオの顔を簡単に交換できます。

人気の記事

ホットツール

ドリームウィーバー CS6
ビジュアル Web 開発ツール

AtomエディタMac版ダウンロード
最も人気のあるオープンソースエディター

mPDF
mPDF は、UTF-8 でエンコードされた HTML から PDF ファイルを生成できる PHP ライブラリです。オリジナルの作者である Ian Back は、Web サイトから「オンザフライ」で PDF ファイルを出力し、さまざまな言語を処理するために mPDF を作成しました。 HTML2FPDF などのオリジナルのスクリプトよりも遅く、Unicode フォントを使用すると生成されるファイルが大きくなりますが、CSS スタイルなどをサポートし、多くの機能強化が施されています。 RTL (アラビア語とヘブライ語) や CJK (中国語、日本語、韓国語) を含むほぼすべての言語をサポートします。ネストされたブロックレベル要素 (P、DIV など) をサポートします。

Dreamweaver Mac版
ビジュアル Web 開発ツール

ゼンドスタジオ 13.0.1
強力な PHP 統合開発環境
