LoginSignup
2
0

More than 5 years have passed since last update.

WNMP環境を一気に起動/停止するbatファイル

Last updated at Posted at 2016-04-29

動機

nginx.confの記述は(おそらく)間違っていないのに、index.htmlは表示されるが、phpinfo.phpがタイムアウトする。
原因はfast-cgiが起動していなかったためだった。
毎回それぞれターミナルを立ち上げて(Nginx/php-cgi/mysql)起動するのが面倒だったので、一括で起動/停止するbatファイルがあれば楽だと思った。

前提

  • NGINX_HOME -> c:\nginx\
  • MYSQL_HOME -> c:"Program Files"\MySQL"MySQL Server 5.7"\
  • PHP_HOME -> c:\php\

なお、今回製造したbatファイルの配置先はNGINX_HOME直下とする。

実装

start.bat

start.bat
@echo off
rem ログファイルがあるのでホームディレクトリをNGINX_HOMEにする
cd /d %~dp0
rem 各exeファイルの起動
start .\nginx.exe
rem レスポンスが返らないため、バックグラウンドで実行
start /b c:\php\php-cgi.exe -b 127.0.0.1:9000
start C:\"Program Files"\MySQL\"MySQL Server 5.7"\bin\mysqld.exe
echo Starting nginx php-cgi mysql
echo .

stop.bat

stop.bat
@echo off
cd /d %~dp0
start c:\nginx\nginx.exe -s quit
taskkill /f /IM nginx.exe
taskkill /f /IM php-cgi.exe
c:\"Program Files"\MySQL\"MySQL Server 5.7"\bin\mysqladmin shutdown -u root
echo Stopped nginx php-cgi mysql
echo .

参考Webページ

2
0
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
2
0