1. Linux で nginx をインストールして構成する
nginx を初めてインストールする場合、プロセス中に発生する問題は段階的に解決されます。
ツール securecrt は、サーバーに接続してログインするために使用されます。
1.1 rz コマンドを実行すると、ダイアログ ボックスが表示されるので、アップロードする nginx 圧縮パッケージを選択します。
#rz
1.2 解凍します
[root@vw010001135067 ~]# cd /usr/local/ [root@vw010001135067 local]# tar -zvxf nginx-1.10.2.tar.gz
1.3 nginx フォルダーに入り、./configure コマンドを実行します
[root@vw010001135067 local]# cd nginx-1.10.2 [root@vw010001135067 nginx-1.10.2]# ./configure
エラーは次のように報告されます:
checking for os + linux 2.6.32-431.el6.x86_64 x86_64 checking for c compiler ... not found ./configure: error: c compiler cc is not found
Thisエラーが発生します。その場合、gcc パッケージはインストールされません。
1.3.1 gcc のインストール
gcc の表示
[root@vw010001135067 nginx-1.10.2]# whereis gcc gcc:
gcc のインストール
[root@vw010001135067 nginx-1.10.2]# yum -y install gcc
インストールが成功したら再度確認します
[root@vw010001135067 nginx-1.10.2]# whereis gcc gcc: /usr/bin/gcc /usr/lib/gcc /usr/libexec/gcc /usr/share/man/man1/gcc.1.gz
gcc がインストールされています。
1.3.2 ./configure
[root@vw010001135067 nginx-1.10.2]# ./configure checking for os + linux 2.6.32-431.el6.x86_64 x86_64 checking for c compiler ... found ...... checking for pcre library ... not found checking for pcre library in /usr/local/ ... not found checking for pcre library in /usr/include/pcre/ ... not found checking for pcre library in /usr/pkg/ ... not found checking for pcre library in /opt/local/ ... not found ./configure: error: the http rewrite module requires the pcre library. you can either disable the module by using --without-http_rewrite_module option, or install the pcre library into the system, or build the pcre library statically from the source with nginx by using --with-pcre=<path> option.
を実行し続けると上記のエラーが発生します。 pcre-devel をインストールします
[root@vw010001135067 nginx-1.10.2]# yum install pcre-devel
1.3.3 ./configure を再度実行します
error: the http gzip module requires the zlib library. you can either disable the module by using --without-http_gzip_module option, or install the zlib library into the system, or build the zlib library statically from the source with nginx by using --with-zlib=<path> option.
このエラーがある場合は実行してください
yum install zlib-devel
1.3.4 その後エラーは報告されません./configure
[root@vw010001135067 nginx-1.10.2]# ./configure checking for os + linux 2.6.32-431.el6.x86_64 x86_64 checking for c compiler ... found + using gnu c compiler + gcc version: 4.4.7 20120313 (red hat 4.4.7-17) (gcc) ....... configuration summary + using system pcre library + openssl library is not used + md5: using system crypto library + sha1: using system crypto library + using system zlib library nginx path prefix: "/usr/local/nginx" nginx binary file: "/usr/local/nginx/sbin/nginx" nginx modules path: "/usr/local/nginx/modules" 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"
1.4 の実行 openssl 機能、sha1 機能を使用する場合。次に、openssl をインストールし、sha1
[root@vw010001135067 nginx-1.10.2]# yum install openssl openssl-devel [root@vw010001135067 nginx-1.10.2]# install perl-digest-sha1.x86_64
1.4.1 ssl モジュールを有効にして、./configure –with-http_ssl_module
[root@vw010001135067 nginx-1.10.2]# ./configure --with-http_ssl_module
1.4.2 を実行します。「サーバー ステータス」ページを有効にして、./configure を実行します。 –with -http_stub_status_module
[root@vw010001135067 nginx-1.10.2]# ./configure --with-http_stub_status_module
上記 2 つのコマンドを同時に開始できます
コードをコピーしますコードは次のとおりです:
[root@vw010001135067 nginx-1.10.2]# ./configure --with-http_stub_status_module --with-http_ssl_module
1.5 上記のconfigureは成功しました
makeコマンドを実行し、make installコマンドを実行します。
[root@vw010001135067 nginx-1.10.2]# make [root@vw010001135067 nginx-1.10.2]# make install
この時点で、nginx は成功します。
1.6 環境変数を設定します
/etc/profile に設定を追加します
設定ファイルを開きます
[root@vw010001135067 nginx-1.10.2]# vi /etc/profile
設定ファイルに追加
#nginx configure export nginx_home=/usr/local/nginx-1.10.2 export path=$path:$nginx_home/sbin
上記のように入力し始めましたが、nginx -vを使用すると見つかりませんでした。上記の nginx_home 設定のアドレスが間違っていることに気付きました。まずnginxのインストールアドレスを探します
[root@vw010001135067 nginx-1.10.2]# whereis nginx nginx: /usr/local/nginx
これは本当に間違ったアドレスです 上記を
#nginx configure export nginx_home=/usr/local/nginx export path=$path:$nginx_home/sbin
に変更します コンパイル後、保存して終了し、
[root@vw010001135067 nginx-1.10.2]# source /etc/profile
を実行して設定を行います効果的。
1.7 nginx バージョンの確認
[root@vw010001135067 nginx]# nginx -v nginx version: nginx/1.10.2
プロセス全体が成功しました。
2. nginx.conf を変更します
2.1 nginx を開始します
設定後の nginx サービスは http://10.1.135.67/ にあります。成功しました。nginx
[root@vw010001135067 nginx]# cd /usr/local/nginx [root@vw010001135067 nginx]# nginx -c conf/nginx.conf
を起動してください。起動が成功しました。ブラウザで http://10.1.135.67/ を開きます。デフォルトのポート番号は 80.
上記のように、nginx はすでに正常に動作しています。
2.2 Tomcat サービスの構成
現在、Tomcat サービスは 10.1.29.15 にあり、nginx 経由で転送する必要があります。次に、nginx.conf を開いて構成ファイルを変更します。次のように追加します:
#user nobody; worker_processes 1; #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; #pid logs/nginx.pid; events { worker_connections 1024;#最大连接数,默认为512 accept_mutex on; #设置网路连接序列化,防止惊群现象发生,默认为on multi_accept on; #设置一个进程是否同时接受多个网络连接,默认为off #use epoll; #事件驱动模型,select|poll|kqueue|epoll|resig|/dev/poll|eventport } http { #文件扩展名与文件类型映射表 include mime.types; #默认文件类型,默认为text/plain 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"'; #combined为日志格式的默认值 access_log logs/access.log main; #允许sendfile方式传输文件,默认为off,可以在http块,server块,location块 sendfile on; sendfile_max_chunk 100k; #每个进程每次调用传输数量不能大于设定的值,默认为0,即不设上限。 #tcp_nopush on; #连接超时时间,默认为75s,可以在http,server,location块。 keepalive_timeout 65; #gzip on; upstream upload { server 10.1.29.15:8080; } error_page 404 https://www.baidu.com; #错误页 server { keepalive_requests 120; #单连接请求上限次数。 listen 80; #监听端口 server_name localhost; #监听地址 #charset koi8-r; #access_log logs/host.access.log main; location ~ ^.*?/upload/[^/]*?$ { proxy_connect_timeout 15; proxy_send_timeout 15; proxy_read_timeout 15; proxy_set_header host $host; proxy_set_header x-real-ip $remote_addr; proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for; proxy_set_header connection ""; proxy_pass http://upload; #请求转向upload 定义的服务器列表 client_max_body_size 1024m; } } }
設定後、設定ファイルを保存してnginxを再起動します
[root@vw010001135067 nginx]# nginx -s reload
アップロード プロジェクトがブラウザで正常に呼び出されるかどうか
# 図に示すように、プロジェクトに正しくアクセスでき、構成は成功しました。
以上がLinux で nginx をインストールして構成する方法の詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

