利用腾讯云服务器Centos7+Tomcat搭建个人网站

之前看腾讯云服务器学生打折,就买了一个,花了较长的时间等待域名备案,最近有些时间便琢磨着搭建一个个人网站,弄个博客,之后毕设也是web系统可以放上去,还是美滋滋,再次记录一下,大体只是为了自己记忆,如有幸被人路过看到,仅供参考。

首先是申请云服务器和备案,个人使用的是腾讯云,无他,那段时间(2017年11月的样子)这个是大厂里最便宜的(对在校生有优惠)。申请流程在官网一步到位,就是备案耗了很久,大概花了两周多。备案需要去线下拍照,还好实习在帝都,找了家附近的就搞定了。


看着这四个1,成了。

接下来是在centos上搭建网站了。当时自己琢磨了段时间python3,所以打算用django,但是linux实在太复杂了,搭建服务器也是为了练练linux。得,熟悉了各种命令行,长时间的面对Baidu&Google安装配置,没弄出个所以然来。

So,还是JAVA吧。大二学的,大四捞起来。从python转换到JAVA还是比当初第一次接触编程语言轻松多了,看了看菜鸟教程唤醒沉睡的记忆,刷了刷LeetCode练练手,面对百度和谷歌,打开XShell直接开搞!

第一步肯定是配置JDK:

# yum search java|grep jdk
结果:

java-1.6.0-openjdk.x86_64 : OpenJDK Runtime Environment
java-1.6.0-openjdk-demo.x86_64 : OpenJDK Demos
java-1.6.0-openjdk-devel.x86_64 : OpenJDK Development Environment
java-1.6.0-openjdk-javadoc.x86_64 : OpenJDK API Documentation
java-1.6.0-openjdk-src.x86_64 : OpenJDK Source Bundle
java-1.7.0-openjdk.x86_64 : OpenJDK Runtime Environment
java-1.7.0-openjdk-accessibility.x86_64 : OpenJDK accessibility connector
java-1.7.0-openjdk-demo.x86_64 : OpenJDK Demos
java-1.7.0-openjdk-devel.x86_64 : OpenJDK Development Environment
java-1.7.0-openjdk-headless.x86_64 : The OpenJDK runtime environment without
java-1.7.0-openjdk-javadoc.noarch : OpenJDK API Documentation
java-1.7.0-openjdk-src.x86_64 : OpenJDK Source Bundle
java-1.8.0-openjdk.i686 : OpenJDK Runtime Environment
java-1.8.0-openjdk.x86_64 : OpenJDK Runtime Environment
java-1.8.0-openjdk-accessibility.i686 : OpenJDK accessibility connector
java-1.8.0-openjdk-accessibility.x86_64 : OpenJDK accessibility connector
java-1.8.0-openjdk-accessibility-debug.i686 : OpenJDK accessibility connector
java-1.8.0-openjdk-accessibility-debug.x86_64 : OpenJDK accessibility connector
java-1.8.0-openjdk-debug.i686 : OpenJDK Runtime Environment with full debug on
java-1.8.0-openjdk-debug.x86_64 : OpenJDK Runtime Environment with full debug on
java-1.8.0-openjdk-demo.i686 : OpenJDK Demos
java-1.8.0-openjdk-demo.x86_64 : OpenJDK Demos
java-1.8.0-openjdk-demo-debug.i686 : OpenJDK Demos with full debug on
java-1.8.0-openjdk-demo-debug.x86_64 : OpenJDK Demos with full debug on
java-1.8.0-openjdk-devel.i686 : OpenJDK Development Environment
java-1.8.0-openjdk-devel.x86_64 : OpenJDK Development Environment
java-1.8.0-openjdk-devel-debug.i686 : OpenJDK Development Environment with full
java-1.8.0-openjdk-devel-debug.x86_64 : OpenJDK Development Environment with
java-1.8.0-openjdk-headless.i686 : OpenJDK Runtime Environment
java-1.8.0-openjdk-headless.x86_64 : OpenJDK Runtime Environment
java-1.8.0-openjdk-headless-debug.i686 : OpenJDK Runtime Environment with full
java-1.8.0-openjdk-headless-debug.x86_64 : OpenJDK Runtime Environment with full
java-1.8.0-openjdk-javadoc.noarch : OpenJDK API Documentation
java-1.8.0-openjdk-javadoc-debug.noarch : OpenJDK API Documentation for packages
java-1.8.0-openjdk-javadoc-zip.noarch : OpenJDK API Documentation compressed in
java-1.8.0-openjdk-javadoc-zip-debug.noarch : OpenJDK API Documentation
java-1.8.0-openjdk-src.i686 : OpenJDK Source Bundle
java-1.8.0-openjdk-src.x86_64 : OpenJDK Source Bundle
java-1.8.0-openjdk-src-debug.i686 : OpenJDK Source Bundle for packages with
java-1.8.0-openjdk-src-debug.x86_64 : OpenJDK Source Bundle for packages with
ldapjdk.noarch : The Mozilla LDAP Java SDK
看了看,当然jdk1.8

# yum install java-1.7.0-openjdk
测试一波

# java -version

然后我也很无脑的没有百度没有谷歌直接——

# yum install tomcat
嗯……没毛病 
关键来了,如何从在我们PC上访问我们的网站呢。大致是打开tomcat,修改tomcat配置,firewall配置。

tomcat的几个简单指令:

service tomcat start 
service tomcat stop 
service tomcat restart

环境变量配置可以参考:

http://blog.csdn.net/qq_27739989/article/details/78047106

firewall配置,百度上搜索大多是iptables配置,在这个版本的centos应该是用不了了,所以采用:

# systemctl start firewalld
# firewall-cmd --add-port=8080/tcp permanent
# systemctl reload firewalld
其他指令:
查看状态: systemctl status firewalld 
停止: systemctl disable firewalld
禁用: systemctl stop firewalld


到此ok,打开浏览器访问ip/域名:8080

利用腾讯云服务器Centos7+Tomcat搭建个人网站_第1张图片

可以在云服务器上玩JAVA WEB了,舒服~

你可能感兴趣的:(JAVA,WEB)