LEEYANGY

LEEYANGY 关注TA

拼搏百天

LEEYANGY

LEEYANGY

关注TA

拼搏百天

  •  Wuhan/HuBei
  • 学生
  • 写了322,476字

该文章投稿至Nemo社区   Java  板块 复制链接


用tomcat部署java web项目

发布于 2021/02/28 01:44 16,955浏览 0回复 3,715

一个很简单的小项目,记录我的学习过程。

以下某些重点内容 (jdk的安装之类的东西)  可能还有错,慢慢更新吧

最近在把小web项目往树莓派迁移,后面都会以树莓派为例子。


开发环境:win 10 专业版 版本号:1909 操作系统版本号:18363.592

使用软件环境: 

IntelliJ IDEA 2020.3 (Ultimate Edition) 使用学生账号授权

tomcat8.5.57 Windows版本

jdk:1.8.0_241

Vm16 (模拟实际访问目标,比如说我要访问link-nemo.com大概就是这个意思)

Xshell和Xftp 使用学生白嫖版本

Navicat Premium 12  白嫖14天体验

过程如下:

从清华镜像站下载ubuntu-server 18.04 和tomcat 使用vm虚拟两个(一个存放tomcat,另一个存放mysql)

配置好虚拟机后使用Xshell进行远程连接

之后使用1为web-server  2 mysql-

把之前下载好的tomcat使用Xftp传输到1服务器上 ,解压tar -xvzf apache................


配置jdk

再Oracle官网上下载最新的jdk

解压到自己的目录下我的是;

/home/ubuntu/java/jdk1.8.0_291/bin

配置环境变量:

sudo vim /etc/profile

加入以下内容: JAVA_HOME是自己前面解压jdk的路径 #set java environment
JAVA_HOME=/home/ubuntu/java/jdk1.8.0_291
JRE_HOME=/home/ubuntu/java/jdk1.8.0_291/jre
CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
export JAVA_HOME JRE_HOME CLASS_PATH PATH

source /etc/profile


输入命令测试是否配置成功

( java , javac , java -version )



vim apa..../conf/server.xml 将

<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />

修改成
<Connector port="8585" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />

重启tomcat服务

./ap......./bin/startup.sh

打开Windows下的浏览器输入1服务器ip+端口即打开tomcat页面

如果能进入tomcat页面后表示配置成功了,否则请反思。


-----2022--09--28----

为了方便使用,将软件移动到/usr/local/下的目录,创建链接到/usr/local/sbin/

sudo mv tomcat_10/ /usr/local/
sudo ln -s /usr/local/tomcat_10/bin/* /usr/local/sbin/

netstat -anput | grep 端口

-----2022--09--28----


mysql的配置:

使用2服务器

sudo apt-get install mysql-server
sudo apt-get install mysql-client
sudo apt-get install libmysqlclient-dev

开启MySql远程访问

配置MySql配置,允许远程登陆

sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
#将bind-address 这行注释掉,然后重启
sudo service mysql restart

mysql_secure_installation 进行简单配置

--为root用户设置密码
--删除匿名账号
--取消root用户远程登录
--删除test库和对test库的访问权限
--刷新授权表使修改生效

以下是配置过程中的log(仅供参考,不是实际用途)

root@ubuntu:/home/ubuntu# mysql_secure_installation

Securing the MySQL server deployment.

Connecting to MySQL using a blank password.

VALIDATE PASSWORD COMPONENT can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD component?

Press y|Y for Yes, any other key for No:
Please set the password for root here.

New password:

Re-enter new password:
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.

Remove anonymous users? (Press y|Y for Yes, any other key for No) : n

... skipping.


Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : n

... skipping.
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.


Remove test database and access to it? (Press y|Y for Yes, any other key for No) : n

... skipping.
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) :

... skipping.
All done! 


配置完成之后使用Navicat Premium进行连接操作

Navicat Premium/SQLyog提示错误: 详见:https://www.link-nemo.com/u/10156/post/290855

设置账号远程登录

mysql -u root -p
use mysql;
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root账号密码' WITH GRANT OPTION;
flush privileges;

以上是环境的部署,web和数据库都在慢慢的设计中,日后更新。2021.02.28:00:00


本文标签
 {{tag}}
点了个评