Ubuntu 22 LTS 搭建SpringBoot服务器
1 常用命令
sudo passwd root
sudo login
ps -ef
ps -ef | grep .jar
htop
netstat -lntp | grep 6379
sudo apt install net-tools
ifconfig -a
which nginx
2 安装ssh远程服务
sudo apt-get install openssh-server
sudo apt-get install openssh-client
sudo vim /etc/ssh/sshd_config
【修改配置:PermitRootLogin yes】
【修改配置:Port 22】
systemctl restart sshd.service
3 防火墙设置
sudo apt-get install ufw
sudo ufw enable (关闭)
sudo ufw default deny
sudo ufw disable
sudo ufw status
sudo ufw allow 80
sudo ufw delete allow 80
sudo ufw allow 22
4 修改IP(Ubuntu 22 Server)
vim /etc/netplan/00-installer-config-wifi.yaml
修改内容(以下非命令,有线连接把access-points及子节点全删除):
network:
version: 2
wifis:
wlp3s0:
access-points:
WIFI名字:
password: 'WIFI密码'
addresses: [10.168.2.250/24]
dhcp4: no
optional: true
gateway4: 10.168.2.1
nameservers:
addresses: [10.168.2.1,8.8.8.8,114.114.114.114]
sudo netplan apply
ifconfig -a
ping 10.168.2.1
5 MySql安装和配置
?
sudo apt-get install mysql-server
sudo mysql_secure_installation
sudo ufw allow 3306
sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf
修改:bind-address = 0.0.0.0
sudo /etc/init.d/mysql restart
sudo mysql -uroot -p
mysql>use mysql;
mysql>select User,authentication_string,Host from user;
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '密码';
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '密码' PASSWORD EXPIRE NEVER;
mysql> UPDATE user SET host = '%' WHERE user = 'root';
mysql>flush privileges;
mysql>quit;
参考:Ubuntu 中修改 MySQL 数据库存储数据的位置_之一先生专栏-CSDN博客 参考:Ubuntu20.04安装Mysql_風の住む街~的博客-CSDN博客_ubuntu20.04安装mysql
6 Java安装
sudo apt install openjdk-8-jdk-headless
java -version
参考:ubuntu 安装 Java 开发环境 - schips - 博客园
7 Nginx安装和配置
apt-get install nginx
vim /etc/nginx/nginx.conf
systemctl start nginx
sudo systemctl enable nginx
sudo systemctl disable nginx
nginx -s reload
问题:配置不生效原因1:sites-enabled,sites-available中的default没有删除
8 Hosts修改
sudo vim /etc/hosts
service netplan restart
9 ?Redis安装和配置
sudo apt install redis
redis-cli --version
vim /etc/redis/redis.conf
【修改】daemonize yes
redis
ps -ef | grep redis
sudo vim /etc/redis/redis.conf:
【修改】把bind 127.0.0.1 ::1改成
【修改】daemonize no
【修改】protected-mode no
/etc/init.d/redis-server restart
127.0.0.1:6379> CONFIG set requirepass "pwd"
127.0.0.1:6379> AUTH "pwd"
参考:(error) DENIED Redis is running in protected 参考:Redis安全相关
10 RabbitMQ安装和配置
curl -s https://packagecloud.io/install/repositories/rabbitmq/rabbitmq-server/script.deb.sh | sudo bash
sudo apt-get install rabbitmq-server=3.10.7-1
service rabbitmq-server status
service rabbitmq-server start
service rabbitmq-server stop
service rabbitmq-server restart
rabbitmq-plugins enable rabbitmq_management
service rabbitmq-server restart
rabbitmqctl list_users
rabbitmqctl add_user admin yourpassword
rabbitmqctl set_user_tags admin administrator
直接按照官方说明安装即可,不用手动安装erlang 参考:RabbitMQ的应用场景 参考:RabbitMQ安装官方指导 参考:Ubuntu 16.04 RabbitMQ 安装与运行(安装篇) 参考:Springboot 整合RabbitMQ ,用心看完这一篇就够了
11 Minio安装和配置
参考:Ubuntu安装MinIO
|