阿里云服务维护
1.安装JDK
查询要安装jdk的版本,命令:yum -y list java*
命令:yum install -y java-1.8.0-openjdk.x86_64
yum install -y java-17-openjdk.x86_64
2.安装nginx
启用 EPEL 仓库
sudo yum install epel-release
安装 Nginx
sudo yum install nginx
启动 Nginx
sudo systemctl start nginx
设置 Nginx 开机自启
sudo systemctl enable nginx
检查 Nginx 状态
sudo systemctl status nginx
停止、重启 Nginx
sudo systemctl restart nginx
http://39.105.6.89
配置目录:/etc/nginx/nginx.conf
配置样例
server {
listen 80;
listen [::]:80;
server_name pcxf.xxx;
root /opt/smart-admin-web;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
location /api/ {
proxy_pass http://127.0.0.1:1024;
# 开启 CORS
add_header 'Access-Control-Allow-Origin' '*';
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
return 204;
}
}
}
3.安装mysql
添加 MySQL 仓库
sudo rpm -Uvh https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
安装 MySQL
sudo yum install mysql-community-server
启动 MySQL 服务
sudo systemctl restart mysqld
设置 MySQL 服务开机自启
sudo systemctl enable mysqld
获取临时密码
sudo grep 'temporary password' /var/log/mysqld.log
安全配置 MySQL
sudo mysql_secure_installation
修改mysql原始账号密码、创建新账号、新账号赋权限
ALTER USER 'root'@'localhost' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
CREATE USER 'allaccessUser'@'%' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'allaccessUser'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;
A temporary password is generated for root@localhost: >kPP2o2Sov=r
配置文件目录:/etc/my.cnf
bind-address=0.0.0.0 允许任何客户端访问
三、Mysql安装GPG检查失败解决方法:
1、禁用 GPG 检查,进行安装:yum install --nogpgcheck mysql-community-server
4.安装redis
安装 EPEL 仓库
sudo yum install epel-release
安装 Redis
sudo yum install redis
sudo systemctl start redis
sudo systemctl status redis
测试 Redis 是否安装成功
redis-cli ping
redis-cli -h <hostname> -p <port> ping
Redis 的配置文件通常位于 /etc/redis.conf
配置文件修改和新增
bind 0.0.0.0
requirepass password
sudo systemctl restart redis
系统检索文件
find / -type f -name "*.conf" -exec grep -Hn "pattern" {} \;
查看防火墙状态
systemctl status firewalld
关闭当前运行中的防火墙
systemctl stop firewalld
systemctl disable firewalld
java项目启动
top
kill -9 pid
nohub java -jar xx.jar &