NginxとApacheにはそれぞれ独自の利点と欠点があり、選択は特定のニーズに基づいている必要があります。 1.Nginxは、非同期の非ブロッキングアーキテクチャのため、高い並行性シナリオに適しています。 2。Apacheは、モジュラー設計のため、複雑な構成を必要とする低変動シナリオに適しています。

Nginxunitは、複数のプログラミング言語をサポートし、動的構成、ゼロダウンタイム更新、組み込みのロードバランシングなどの機能を提供するオープンソースアプリケーションサーバーです。 1。動的構成:再起動せずに構成を変更できます。 2。多言語サポート:Python、Go、Java、PHPなどと互換性があります。 4。ビルトインロードバランシング:リクエストは、複数のアプリケーションインスタンスに配布できます。

nginxunitは、多言語プロジェクトや動的な構成要件に適した、apachetomcat、gunicorn、node.jsビルトインHTTPサーバーよりも優れています。 1)複数のプログラミング言語をサポートします。2)動的な構成リロード、3)高いスケーラビリティと信頼性を必要とするプロジェクトに適した組み込みの負荷分散機能を提供します。

Nginxunitは、モジュラーアーキテクチャと動的な再構成機能により、アプリケーションのパフォーマンスと管理性を向上させます。 1)モジュラー設計には、マスタープロセス、ルーター、アプリケーションプロセスが含まれ、効率的な管理と拡張をサポートします。 2)動的再構成により、CI/CD環境に適した、実行時に構成をシームレスに更新できます。 3)多言語サポートは、言語ランタイムの動的なロードを通じて実装され、開発の柔軟性が向上します。 4)イベント駆動型モデルと非同期I/Oによって高性能が達成され、高い並行性の下でも効率的なままです。 5)申請プロセスを分離し、アプリケーション間の相互の影響を減らすことにより、セキュリティが改善されます。

