Windows下 nginx+php快速配置及性能测试
一、Windowsnginxphp环境配置: 1.下载php-5.3.16-nts-Win32-VC9-x86.zip(nts-非线程安全,nginx需要php的cgi模式运行),解压缩至d:\wnmp\php5 2.配置php.ini(可以将php.ini-development复制成php.ni,然后主要是4个位置配置): extension_dir = D:/wnmp/p
一、Windows+nginx+php环境配置:
1.下载php-5.3.16-nts-Win32-VC9-x86.zip(nts-非线程安全,nginx需要php的cgi模式运行),解压缩至d:\wnmp\php5
2.配置php.ini(可以将php.ini-development复制成php.ni,然后主要是4个位置配置):
extension_dir = "D:/wnmp/php5/ext"
extension=php_mysql.dll ...
cgi.fix_pathinfo=1
doc_root ="D:/wnmp/wwwroot"
3.下载nginx-1.3.4.zip Windows版,解压至d:\wnmp\nginx
4.配置nginx.conf,主要是站点目录和启用php:
location / { root D:/wnmp/wwwroot; #站点根目录 index index.html index.htm; }
# 去掉注释,指明目录 location ~ \.php$ { root D:/wnmp/wwwroot; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; include fastcgi_params; }
配置就这么简单。
二、运行
1.运行php:
@echooff echo Starting php... php5\php-cgi.exe -b 127.0.0.1:9000 -c D:/wnmp/php5/php.ini
2.运行nginx:
@echooff echo Starting nginx nginx.exe -p D:/wnmp/nginx
3.停止php和nginx:
@echooff echo Stopping nginx... taskkill /F /IM nginx.exe > nul echo Stopping PHP FastCGI... taskkill /F /IM php-cgi.exe > nul pause exit
三、性能测试
apache是xampp包,可能有些优化,nginx纯粹按上面的手工配置,感觉php-cgi不稳定
1.html测试:
ab -n 200000 -c 20 -k http://localhost/test/index.htm
apache,7945.38个请求每秒.
D:\xampp\apache\bin>ab -n 200000 -c 20 -k http://localhost/test/index.htm This is ApacheBench, Version 2.3 Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Licensed to The Apache Software Foundation, http://www.apache.org/ Benchmarking localhost (be patient) Completed 20000 requests Completed 40000 requests Completed 60000 requests Completed 80000 requests Completed 100000 requests Completed 120000 requests Completed 140000 requests Completed 160000 requests Completed 180000 requests Completed 200000 requests Finished 200000 requests Server Software: Apache/2.2.21 Server Hostname: localhost Server Port: 80 Document Path: /test/index.htm Document Length: 42354 bytes Concurrency Level: 20 Time taken for tests: 25.172 seconds Complete requests: 200000 Failed requests: 0 Write errors: 0 Keep-Alive requests: 198031 Total transferred: 8544538023 bytes HTML transferred: 8471021747 bytes Requests per second: 7945.38 [#/sec] (mean) Time per request: 2.517 [ms] (mean) Time per request: 0.126 [ms] (mean, across all concurrent requests) Transfer rate: 331492.01 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 0 0.2 0 16 Processing: 0 3 5.8 0 31 Waiting: 0 2 5.0 0 31 Total: 0 3 5.8 0 31 Percentage of the requests served within a certain time (ms) 50% 0 66% 0 75% 0 80% 0 90% 16 95% 16 98% 16 99% 16 100% 31 (longest request)
nginx,6986个请求每秒
D:\xampp\apache\bin>ab -n 200000 -c 20 -k http://localhost:8080/index.htm This is ApacheBench, Version 2.3 Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Licensed to The Apache Software Foundation, http://www.apache.org/ Benchmarking localhost (be patient) Completed 20000 requests Completed 40000 requests Completed 60000 requests Completed 80000 requests Completed 100000 requests Completed 120000 requests Completed 140000 requests Completed 160000 requests Completed 180000 requests Completed 200000 requests Finished 200000 requests Server Software: nginx/1.3.4 Server Hostname: localhost Server Port: 8080 Document Path: /index.htm Document Length: 42354 bytes Concurrency Level: 20 Time taken for tests: 28.641 seconds Complete requests: 200000 Failed requests: 0 Write errors: 0 Keep-Alive requests: 198012 Total transferred: 8519030702 bytes HTML transferred: 8471038962 bytes Requests per second: 6983.09 [#/sec] (mean) Time per request: 2.864 [ms] (mean) Time per request: 0.143 [ms] (mean, across all concurrent requests) Transfer rate: 290474.31 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 0 0.1 0 16 Processing: 0 3 6.1 0 47 Waiting: 0 2 4.8 0 31 Total: 0 3 6.1 0 47 Percentage of the requests served within a certain time (ms) 50% 0 66% 0 75% 0 80% 0 90% 16 95% 16 98% 16 99% 16 100% 47 (longest request)
2.php测试
ngnix下的php-cgi直接奔溃,apache大概600个请求每秒。
怎么感觉还是apache好啊!?配置上有问题?

ホットAIツール

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

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

Undress AI Tool
脱衣画像を無料で

Clothoff.io
AI衣類リムーバー

AI Hentai Generator
AIヘンタイを無料で生成します。

人気の記事

ホットツール

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

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

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

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

SublimeText3 Mac版
神レベルのコード編集ソフト(SublimeText3)

ホットトピック









はい、MySQLはWindows 7にインストールできます。MicrosoftはWindows 7のサポートを停止しましたが、MySQLは引き続き互換性があります。ただし、インストールプロセス中に次のポイントに注意する必要があります。WindowsのMySQLインストーラーをダウンロードしてください。 MySQL(コミュニティまたはエンタープライズ)の適切なバージョンを選択します。インストールプロセス中に適切なインストールディレクトリと文字セットを選択します。ルートユーザーパスワードを設定し、適切に保ちます。テストのためにデータベースに接続します。 Windows 7の互換性とセキュリティの問題に注意してください。サポートされているオペレーティングシステムにアップグレードすることをお勧めします。

Slow Photoshopの起動の問題を解決するには、次のような多面的なアプローチが必要です。ハードウェアのアップグレード(メモリ、ソリッドステートドライブ、CPU)。時代遅れまたは互換性のないプラグインのアンインストール。システムのゴミと過剰な背景プログラムを定期的にクリーンアップします。無関係なプログラムを慎重に閉鎖する。起動中に多数のファイルを開くことを避けます。

フロントエンド開発でWindowsのような実装方法...
![[ブラウザ]タブを閉じることと、JavaScriptを使用してブラウザ全体を閉じることを区別する方法は?](https://img.php.cn/upload/article/001/246/273/174338713695338.jpg?x-oss-process=image/resize,m_fill,h_207,w_330)
ブラウザのJavaScriptを使用して、タブを閉じることとブラウザ全体を区別する方法は?ブラウザの毎日の使用中、ユーザーは...

Photoshopで垂直ガイドを引く:ルーラービューを有効にします(ビュー>ルーラー)。マウスをルーラーの垂直エッジの上にホバリングし、次にカーソルが二重矢印を備えた垂直線になり、マウスを保持してドラッグして基準線を引き出します。ガイドをドラッグして[削除]をクリックするか、クロスにホバリングします。

MySQLのインストールエラーのソリューションは次のとおりです。1。システム環境を慎重に確認して、MySQL依存関係ライブラリの要件が満たされていることを確認します。異なるオペレーティングシステムとバージョンの要件は異なります。 2.エラーメッセージを慎重に読み取り、依存関係のインストールやSUDOコマンドの使用など、プロンプト(ライブラリファイルの欠落やアクセス許可など)に従って対応する測定値を取得します。 3.必要に応じて、ソースコードをインストールし、コンパイルログを慎重に確認してみてください。これには、一定量のLinuxの知識と経験が必要です。最終的に問題を解決する鍵は、システム環境とエラー情報を慎重に確認し、公式の文書を参照することです。

MySQLのインストール障害の主な理由は次のとおりです。1。許可の問題、管理者として実行するか、SUDOコマンドを使用する必要があります。 2。依存関係が欠落しており、関連する開発パッケージをインストールする必要があります。 3.ポート競合では、ポート3306を占めるプログラムを閉じるか、構成ファイルを変更する必要があります。 4.インストールパッケージが破損しているため、整合性をダウンロードして検証する必要があります。 5.環境変数は誤って構成されており、環境変数はオペレーティングシステムに従って正しく構成する必要があります。これらの問題を解決し、各ステップを慎重に確認して、MySQLを正常にインストールします。

端末からmysqlにアクセスできない場合は、次の理由があります。MySQLサービスが実行されていません。接続コマンドエラー;許可が不十分です。ファイアウォールは接続をブロックします。 mysql構成ファイルエラー。
