之前写过一篇《阿里云Ubuntu部署java web》,详细记录了java、tomcat、mysql在ubuntu16.04版本上的安装和配置。最近新装服务器,发现20.04版本的ubuntu有些小变化。
*以下内容仅针对18.04变更部分,详细配置请参考: 阿里云Ubuntu部署java web - 目录_zcsoft-CSDN博客
1:更新源:目前ubuntu默认源就很好用,速度也很快,不在需要替换源位置,直接update即可
sudo apt-get update
2:安装Java11
sudo apt install openjdk-11-jre-headless
3:安装mysql(Ubuntu设置mysql的root用户密码)
sudo apt-get install mysql-server
使用mysql安装mysql不在提示设置默认密码,但是系统会创建默认用户(debian-sys-maint),并将用户名密码记录在:/etc/mysql/debian.cnf,可以使用以下命令查看用户名密码:
sudo vim /etc/mysql/debian.cnf
登录默认用户:
mysql -u debian-sys-maint -p
修改root用户密码:
use mysql;
update mysql.user set authentication_string=PASSWORD('newPwd'), plugin='mysql_native_password' where user='root';
flush privileges;
4:安装tomcat
sudo apt-get install tomcat8
tomcat根目录位置:/var/lib/tomcat8/
5:开放系统80、443端口
5.0. 安装authbind,apt-get install authbind
5.1. 修改/etc/default/tomcat8,改最后一行的#AUTHBIND=no为AUTHBIND=yes
5.2. 执行一下指令:
sudo touch /etc/authbind/byport/80
sudo touch /etc/authbind/byport/443
sudo chmod 0755 /etc/authbind/byport/80
sudo chmod 0755 /etc/authbind/byport/443
sudo chown tomcat8:tomcat8 /etc/authbind/byport/80
sudo chown tomcat8:tomcat8 /etc/authbind/byport/443
5.3. 修改server.xml,web.xml配置(https://cloud.tencent.com/document/product/400/35224)
5.4. 重启tomcat