nginxunitを使用して、アプリケーションを複数の言語で展開および管理できます。 1)nginxunitをインストールします。 2)PythonやPHPなどのさまざまなタイプのアプリケーションを実行するように構成します。 3)アプリケーション管理に動的構成関数を使用します。これらの手順を通じて、アプリケーションを効率的に展開および管理し、プロジェクトの効率を向上させることができます。

NGINXは、高い並行接続の処理に適していますが、Apacheは複雑な構成とモジュール拡張が必要なシナリオにより適しています。 1.Nginxは、高性能と低リソース消費で知られており、高い並行性に適しています。 2. Apacheは、その安定性とリッチモジュール拡張機能で知られています。これは、複雑な構成ニーズに適しています。

Nginxunitは、動的な構成と高性能アーキテクチャにより、アプリケーションの柔軟性とパフォーマンスを向上させます。 1.動的構成により、サーバーを再起動せずにアプリケーション構成を調整できます。 2.高性能は、イベント駆動型および非ブロッキングアーキテクチャおよびマルチプロセスモデルに反映され、同時接続を効率的に処理し、マルチコアCPUを利用できます。

NginxとApacheはどちらも強力なWebサーバーであり、それぞれがパフォーマンス、スケーラビリティ、効率の点で独自の利点と短所を備えています。 1)nginxは、静的なコンテンツを処理し、逆プロキシを逆にするときにうまく機能します。 2)Apacheは、動的コンテンツを処理するときにパフォーマンスが向上し、リッチモジュールサポートが必要なプロジェクトに適しています。サーバーの選択は、プロジェクトの要件とシナリオに基づいて決定する必要があります。


ホットAIツール

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

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

Undress AI Tool
脱衣画像を無料で

Clothoff.io
AI衣類リムーバー

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

人気の記事

ホットツール

Safe Exam Browser
Safe Exam Browser は、オンライン試験を安全に受験するための安全なブラウザ環境です。このソフトウェアは、あらゆるコンピュータを安全なワークステーションに変えます。あらゆるユーティリティへのアクセスを制御し、学生が無許可のリソースを使用するのを防ぎます。

メモ帳++7.3.1
使いやすく無料のコードエディター

SAP NetWeaver Server Adapter for Eclipse
Eclipse を SAP NetWeaver アプリケーション サーバーと統合します。

SublimeText3 中国語版
中国語版、とても使いやすい

EditPlus 中国語クラック版
サイズが小さく、構文の強調表示、コード プロンプト機能はサポートされていません

ホットトピック









