LoginSignup
45
48

More than 5 years have passed since last update.

nginx > (windows) nginxのインストールとサービス常駐

Last updated at Posted at 2018-01-25

本家サイト

Welcome to NGINX Wiki! | NGINX

インストールガイド

Install | NGINX

インストーラー

nginx: download

Installation:

cd c:\
unzip nginx-1.2.3.zip
ren nginx-1.2.3 nginx
cd nginx
start nginx

startとは:
現在のウインドウとは別のコマンドプロンプトウィンドウを起動して、指定したプログラムまたはコマンドを実行する。

startコマンドで何も表示されなければ、ポートがかぶっている可能性もあります。(IIS等)

image

ローカルにアクセスして、「Welcome to nginx!」が出ればOK
http://localhost/

停止

nginx -s stop
nginx -s quit
nginx -s start

サービス

nginxが動いていれば停止しときます。

nginx -s stop

winswを使ってサービス化します。

以下から最新版をダウンロードし、C:\nginxの直下に置く
Index of releases/com/sun/winsw/winsw

名称をリネームする。名称はなんでもOK
image

バージョンが分かるように
winsw-2.1.2-nginxsvc.exeにリネームしました。

winsw-2.1.2-nginxsvc.xmlを作成

winsw-2.1.2-nginxsvc.xml
<service>
  <id>nginx</id>
  <name>nginx</name>
  <description>nginx</description>
  <logpath>c:\nginx\logs</logpath>
  <logmode>roll</logmode>
  <depend></depend>
  <executable>c:\nginx\nginx.exe</executable>
  <startargument></startargument>
  <stopexecutable>c:\nginx\nginx.exe</stopexecutable>
  <stopargument>-s</stopargument>
  <stopargument>stop</stopargument>
</service>

以下のような構成になっています。
image

管理者権限でコマンドプロンプトを開き、以下のコマンドを叩く

C:\nginx\winsw-2.1.2-nginxsvc.exe install

以下のようにでればOK

C:\nginx>winsw-2.1.2-nginxsvc.exe install
2018-01-25 11:06:46,673 INFO  - Installing the service with id 'nginx'

サービスを削除する場合には以下

C:\nginx\winsw-2.1.2-nginxsvc.exe uninstall
45
48
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
45
48