Heim  >  Artikel  >  Datenbank  >  linux 之休验(JDK7+Tomcat7+MySQL5.5)部署环境_MySQL

linux 之休验(JDK7+Tomcat7+MySQL5.5)部署环境_MySQL

WBOY
WBOYOriginal
2016-06-01 13:06:23906Durchsuche

Tomcat7Tomcat

------------------------------------------------------------------------------------------------------------------
JDK
<span class="indent">  </span><span class="number">0</span>:下载JDK http:<span class="regexp">//www</span>.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-<span class="number">1880260</span>.html
<span class="indent">  </span><span class="number">1</span>:卸载(root用户)
<span class="indent">  </span><span class="indent">  </span><span class="number">1.0</span>:查询已安装的jdk		
<span class="indent">  </span><span class="indent">  </span><span class="indent">  </span><span class="comment"># rpm -qa|grep jdk	</span>
<span class="indent">  </span><span class="indent">  </span><span class="indent">  </span>  <span class="variable">**</span>*
<span class="indent">  </span><span class="indent">  </span><span class="indent">  </span><span class="comment"># rpm -qa|grep java</span>
<span class="indent">  </span><span class="indent">  </span><span class="indent">  </span>  <span class="variable">**</span>*
<span class="indent">  </span><span class="indent">  </span><span class="number">1.1</span>:根据名称移除(-e表示删除,-nodeps表示强制删除防止JDK与程序关联,导致删除失败!)
<span class="indent">  </span><span class="indent">  </span><span class="indent">  </span><span class="comment"># rpm -e -nodeps	***</span>
<span class="indent">  </span><span class="indent">  </span><span class="number">1.2</span>:再运行java -version;如果提示-bash: java -version: command <span class="keyword">not</span> found则不用继续下面方案,jdk删除成功。
<span class="indent">  </span><span class="indent">  </span><span class="number">1.3</span>:手动删除文件夹(-f表示删除整个文件夹及子目录)
<span class="indent">  </span><span class="indent">  </span><span class="indent">  </span><span class="comment"># rm -f /usr/bin/java </span>
<span class="indent">  </span><span class="indent">  </span><span class="indent">  </span><span class="comment"># rm -f /usr/bin/javac </span>
<span class="indent">  </span><span class="indent">  </span><span class="indent">  </span><span class="comment"># rm -f /etc/alternatives/java </span>
<span class="indent">  </span><span class="indent">  </span><span class="indent">  </span><span class="comment"># rm -f /etc/alternatives/javac</span>
<span class="indent">  </span><span class="number">2</span>:安装(root用户)
<span class="indent">  </span><span class="indent">  </span><span class="number">2.1</span>:给每个用户添加操作权限
<span class="indent">  </span><span class="indent">  </span><span class="indent">  </span><span class="comment"># chomd +x jdk_*.*.*.rpm</span>
<span class="indent">  </span><span class="indent">  </span><span class="number">2.2</span>:安装JDK
<span class="indent">  </span><span class="indent">  </span><span class="indent">  </span><span class="comment"># rpm -ivh jdk_*.*.*.rpm</span>
<span class="indent">  </span><span class="indent">  </span><span class="number">2.3</span>:修改如下配置文件
<span class="indent">  </span><span class="indent">  </span><span class="indent">  </span>|--<span class="comment"># cd /	切换到root目录下</span>
<span class="indent">  </span><span class="indent">  </span><span class="indent">  </span>|--<span class="comment"># cd ect	配置文件目录</span>
<span class="indent">  </span><span class="indent">  </span><span class="indent">  </span>|--<span class="comment"># vi ./profile	修改/etc/profile文件 (全局所有用户)</span>
<span class="indent">  </span><span class="indent">  </span><span class="indent">  </span>|--<span class="comment">#打开profile后,按i进入编辑模式,末尾加入:</span>
<span class="indent">  </span><span class="indent">  </span><span class="indent">  </span><span class="indent">  </span><span class="comment">#set java environment</span>
<span class="indent">  </span><span class="indent">  </span><span class="indent">  </span><span class="indent">  </span>export JAVA_HOME=<span class="regexp">/usr/share</span><span class="regexp">/jdk1.7.0_60
<span class="indent">  </span><span class="indent">  </span><span class="indent">  </span><span class="indent">  </span>export PATH=$JAVA_HOME/bin</span>:<span class="variable">$PATH</span>
<span class="indent">  </span><span class="indent">  </span><span class="indent">  </span><span class="indent">  </span>export CLASSPATH=.:<span class="variable">$JAVA_HOME</span>/lib/dt.jar:<span class="variable">$JAVA_HOME</span>/lib/tools.jar
<span class="indent">  </span><span class="indent">  </span><span class="indent">  </span>|--<span class="comment">#按catl+c进入Normall模式,输入#wq保存并关闭</span>
<span class="indent">  </span><span class="indent">  </span><span class="indent">  </span>|--<span class="comment"># find -name .bash_profile	找到bash_profile所在位置</span>
<span class="indent">  </span><span class="indent">  </span><span class="indent">  </span>.<span class="regexp">/skel/</span>.bash_profile
<span class="indent">  </span><span class="indent">  </span><span class="indent">  </span>|--<span class="comment"># vi ./skel/.bash_profile	.修改.bash_profile文件 (某个用户权限使用这些环境变量)</span>
<span class="indent">  </span><span class="indent">  </span><span class="indent">  </span>|--<span class="comment">#打开profile后,按i进入编辑模式,末尾加入:</span>
<span class="indent">  </span><span class="indent">  </span><span class="indent">  </span><span class="indent">  </span>export JAVA_HOME=<span class="regexp">/usr/java</span><span class="regexp">/jdk1.7.0_60			#先确认下你的jdk是否也是这个目录
<span class="indent">  </span><span class="indent">  </span><span class="indent">  </span><span class="indent">  </span>export PATH=$JAVA_HOME/bin</span>:<span class="variable">$PATH</span>
<span class="indent">  </span><span class="indent">  </span><span class="indent">  </span><span class="indent">  </span>export CLASSPATH=.:<span class="variable">$JAVA_HOME</span>/lib/dt.jar:<span class="variable">$JAVA_HOME</span>/lib/tools.jar
<span class="indent">  </span><span class="indent">  </span><span class="indent">  </span>|--<span class="comment">#按catl+c进入Normall模式,输入#wq保存并关闭</span>
<span class="indent">  </span><span class="indent">  </span><span class="indent">  </span>|--<span class="comment">#source /etc/profile执行后生效</span>
<span class="indent">  </span><span class="indent">  </span><span class="number">2.4</span>:测试
<span class="indent">  </span><span class="indent">  </span>[root<span class="variable">@localhost</span> ~]<span class="comment"># vim Hello.java</span>
<span class="indent">  </span><span class="indent">  </span><span class="indent">  </span><span class="indent">  </span><span class="indent">  </span>public class Hello{
<span class="indent">  </span><span class="indent">  </span><span class="indent">  </span><span class="indent">  </span><span class="indent">  </span><span class="indent">  </span>public static void main(String[] args){
<span class="indent">  </span><span class="indent">  </span><span class="indent">  </span><span class="indent">  </span><span class="indent">  </span><span class="indent">  </span><span class="indent">  </span>System.out.println(<span class="string">"hello World"</span>);
<span class="indent">  </span><span class="indent">  </span><span class="indent">  </span><span class="indent">  </span><span class="indent">  </span><span class="indent">  </span>}

<span class="indent">  </span><span class="indent">  </span><span class="indent">  </span><span class="indent">  </span><span class="indent">  </span>}
<span class="indent">  </span><span class="indent">  </span>[root<span class="variable">@localhost</span> ~]<span class="comment"># javac Hello.java</span>
<span class="indent">  </span><span class="indent">  </span>[root<span class="variable">@localhost</span> ~]<span class="comment"># java Hello</span>
<span class="indent">  </span><span class="indent">  </span>hello World
<span class="indent">  </span><span class="number">3</span>:更多详细http:<span class="regexp">//www</span>.<span class="number">2</span>cto.com/os/<span class="number">201211</span>/<span class="number">171035</span>.html
------------------------------------------------------------------------------------------------------------------
Tomcat
<span class="indent">  </span><span class="number">0</span>:下载地址:http:<span class="regexp">//tomcat</span>.apache.org/download-<span class="number">70</span>.cgi
<span class="indent">  </span><span class="number">1</span>:解压tomcat
<span class="indent">  </span><span class="indent">  </span><span class="comment">#unzip  xxx.zip		#zip解压</span>
<span class="indent">  </span><span class="indent">  </span><span class="comment">#tar -zxvf xxx.tar.gx	#tar解压</span>
<span class="indent">  </span><span class="number">2</span>:然后将tomcat移动到/usr/java/tomcat[version];(个人建议)
<span class="indent">  </span><span class="indent">  </span><span class="comment">#mv -rf tomcat_x.x.x /usr/java/tomcat[version]</span>
<span class="indent">  </span><span class="number">3</span>:配置tomcat环境(可选)  
<span class="indent">  </span><span class="indent">  </span><span class="comment">#vim /etc/profile		=#在末尾加入如下配置</span>
<span class="indent">  </span><span class="indent">  </span>export TOMCAT_HOME=<span class="regexp">/usr/java</span><span class="regexp">/tomcat7/bin</span>
<span class="indent">  </span><span class="indent">  </span>export CATALINA_HOME=<span class="regexp">/usr/java</span><span class="regexp">/tomcat7		
<span class="indent">  </span><span class="indent">  </span>#其用途:可以在任意目录下执行./shutdown</span>.sh或.<span class="regexp">/startup.sh
<span class="indent">  </span>4:测试访问:http:/</span><span class="regexp">/localhost:8080	
<span class="indent">  </span>5:然后你可将web项目打包成zip,通过在window下cmd中通过pscp xx user@ip:/</span><span class="regexp">/xx/</span><span class="regexp">/xx 将项目上传到服务器。然后再到服务器解压,再重启tomcat,便可运行啦..........呼呼
<span class="indent">  </span>5:详细参考:http:/</span><span class="regexp">/blog.sina.com.cn/s</span><span class="regexp">/blog_866c5a5d0101cn1l.html
------------------------------------------------------------------------------------------------------------------
MySql
<span class="indent">  </span>0:下载网站:http:/</span><span class="regexp">/dev.mysql.com/downloads</span><span class="regexp">/mysql/</span><span class="number">5.1</span>.html
<span class="indent">  </span><span class="number">1</span>:安装server	[root<span class="variable">@localhost</span> ~]<span class="comment"># rpm -ivh xxx.emp;</span>
<span class="indent">  </span><span class="number">2</span>:安装client	[root<span class="variable">@localhost</span> ~]<span class="comment"># rpm -ivh xxx.emp;</span>
<span class="indent">  </span><span class="number">3</span>:MySql重要目录
<span class="indent">  </span><span class="indent">  </span>|--数据库目录		[root<span class="variable">@localhost</span> ~]<span class="comment"># /var/lib/mysql</span>
<span class="indent">  </span><span class="indent">  </span>|--配置文件		[root<span class="variable">@localhost</span> ~]<span class="comment"># /usr/share/mysql(mysql.server及配置文件)</span>
<span class="indent">  </span><span class="indent">  </span>|--相关命令		[root<span class="variable">@localhost</span> ~]<span class="comment"># /usr/bin/(mysqladmin|mysqldump)</span>
<span class="indent">  </span><span class="indent">  </span>|--启动脚本		[root<span class="variable">@localhost</span> ~]<span class="comment"># /etc/rc.d/init.d(启动脚本文件mysql的目录)</span>
<span class="indent">  </span><span class="number">4</span>:启动mysql	[root<span class="variable">@localhost</span> ~]<span class="comment"># /etc/init.d/mysql start</span>
<span class="indent">  </span><span class="number">5</span>:查看使用中的端口号(如果有<span class="number">3306</span>则启动成功)
<span class="indent">  </span><span class="indent">  </span>[root<span class="variable">@localhost</span> ~]<span class="comment"># netstat -nat</span>
<span class="indent">  </span><span class="indent">  </span>Active Internet connections (servers <span class="keyword">and</span> established)
<span class="indent">  </span><span class="indent">  </span>Proto Recv-Q Send-Q Local Address               Foreign Address             State      
<span class="indent">  </span><span class="indent">  </span>tcp        <span class="number">0</span>      <span class="number">0</span> <span class="number">127.0</span>.<span class="number">0</span>.<span class="number">1</span>:<span class="number">2208</span>              <span class="number">0</span>.<span class="number">0</span>.<span class="number">0</span>.<span class="number">0</span>:*                   LISTEN      
<span class="indent">  </span><span class="indent">  </span>tcp        <span class="number">0</span>      <span class="number">0</span> <span class="number">0</span>.<span class="number">0</span>.<span class="number">0</span>.<span class="number">0</span>:<span class="number">776</span>                 <span class="number">0</span>.<span class="number">0</span>.<span class="number">0</span>.<span class="number">0</span>:*                   LISTEN      
<span class="indent">  </span><span class="indent">  </span>tcp        <span class="number">0</span>      <span class="number">0</span> <span class="number">0</span>.<span class="number">0</span>.<span class="number">0</span>.<span class="number">0</span>:<span class="number">3306</span>                <span class="number">0</span>.<span class="number">0</span>.<span class="number">0</span>.<span class="number">0</span>:*                   LISTEN      
<span class="indent">  </span><span class="indent">  </span>tcp        <span class="number">0</span>      <span class="number">0</span> <span class="number">0</span>.<span class="number">0</span>.<span class="number">0</span>.<span class="number">0</span>:<span class="number">111</span>                 <span class="number">0</span>.<span class="number">0</span>.<span class="number">0</span>.<span class="number">0</span>:*                   LISTEN      
<span class="indent">  </span><span class="number">6</span>:设置密码
<span class="indent">  </span><span class="indent">  </span>安装完mysql有一个默认用户root,密码是没有的。
<span class="indent">  </span><span class="indent">  </span>[root<span class="variable">@localhost</span> ~]<span class="comment"># /usr/bin/mysqladmin/ -u root -p password 123456</span>
<span class="indent">  </span><span class="number">7</span>:登录到mysql
<span class="indent">  </span><span class="indent">  </span>[root<span class="variable">@localhost</span> ~]<span class="comment"># mysql -u root -p 123456</span>
<span class="indent">  </span><span class="number">8</span>:查询数据库
<span class="indent">  </span><span class="indent">  </span>show databases
<span class="indent">  </span><span class="number">9</span>:查询表
<span class="indent">  </span><span class="indent">  </span><span class="keyword">use</span> test
<span class="indent">  </span><span class="indent">  </span>show tables
<span class="indent">  </span><span class="number">10</span>:停止mysql
<span class="indent">  </span><span class="indent">  </span>[root<span class="variable">@localhost</span> ~]<span class="comment"># /usr/bin/mysqladmin -u root -p shutdown</span>
<span class="indent">  </span><span class="number">11</span>:常见原因
<span class="indent">  </span><span class="indent">  </span><span class="number">11.1</span>:linuxe启动后<span class="number">13</span>:<span class="number">07</span>mysql,在windows下无法连接linuxe的mysql.
<span class="indent">  </span><span class="indent">  </span><span class="indent">  </span>报错:<span class="number">1130</span>-host ... is <span class="keyword">not</span> allowed to <span class="keyword">connect</span> to this MySql server 开放mysql远程连接 不使用localhost
<span class="indent">  </span><span class="indent">  </span>      解决方案http:<span class="regexp">//www</span>.cnblogs.com/xyzdw/archive/<span class="number">2011</span>/08/<span class="number">11</span>/<span class="number">2135227</span>.html 我是通过下面来解决的
<span class="indent">  </span><span class="indent">  </span><span class="indent">  </span>GRANT ALL PRIVILEGES ON <span class="variable">*.</span>* TO <span class="string">'用户名'</span><span class="variable">@'</span><span class="variable">%'</span> IDENTIFIED BY <span class="string">'密码'</span> WITH GRANT OPTION;
<span class="indent">  </span><span class="indent">  </span><span class="indent">  </span>FLUSH   PRIVILEGES;
<span class="indent">  </span><span class="number">12</span>:详细参考:http:<span class="regexp">//www</span>.t086.com/article/<span class="number">638</span>
------------------------------------------------------------------------------------------------------------------

在学习中,我们都会遇到很多奇葩问题,但这么奇葩问题是让我们提升的宝贵经验。所以,请不要太过着急、自责。耐心的静下来冷静解决问题。

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn