【MySQL64位】
http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.26-winx64.zip
【MySQL32位】
http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.26-win32.zip
【JDK 64位】
http://download.oracle.com/otn-pub/java/jdk/8u60-b27/jdk-8u60-windows-x64.exe?AuthParam=1441529858_771aeb3e7d7a6230692b72cf748b612f
【JDK 32位】
http://download.oracle.com/otn-pub/java/jdk/8u60-b27/jdk-8u60-windows-i586.exe?AuthParam=1441527399_24e27670f8213dc1f3b5c010921c5810
【Tomcat64位】
http://mirrors.cnnic.cn/apache/tomcat/tomcat-8/v8.0.26/bin/apache-tomcat-8.0.26-windows-x64.zip
【Tomcat32位】
http://mirrors.hust.edu.cn/apache/tomcat/tomcat-8/v8.0.26/bin/apache-tomcat-8.0.26-windows-x86.zip
解压MySQL、Tomcat,安装JDK
创建如下图的目录结构,jre是从JDK的安装目录(%JAVA_HOME%\jre)中拷贝过来的,mysql是直接解压缩下载的MySQL重命名根文件夹得到的,tomcat是直接解压下载的Tomcat重命名根文件夹得到的。
MySQL瘦身,解压后删除所有.pdb后缀内容,删除无用文件夹得到如下结构
下面是将javaWebConfig.bat拆分介绍,文章最后会附上完整版的javaWebConfig.bat
【javaWebConfig.bat】头部&停止已存在的mysql服务&删除mysql服务
@echo off & setlocal EnableDelayedExpansion
net stop mysql
sc delete mysql
GOTO check80
【javaWebConfig.bat】检查端口占用情况
:check80
echo check port 80...
for /f "tokens=3 delims=:, " %%i in ('netstat -ano') do (
if "%%i" == "80" GOTO 80used
)
GOTO configBegin
:80used
mshta vbscript:CreateObject("Wscript.Shell").popup("端口80被占用,请解除端口占用后重新启动",7,"提示",64)(window.close)
exit /B 2
【javaWebConfig.bat】配置启动mysql
:configBegin
rem config mysql
"%~dp0mysql\bin\mysqld" install
echo [mysql]>"%~dp0mysql\my.ini"
echo default-character-set=utf8>>"%~dp0mysql\my.ini"
echo [mysqld]>>"%~dp0mysql\my.ini"
echo port = 3306>>"%~dp0mysql\my.ini"
echo max_connections=200>>"%~dp0mysql\my.ini"
echo character-set-server=utf8>>"%~dp0mysql\my.ini"
echo default-storage-engine=INNODB>>"%~dp0mysql\my.ini"
echo sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES>>"%~dp0mysql\my.ini"
echo key_buffer_size = 256M>>"%~dp0mysql\my.ini"
echo max_allowed_packet = 1M>>"%~dp0mysql\my.ini"
echo table_open_cache = 256>>"%~dp0mysql\my.ini"
echo sort_buffer_size = 1M>>"%~dp0mysql\my.ini"
echo read_buffer_size = 1M>>"%~dp0mysql\my.ini"
echo read_rnd_buffer_size = 4M>>"%~dp0mysql\my.ini"
echo myisam_sort_buffer_size = 64M>>"%~dp0mysql\my.ini"
echo thread_cache_size = 8M>>"%~dp0mysql\my.ini"
echo query_cache_size = 16M>>"%~dp0mysql\my.ini"
echo basedir=%~dp0mysql>>"%~dp0mysql\my.ini"
echo datadir=%~dp0mysql\data>>"%~dp0mysql\my.ini"
net start mysql
【javaWebConfig.bat】配置启动tomcat
echo @echo off>"%~dp0tomcat\bin\temp.bat"
echo set JAVA_HOME=%~dp0jdk>>"%~dp0tomcat\bin\temp.bat"
echo set JRE_HOME=%~dp0jdk\jre>>"%~dp0tomcat\bin\temp.bat"
set j=0
for /f "usebackq delims=""" %%i in ("%~dp0tomcat\bin\setclasspath.bat") do (
set /a j+=1
set con!j!=%%i
call set a=%%con!j!%%
if !j! NEQ 1 (echo !a!>>"%~dp0tomcat\bin\temp.bat")
)
del "%~dp0tomcat\bin\setclasspath.bat"
ren "%~dp0tomcat\bin\temp.bat" setclasspath.bat
echo %~dp0
rem start tomcat
set CATALINA_HOME=%~dp0tomcat
call "%~dp0tomcat\bin\shutdown.bat"
call "%~dp0tomcat\bin\startup.bat"
将javaWebConfig.bat放在mysql、tomcat、jdk同目录下,右键以管理员身份运行即可
附:javaWebConfig.bat
@echo off & setlocal EnableDelayedExpansion
rem config prepare
net stop mysql
sc delete mysql
GOTO check80
rem check ports if available
:check80
echo check port 80...
for /f "tokens=3 delims=:, " %%i in ('netstat -ano') do (
if "%%i" == "80" GOTO 80used
)
GOTO check21
:80used
mshta vbscript:CreateObject("Wscript.Shell").popup("端口80被占用,请解除端口占用后重新启动",7,"提示",64)(window.close)
exit /B 2
:check21
echo check port 21...
for /f "tokens=3 delims=:, " %%i in ('netstat -ano') do (
if "%%i" == "21" GOTO 21used
)
GOTO check3131
:21used
mshta vbscript:CreateObject("Wscript.Shell").popup("端口21被占用,请解除端口占用后重新启动",7,"提示",64)(window.close)
exit /B 2
:check3131
echo check port 3131...
for /f "tokens=3 delims=:, " %%i in ('netstat -ano') do (
if "%%i" == "3131" GOTO 3131used
)
GOTO check5151
:3131used
mshta vbscript:CreateObject("Wscript.Shell").popup("端口3131被占用,请解除端口占用后重新启动",7,"提示",64)(window.close)
exit /B 2
:check5151
echo check port 5151...
for /f "tokens=3 delims=:, " %%i in ('netstat -ano') do (
if "%%i" == "5151" GOTO 5151used
)
GOTO configBegin
:5151used
mshta vbscript:CreateObject("Wscript.Shell").popup("端口5151被占用,请解除端口占用后重新启动",7,"提示",64)(window.close)
exit /B 2
rem config tomcat
echo @echo off>"%~dp0tomcat\bin\temp.bat"
echo set JAVA_HOME=%~dp0jdk>>"%~dp0tomcat\bin\temp.bat"
echo set JRE_HOME=%~dp0jdk\jre>>"%~dp0tomcat\bin\temp.bat"
set j=0
for /f "usebackq delims=""" %%i in ("%~dp0tomcat\bin\setclasspath.bat") do (
set /a j+=1
set con!j!=%%i
call set a=%%con!j!%%
if !j! NEQ 1 (echo !a!>>"%~dp0tomcat\bin\temp.bat")
)
del "%~dp0tomcat\bin\setclasspath.bat"
ren "%~dp0tomcat\bin\temp.bat" setclasspath.bat
echo %~dp0
rem start tomcat
set CATALINA_HOME=%~dp0tomcat
call "%~dp0tomcat\bin\shutdown.bat"
call "%~dp0tomcat\bin\startup.bat"