使用的是xftp和xshell工具,服务器版本是ubuntu20.04,部署项目为springboot+vue分离项目。打包后的文件放到自定义位置。
文件夹或文件授权
sudo chmod 600 ××× (只有所有者有读和写的权限)
sudo chmod 644 ××× (所有者有读和写的权限,组用户只有读的权限)
sudo chmod 700 ××× (只有所有者有读和写以及执行的权限)
sudo chmod 666 ××× (每个人都有读和写的权限)
sudo chmod 777 ××× (每个人都有读和写以及执行的权限)
管理员登入
sudo su
切换用户
su 用户名
创建文件夹
mkdir 文件名
重启
reboot
在/usr文件夹下创建java文件夹,将jdk的包导入进去并解压,可以用xftp进行可视化操作,也可以用xshell命令行操作
xshell操作
安装工具
yum install lrzsz
切换到/usr/java文件夹下 ,上传文件
rz
解压文件(可先用ls查看文件夹下文件,并复制压缩包名)
tar -zxvf 压缩包名
找到文件 /etc/profile ,在最下面添加如下代码(注意好文件名)
export JAVA_HOME=/usr/java/jdk1.8.0_221
export CLASSPATH=$JAVA_HOME/lib/
export PATH=$PATH:$JAVA_HOME/bin
export PATH JAVA_HOME CLASSPATH
查看文件是否保存成功
cat profile
使用source命令(source命令:依次执行文件所有语句)
source /etc/profile
java命令验证
java -version
更新源
sudo apt-get update
安装mysql(Ubuntu在20.04版本中,源仓库中MySQL的默认版本已经更新到8.0。因此可以直接安装)
sudo apt-get install mysql-server
启动mysql-services服务
systemctl status mysql
登入mysql(测试是否安装成功)
sudo mysql -u root -p
或者:#可以不需要指定用户名密码
sudo mysql
获取mysql随机账号用户名和初始密码(user
、password
)(此方法可用于重置密码)
sudo cat /etc/mysql/debian.cnf
然后使用获取到的用户名和密码登录MySQL
mysql -u -p
修改root密码
use mysql;
update user set authentication_string='' where user='root';
修改密码
alter user 'root'@'localhost' identified with mysql_native_password by '修改的密码';
保存退出(可重新登入检查密码是否修改成功)
quit;
修改编码方式为utf-8
编辑配置文件
sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf
在[mysqld]下添加
sql_mode='STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION'
collation-server = utf8_unicode_ci
init-connect='SET NAMES utf8'
character-set-server = utf8
!!如果不能修改文件,则要修改权限
sudo chmod 777 mysqld.cnf
sudo chmod a+w mysqld.cnf
修改文件后
sudo chmod 644 mysqld.cnf
配置远程连接
#bind-address=127.0,0.1
#mysalx-bind-address=127,0,0,1
#注释掉这两行
重启mysql服务
service mysql restart
登入mysql检查mysql目前编码方式
show variables like "char%";
修改用户权限
use mysql;
update user set host = '%' where user = 'root';
刷新权限
flush privileges;
查看用户的权限
select user, host, plugin from user where user = 'root';
此时root的host为%,可以尝试用远程。
查看MySQL配置文件
sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
启动MySQL数据库服务
sudo systemctl start mysql.service
查看MySQL运行状态
sudo systemctl status mysql.service
停止MySQL数据库服务
sudo systemctl stop mysql.service
重启MySQL数据库服务
sudo systemctl restart mysql.service
确认mysql服务是否启动成功
sudo netstat -tap | grep mysql
查看数据库
show databases;
如何新增用户
CREATE USER 'admin'@'localhost' IDENTIFIED BY '你要设置的密码';
卸载mysql
sudo rm /var/lib/mysql/ -R
sudo apt-get autoremove mysql* --purge
sudo rm /etc/mysql/ -R
sudo apt-get update
sudo apt-get install redis-server
service redis status
执行命令whereis redis 可以查看配置文件所在位置,一般在/etc/redis/redis.conf
bind 127.0.0.1
protected-mode yes
改为:protected-mode no
requirepas 密码
service redis restart
打jar包前,配置好ip地址,以免照成没必要的bug,我们把它们放在自己想放的位置之后,在此路径下开始命令行操作
vi start.sh
在里面写上java -jar jar包名
chmod 777 start.sh
nohup ./start.sh &
sudo apt-get update
sudo apt-get install nginx
nginx -v
安装nginx后,nginx的默认目录是/etc/nginx,在该目录中有nginx.conf文件进行配置
user root;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
#端口号
listen 80;
#名称,可自定义,一般写ip地址
server_name ip地址;
#charset koi8-r;
#access_log logs/host.access.log main;
try_files $uri $uri/ /index.html;
location / {
#vue包存放位置
root /home/unodolar/yungongju/dist;
# 此处的 实际上是引用下面的转发,否则在 Vue 路由刷新时可能会抛出 404
try_files $uri $uri/ ;
index index.html index.htm;
}
# 由于路由的资源不一定是真实的路径,无法找到具体文件
# 所以需要将请求重写到 index.html 中,然后交给真正的 Vue 路由处理请求资源
location {
rewrite ^.*$ /index.html last;
}
# 关键步骤,这里表示将所有的 /api/ 开头的请求都转发到下面 proxy_pass 指定的链接中
# 为了防止在访问页面时请求就被 Nginx 代理转发,这里需要更具体的配置,才能和前端访问请求区分开
location /api/ {
# 后端的真实接口
proxy_pass http://IP地址:9090;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Cookie $http_cookie;
# for Ajax
#fastcgi_param HTTP_X_REQUESTED_WITH $http_x_requested_with;
proxy_set_header HTTP-X-REQUESTED-WITH $http_x_requested_with;
proxy_set_header HTTP_X_REQUESTED_WITH $http_x_requested_with;
proxy_set_header x-requested-with $http_x_requested_with;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 128k;
proxy_buffers 32 32k;
proxy_busy_buffers_size 128k;
proxy_temp_file_write_size 128k;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}
启动nginx
server nginx restart
重启nginx
nginx -s reload
停止nginx
systemctl stop nginx
小白路漫漫,让我们一起加油!!!