上一步主要主要讲解在服务器中建立自己的hexo博客环境,最后达到可以远程访问,以及远程Git推送到github。这章主要讲解Tomcat环境的搭建,以及域名解析。到这里你的服务器以及可以被全世界的人民访问了。掌声送给自己吧!!
1.Tomcat介绍:
Tomcat 服务器是一个免费的开放源代码的Web 应用服务器,属于轻量级应用服务器,是开发和调试JSP/servlet 程序的首选。
2.安装jdk环境
tomcat是基于Java环境的,所以需要先安装java环境。
1. 下载jdk8的安装包:jdk-8u60-linux-x64.tar.gz;这是linux系统的安装包;
可以下载我分享的链接:百度云链接;
2. 安装jdk8步骤:万试万灵的步骤:
<code class="hljs ruby has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;"><span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>.复制文件到云服务器 sudo scp -r /home/peace/jdk-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">8</span>u6<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span>-linux-x64.tar.gz root<span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">@115</span>.<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">29.52</span>.<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">140</span><span class="hljs-symbol" style="color: rgb(0, 102, 102); box-sizing: border-box;">:/root/</span> <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2</span>登陆云服务器: <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">##创建文件夹,和解压文件</span> <span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">$ </span>mkdir /usr/lib/jvm <span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">$ </span>mv jdk-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">8</span>u6<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span>-linux-x64.tar.gz /usr/lib/jvm/ <span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">$ </span>cd /usr/lib/jvm/ <span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">$ </span> tar -zxvf jdk-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">8</span>u6<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span>-linux-x64.tar.gz <span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">$ </span>rm ./jdk-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">8</span>u6<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span>-linux-x64.tar.gz <span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">$mvjdk</span>-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">8</span>u6<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span> jdk8 <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">##配置环境变量:</span> <span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">$vi</span> /etc/environment 在environment中修改<span class="hljs-constant" style="box-sizing: border-box;">PATH</span>,追加<span class="hljs-constant" style="box-sizing: border-box;">JDK</span>路径,添加<span class="hljs-constant" style="box-sizing: border-box;">CLASSPATH</span>与<span class="hljs-constant" style="box-sizing: border-box;">JAVA_HOME</span>后如下: export <span class="hljs-constant" style="box-sizing: border-box;">JAVA_HOME</span>=<span class="hljs-regexp" style="color: rgb(0, 136, 0); box-sizing: border-box;">/usr/lib</span><span class="hljs-regexp" style="color: rgb(0, 136, 0); box-sizing: border-box;">/jvm/jdk</span>8 export <span class="hljs-constant" style="box-sizing: border-box;">JRE_HOME</span>=<span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">${</span><span class="hljs-constant" style="box-sizing: border-box;">JAVA_HOME</span>}/jre export <span class="hljs-constant" style="box-sizing: border-box;">CLASSPATH</span>=.<span class="hljs-symbol" style="color: rgb(0, 102, 102); box-sizing: border-box;">:</span><span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">${</span><span class="hljs-constant" style="box-sizing: border-box;">JAVA_HOME</span>}/<span class="hljs-symbol" style="color: rgb(0, 102, 102); box-sizing: border-box;">lib:</span><span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">${</span><span class="hljs-constant" style="box-sizing: border-box;">JRE_HOME</span>}/lib <span class="hljs-constant" style="box-sizing: border-box;">PATH</span>=<span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"/usr/lib/jvm/jdk8/bin:/usr/local/sbin:/usr/local/bin: /usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">##告诉系统,我们使用的sun的JDK,而非OpenJDK了:</span> <span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">$update</span>-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk8/bin/java <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">300</span> <span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">$update</span>-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk8/bin/javac <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">300</span> <span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">$update</span>-alternatives --config java <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">##测试一下运行 java -version</span> 可以看到版本号 : java version <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"1.8.0_60"</span> <span class="hljs-constant" style="box-sizing: border-box;">Java</span>(<span class="hljs-constant" style="box-sizing: border-box;">TM</span>) <span class="hljs-constant" style="box-sizing: border-box;">SE</span> <span class="hljs-constant" style="box-sizing: border-box;">Runtime</span> <span class="hljs-constant" style="box-sizing: border-box;">Environment</span> (build <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1.8</span>.<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0_60</span>-b27) <span class="hljs-constant" style="box-sizing: border-box;">Java</span> <span class="hljs-constant" style="box-sizing: border-box;">HotSpot</span>(<span class="hljs-constant" style="box-sizing: border-box;">TM</span>) <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">64</span>-<span class="hljs-constant" style="box-sizing: border-box;">Bit</span> <span class="hljs-constant" style="box-sizing: border-box;">Server</span> <span class="hljs-constant" style="box-sizing: border-box;">VM</span> (build <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">25.60</span>-b23, mixed mode)</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li><li style="box-sizing: border-box; padding: 0px 5px;">5</li><li style="box-sizing: border-box; padding: 0px 5px;">6</li><li style="box-sizing: border-box; padding: 0px 5px;">7</li><li style="box-sizing: border-box; padding: 0px 5px;">8</li><li style="box-sizing: border-box; padding: 0px 5px;">9</li><li style="box-sizing: border-box; padding: 0px 5px;">10</li><li style="box-sizing: border-box; padding: 0px 5px;">11</li><li style="box-sizing: border-box; padding: 0px 5px;">12</li><li style="box-sizing: border-box; padding: 0px 5px;">13</li><li style="box-sizing: border-box; padding: 0px 5px;">14</li><li style="box-sizing: border-box; padding: 0px 5px;">15</li><li style="box-sizing: border-box; padding: 0px 5px;">16</li><li style="box-sizing: border-box; padding: 0px 5px;">17</li><li style="box-sizing: border-box; padding: 0px 5px;">18</li><li style="box-sizing: border-box; padding: 0px 5px;">19</li><li style="box-sizing: border-box; padding: 0px 5px;">20</li><li style="box-sizing: border-box; padding: 0px 5px;">21</li><li style="box-sizing: border-box; padding: 0px 5px;">22</li><li style="box-sizing: border-box; padding: 0px 5px;">23</li><li style="box-sizing: border-box; padding: 0px 5px;">24</li><li style="box-sizing: border-box; padding: 0px 5px;">25</li><li style="box-sizing: border-box; padding: 0px 5px;">26</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li><li style="box-sizing: border-box; padding: 0px 5px;">5</li><li style="box-sizing: border-box; padding: 0px 5px;">6</li><li style="box-sizing: border-box; padding: 0px 5px;">7</li><li style="box-sizing: border-box; padding: 0px 5px;">8</li><li style="box-sizing: border-box; padding: 0px 5px;">9</li><li style="box-sizing: border-box; padding: 0px 5px;">10</li><li style="box-sizing: border-box; padding: 0px 5px;">11</li><li style="box-sizing: border-box; padding: 0px 5px;">12</li><li style="box-sizing: border-box; padding: 0px 5px;">13</li><li style="box-sizing: border-box; padding: 0px 5px;">14</li><li style="box-sizing: border-box; padding: 0px 5px;">15</li><li style="box-sizing: border-box; padding: 0px 5px;">16</li><li style="box-sizing: border-box; padding: 0px 5px;">17</li><li style="box-sizing: border-box; padding: 0px 5px;">18</li><li style="box-sizing: border-box; padding: 0px 5px;">19</li><li style="box-sizing: border-box; padding: 0px 5px;">20</li><li style="box-sizing: border-box; padding: 0px 5px;">21</li><li style="box-sizing: border-box; padding: 0px 5px;">22</li><li style="box-sizing: border-box; padding: 0px 5px;">23</li><li style="box-sizing: border-box; padding: 0px 5px;">24</li><li style="box-sizing: border-box; padding: 0px 5px;">25</li><li style="box-sizing: border-box; padding: 0px 5px;">26</li></ul>
3.安装Tomcat
- 下载tomcat的安装包:apache-tomcat-7.0.64.tar.gz
可以下载我分享的链接:csdn; - 安装步骤就是拷贝到云服务器进行解压就行:
<code class="hljs ruby has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;"><span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>.复制文件到云服务器 sudo scp -r /home/peace/apache-tomcat-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">7.0</span>.<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">64</span>.tar.gz root<span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">@115</span>.<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">29.52</span>.<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">140</span><span class="hljs-symbol" style="color: rgb(0, 102, 102); box-sizing: border-box;">:/root/peace/java</span> <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2</span>登陆云服务器: <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">##解压:</span> <span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">$ </span> tar -zxvf apache-tomcat-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">7.0</span>.<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">64</span>.tar.gz <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">##安装完成可以测试了:</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">#启动:</span> <span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">$ </span>cd /home/peace/java/apache-tomcat-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">7.0</span>.<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">64</span>/bin <span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">$ </span>./startup.sh </code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li><li style="box-sizing: border-box; padding: 0px 5px;">5</li><li style="box-sizing: border-box; padding: 0px 5px;">6</li><li style="box-sizing: border-box; padding: 0px 5px;">7</li><li style="box-sizing: border-box; padding: 0px 5px;">8</li><li style="box-sizing: border-box; padding: 0px 5px;">9</li><li style="box-sizing: border-box; padding: 0px 5px;">10</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li><li style="box-sizing: border-box; padding: 0px 5px;">5</li><li style="box-sizing: border-box; padding: 0px 5px;">6</li><li style="box-sizing: border-box; padding: 0px 5px;">7</li><li style="box-sizing: border-box; padding: 0px 5px;">8</li><li style="box-sizing: border-box; padding: 0px 5px;">9</li><li style="box-sizing: border-box; padding: 0px 5px;">10</li></ul>
环境搭建完毕大家可以通过ip访问到自己的网站了:
4.部署你的网站到tomcat:
- 最简单的部署:
将你的网站文件拷贝到:apache-tomcat-7.0.64/webapps下即可。如果你的网站含有动态工程,就必须重启tomcat,如果你的只是静态文件(如html等)直接通过ip访问就行;
访问方式:http://ip:8080/文件夹名/文件.html;
对于怎么部署网站到tocmact可以观看我的网站的另一篇文章:
里面有介绍,其实就是复制你的工程就行
5.给自己的网站绑定到你的服务器:域名解析
上一步主要主要讲解在服务器中建立自己的hexo博客环境,最后达到可以远程访问,以及远程Git推送到github。这章主要讲解Tomcat环境的搭建,以及域名解析。到这里你的服务器以及可以被全世界的人民访问了。掌声送给自己吧!!
1.Tomcat介绍:
Tomcat 服务器是一个免费的开放源代码的Web 应用服务器,属于轻量级应用服务器,是开发和调试JSP/servlet 程序的首选。
2.安装jdk环境
tomcat是基于Java环境的,所以需要先安装java环境。
1. 下载jdk8的安装包:jdk-8u60-linux-x64.tar.gz;这是linux系统的安装包;
可以下载我分享的链接:百度云链接;
2. 安装jdk8步骤:万试万灵的步骤:
<code class="hljs ruby has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;"><span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>.复制文件到云服务器 sudo scp -r /home/peace/jdk-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">8</span>u6<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span>-linux-x64.tar.gz root<span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">@115</span>.<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">29.52</span>.<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">140</span><span class="hljs-symbol" style="color: rgb(0, 102, 102); box-sizing: border-box;">:/root/</span> <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2</span>登陆云服务器: <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">##创建文件夹,和解压文件</span> <span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">$ </span>mkdir /usr/lib/jvm <span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">$ </span>mv jdk-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">8</span>u6<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span>-linux-x64.tar.gz /usr/lib/jvm/ <span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">$ </span>cd /usr/lib/jvm/ <span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">$ </span> tar -zxvf jdk-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">8</span>u6<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span>-linux-x64.tar.gz <span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">$ </span>rm ./jdk-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">8</span>u6<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span>-linux-x64.tar.gz <span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">$mvjdk</span>-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">8</span>u6<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span> jdk8 <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">##配置环境变量:</span> <span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">$vi</span> /etc/environment 在environment中修改<span class="hljs-constant" style="box-sizing: border-box;">PATH</span>,追加<span class="hljs-constant" style="box-sizing: border-box;">JDK</span>路径,添加<span class="hljs-constant" style="box-sizing: border-box;">CLASSPATH</span>与<span class="hljs-constant" style="box-sizing: border-box;">JAVA_HOME</span>后如下: export <span class="hljs-constant" style="box-sizing: border-box;">JAVA_HOME</span>=<span class="hljs-regexp" style="color: rgb(0, 136, 0); box-sizing: border-box;">/usr/lib</span><span class="hljs-regexp" style="color: rgb(0, 136, 0); box-sizing: border-box;">/jvm/jdk</span>8 export <span class="hljs-constant" style="box-sizing: border-box;">JRE_HOME</span>=<span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">${</span><span class="hljs-constant" style="box-sizing: border-box;">JAVA_HOME</span>}/jre export <span class="hljs-constant" style="box-sizing: border-box;">CLASSPATH</span>=.<span class="hljs-symbol" style="color: rgb(0, 102, 102); box-sizing: border-box;">:</span><span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">${</span><span class="hljs-constant" style="box-sizing: border-box;">JAVA_HOME</span>}/<span class="hljs-symbol" style="color: rgb(0, 102, 102); box-sizing: border-box;">lib:</span><span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">${</span><span class="hljs-constant" style="box-sizing: border-box;">JRE_HOME</span>}/lib <span class="hljs-constant" style="box-sizing: border-box;">PATH</span>=<span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"/usr/lib/jvm/jdk8/bin:/usr/local/sbin:/usr/local/bin: /usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">##告诉系统,我们使用的sun的JDK,而非OpenJDK了:</span> <span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">$update</span>-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk8/bin/java <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">300</span> <span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">$update</span>-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk8/bin/javac <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">300</span> <span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">$update</span>-alternatives --config java <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">##测试一下运行 java -version</span> 可以看到版本号 : java version <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"1.8.0_60"</span> <span class="hljs-constant" style="box-sizing: border-box;">Java</span>(<span class="hljs-constant" style="box-sizing: border-box;">TM</span>) <span class="hljs-constant" style="box-sizing: border-box;">SE</span> <span class="hljs-constant" style="box-sizing: border-box;">Runtime</span> <span class="hljs-constant" style="box-sizing: border-box;">Environment</span> (build <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1.8</span>.<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0_60</span>-b27) <span class="hljs-constant" style="box-sizing: border-box;">Java</span> <span class="hljs-constant" style="box-sizing: border-box;">HotSpot</span>(<span class="hljs-constant" style="box-sizing: border-box;">TM</span>) <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">64</span>-<span class="hljs-constant" style="box-sizing: border-box;">Bit</span> <span class="hljs-constant" style="box-sizing: border-box;">Server</span> <span class="hljs-constant" style="box-sizing: border-box;">VM</span> (build <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">25.60</span>-b23, mixed mode)</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li><li style="box-sizing: border-box; padding: 0px 5px;">5</li><li style="box-sizing: border-box; padding: 0px 5px;">6</li><li style="box-sizing: border-box; padding: 0px 5px;">7</li><li style="box-sizing: border-box; padding: 0px 5px;">8</li><li style="box-sizing: border-box; padding: 0px 5px;">9</li><li style="box-sizing: border-box; padding: 0px 5px;">10</li><li style="box-sizing: border-box; padding: 0px 5px;">11</li><li style="box-sizing: border-box; padding: 0px 5px;">12</li><li style="box-sizing: border-box; padding: 0px 5px;">13</li><li style="box-sizing: border-box; padding: 0px 5px;">14</li><li style="box-sizing: border-box; padding: 0px 5px;">15</li><li style="box-sizing: border-box; padding: 0px 5px;">16</li><li style="box-sizing: border-box; padding: 0px 5px;">17</li><li style="box-sizing: border-box; padding: 0px 5px;">18</li><li style="box-sizing: border-box; padding: 0px 5px;">19</li><li style="box-sizing: border-box; padding: 0px 5px;">20</li><li style="box-sizing: border-box; padding: 0px 5px;">21</li><li style="box-sizing: border-box; padding: 0px 5px;">22</li><li style="box-sizing: border-box; padding: 0px 5px;">23</li><li style="box-sizing: border-box; padding: 0px 5px;">24</li><li style="box-sizing: border-box; padding: 0px 5px;">25</li><li style="box-sizing: border-box; padding: 0px 5px;">26</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li><li style="box-sizing: border-box; padding: 0px 5px;">5</li><li style="box-sizing: border-box; padding: 0px 5px;">6</li><li style="box-sizing: border-box; padding: 0px 5px;">7</li><li style="box-sizing: border-box; padding: 0px 5px;">8</li><li style="box-sizing: border-box; padding: 0px 5px;">9</li><li style="box-sizing: border-box; padding: 0px 5px;">10</li><li style="box-sizing: border-box; padding: 0px 5px;">11</li><li style="box-sizing: border-box; padding: 0px 5px;">12</li><li style="box-sizing: border-box; padding: 0px 5px;">13</li><li style="box-sizing: border-box; padding: 0px 5px;">14</li><li style="box-sizing: border-box; padding: 0px 5px;">15</li><li style="box-sizing: border-box; padding: 0px 5px;">16</li><li style="box-sizing: border-box; padding: 0px 5px;">17</li><li style="box-sizing: border-box; padding: 0px 5px;">18</li><li style="box-sizing: border-box; padding: 0px 5px;">19</li><li style="box-sizing: border-box; padding: 0px 5px;">20</li><li style="box-sizing: border-box; padding: 0px 5px;">21</li><li style="box-sizing: border-box; padding: 0px 5px;">22</li><li style="box-sizing: border-box; padding: 0px 5px;">23</li><li style="box-sizing: border-box; padding: 0px 5px;">24</li><li style="box-sizing: border-box; padding: 0px 5px;">25</li><li style="box-sizing: border-box; padding: 0px 5px;">26</li></ul>
3.安装Tomcat
- 下载tomcat的安装包:apache-tomcat-7.0.64.tar.gz
可以下载我分享的链接:csdn; - 安装步骤就是拷贝到云服务器进行解压就行:
<code class="hljs ruby has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;"><span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>.复制文件到云服务器 sudo scp -r /home/peace/apache-tomcat-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">7.0</span>.<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">64</span>.tar.gz root<span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">@115</span>.<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">29.52</span>.<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">140</span><span class="hljs-symbol" style="color: rgb(0, 102, 102); box-sizing: border-box;">:/root/peace/java</span> <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2</span>登陆云服务器: <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">##解压:</span> <span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">$ </span> tar -zxvf apache-tomcat-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">7.0</span>.<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">64</span>.tar.gz <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">##安装完成可以测试了:</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">#启动:</span> <span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">$ </span>cd /home/peace/java/apache-tomcat-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">7.0</span>.<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">64</span>/bin <span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">$ </span>./startup.sh </code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li><li style="box-sizing: border-box; padding: 0px 5px;">5</li><li style="box-sizing: border-box; padding: 0px 5px;">6</li><li style="box-sizing: border-box; padding: 0px 5px;">7</li><li style="box-sizing: border-box; padding: 0px 5px;">8</li><li style="box-sizing: border-box; padding: 0px 5px;">9</li><li style="box-sizing: border-box; padding: 0px 5px;">10</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li><li style="box-sizing: border-box; padding: 0px 5px;">5</li><li style="box-sizing: border-box; padding: 0px 5px;">6</li><li style="box-sizing: border-box; padding: 0px 5px;">7</li><li style="box-sizing: border-box; padding: 0px 5px;">8</li><li style="box-sizing: border-box; padding: 0px 5px;">9</li><li style="box-sizing: border-box; padding: 0px 5px;">10</li></ul>
环境搭建完毕大家可以通过ip访问到自己的网站了:
4.部署你的网站到tomcat:
- 最简单的部署:
将你的网站文件拷贝到:apache-tomcat-7.0.64/webapps下即可。如果你的网站含有动态工程,就必须重启tomcat,如果你的只是静态文件(如html等)直接通过ip访问就行;
访问方式:http://ip:8080/文件夹名/文件.html;
对于怎么部署网站到tocmact可以观看我的网站的另一篇文章:
里面有介绍,其实就是复制你的工程就行