将基本的项目部署到linux上(前后台只是实现了基本的功能,本次只是记录一些基本的开发流程,完善,等后续)
1、linux环境准备(我用的是阿里云服务器)
①jre、mysql,Nginx基本上这些就可以了
安装jdk:
//事先下载好的jdk-8u211-linux-x64.rpmrpm -ivh jdk-8u211-linux-x64.rpm
出现这个就代表已经完成
[root@nxz ~]# java -versionjava version "1.8.0_211"Java(TM) SE Runtime Environment (build 1.8.0_211-b12)Java HotSpot(TM) 64-Bit Server VM (build 25.211-b12, mixed mode)
安装mysql:
//事先下载好 mysql80-community-release-el7-3.noarch.rpm[root@nxz ~]# rpm -Uvh mysql80-community-release-el7-3.noarch.rpm
[root@nxz ~]# [root@nxz ~]# rpm -Uvh mysql80-community-release-el7-3.noarch.rpm warning: mysql80-community-release-el7-3.noarch.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEYPreparing... ################################# [100%]Updating / installing... 1:mysql80-community-release-el7-3 ################################# [100%]
执行完成之后:执行以下命令,并按照提示安装其他的一些东西
yum install mysql-community-server
直到输出:
安装完成之后,启动mysql:
service mysqld start
[root@nxz ~]# ps -ef | grep mysqlmysql 2855 1 3 21:30 ? 00:00:00 /usr/sbin/mysqld // 有这个代码mysql已经启动root 2917 1937 0 21:31 pts/0 00:00:00 grep --color=auto mysql
查询安装过程中生成的临时密码:
grep "password" /var/log/mysqld.log2019-06-12T13:30:49.812989Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: lqpRNIw7QB_5
登录mysql:
mysql -uroot -p***
登录后修改mysql的密码:
ALTER USER 'root'@'localhost' IDENTIFIED BY '123'; 修改MySQL数据库密码(这里要注意的是新密码必须是大写开头,包含大、小写字母,数字,特殊符号等)
比如我想用本机上的Navicat连接刚才配置的阿里云服务器上的MySQL数据库,还需要这一步:
grant all on *.* to admin@'%' identified by'123456' with grant option; //[admin]是远程连接的【用户名】,[123456]是远程连接的【密码】(同样,密码必须是大写开头,包含大、小写字母,特殊符号等)
(上边那个在有的版本的mysql上是不支持的,root用户不能用于外网访问),因此需要新建一个其他的用户
mysql> use mysql;Database changedmysql> create user 'admin'@'%' identified by '******';Query OK, 0 rows affected (0.01 sec)//授权访问mysql> grant all on *.* to 'admin'@'%';Query OK, 0 rows affected (0.01 sec)mysql>
另:需要放开防火墙端口3306和8080
查看:firewall-cmd --zone=public --list-ports
[root@nxz ~]# firewall-cmd --staterunning[root@nxz ~]# firewall-cmd --zone=public --add-port=3306/tcp --permanentsuccess[root@nxz ~]# firewall-cmd --zone=public --add-port=8080/tcp --permanentsuccess[root@nxz ~]# firewall-cmd --reload
使用Navicat链接:
Authentication plugin 'caching_sha2_password' cannot be loaded
遇到上边这个问题:(每一个用户都要这样执行一次))
1 修改账户密码加密规则并更新用户密码 ALTER USER 'root'@'localhost' IDENTIFIED BY 'password' PASSWORD EXPIRE NEVER; #修改加密规则 ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password'; #更新一下用户的密码 FLUSH PRIVILEGES; #刷新权限
或者:
看样子是验证插件问题的,排查下:SELECT `user`, `host`, `authentication_string`, `plugin` FROM mysql.user;+------------------+-----------+------------------------------------------------------------------------+-----------------------+| user | host | authentication_string | plugin |+------------------+-----------+------------------------------------------------------------------------+-----------------------+| archiver | % | $A$005$==t@l=SP'G{U[1})D8yLwA6ti2uHtmUKNuHxQSUggrBRMBR2CheCw0Oxad9 | caching_sha2_password || mysql.infoschema | localhost | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql_native_password || mysql.session | localhost | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql_native_password || mysql.sys | localhost | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql_native_password || root | localhost | $A$005$==t@l=SP'G{U[1})D8yLwA6ti2uHtmUKNuHxQSUggrBRMBR2CheCw0Oxad9 | caching_sha2_password |+------------------+-----------+------------------------------------------------------------------------+-----------------------+5 rows in set (0.06 sec)修改arhiver账号的密码验证插件类型:ALTER USER 'archiver'@'%' IDENTIFIED WITH mysql_native_password BY 'archiver';flush privileges;再次看下,SELECT `user`, `host`, `authentication_string`, `plugin` FROM mysql.user;+------------------+-----------+------------------------------------------------------------------------+-----------------------+| user | host | authentication_string | plugin |+------------------+-----------+------------------------------------------------------------------------+-----------------------+| archiver | % | *13D295FD7B8108ABBC89FCDDD342FFBFF5DA803C | mysql_native_password || mysql.infoschema | localhost | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql_native_password || mysql.session | localhost | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql_native_password || mysql.sys | localhost | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql_native_password || root | localhost | $A$005$==t@l=SP'G{U[1})D8yLwA6ti2uHtmUKNuHxQSUggrBRMBR2CheCw0Oxad9 | caching_sha2_password |+------------------+-----------+------------------------------------------------------------------------+-----------------------+5 rows in set (0.06 sec)
修改完成之后,可以使用Navicat链接了:
配置ngnix:
Nginx安装可以根据这个:
配置完成后:
Nginx 启动命令如下:[root@bogon conf]# /usr/local/webserver/nginx/sbin/nginx
查看进程:(已启动)
[root@nxz conf]# /usr/local/webserver/nginx/sbin/nginx [root@nxz conf]# ps -ef | grep nginxroot 16340 1 0 22:43 ? 00:00:00 nginx: master process /usr/local/webserver/nginx/sbin/nginxwww 16341 16340 0 22:43 ? 00:00:00 nginx: worker processwww 16342 16340 0 22:43 ? 00:00:00 nginx: worker processroot 16351 1937 0 22:43 pts/0 00:00:00 grep --color=auto nginx[root@nxz conf]#
其他命令:
/usr/local/webserver/nginx/sbin/nginx -s reload # 重新载入配置文件/usr/local/webserver/nginx/sbin/nginx -s reopen # 重启 Nginx/usr/local/webserver/nginx/sbin/nginx -s stop # 停止 Nginx
2、服务器配置安全组
3、以上信息配置完成后,将前后端项目移到服务器上
前端打包放到ngnix/html中即可(放好之后需要reload),后台随意了
放置后,直接访问服务器ip即可看到: