基础环境搭建
安装open jdk
yum -y install java-1.8.0-openjdk java-1.8.0-openjdk-devel # 安装1.8版本
dirname $(readlink $(readlink $(which java))) # 查看安装目录
配置jdk环境变量,在文件/etc/profice最后面增加内容:
export JAVA_HOME=上面dirname命令获取到的路径,不要jre/bin最后这段
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/jre/lib:$JAVA_HOME/lib:
$JAVA_HOME/lib/tools.jar
java -version 查看版本信息,版本信息能够查询出来表示安装成功
安装MAVEN3
wget http://mirrors.hust.edu.cn/apache/maven/maven-3/3.1.1/binaries/apache-maven-3.1.1-bin.tar.gz # 下载安装包
tar zxf apache-maven-3.1.1-bin.tar.gz 解压
修改环境变量
export M2_HOME=/usr/local/maven3
export PATH=$PATH:$JAVA_HOME/bin:$M2_HOME/bin # 加在JDK Path路径后面
source /etc/profice
验证是否安装成功
mvn -v
安装mysql
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
sudo rpm -ivh mysql-community-release-el7-5.noarch.rpm
sudo yum install mysql-server
修改权限
sudo chown -R openscanner:openscanner /var/lib/mysql
service mysqld restart
mysql -u root
use mysql;mysql > update user set password=password(‘root‘) where user=‘root‘;mysql > exit;
Grant all privileges on *.* to 'root'@'%' identified by 'root' with grant option;
部署
# 进入磁盘目录,如/data
cd /data
git clone https://github.com/ZHENFENG13/My-Blog.git
目录结构如下:
myblog
├── docker-extension
├── my-blog
├── mysql
├── docker-compose.yml
└── run.sh
├── src
├── main/java
└── main/resources
├── pom.xml
└── my-blog.sh
导入数据库文件,docker-extension/mysql/schema.sql
修改配置文件中的mysql地址和账密,默认为localhost:3306,修改为你的地址即可,配置文件路径为:main/resources/application-default.properties
# 修改脚本执行权限
chmod +x my-blog.sh
#启动mysql
sh -x my-blog.sh start
启动成功后即可访问
首页地址:http://localhost:8080
后台地址:http://localhost:8080/admin
默认账密:admin 123456
详细操作参见:https://github.com/ZHENFENG13/My-Blog/wiki/1-%E5%A6%82%E4%BD%95%E9%83%A8%E7%BD%B2My-Blog
网友评论