部署lilishop开发平台
Docker部署:
安装jdk环境
mkdir /usr/lib/jvm
tar -zxvf jdk-8u221-linux-x64.tar.gz -C /usr/lib/jvm
vim ~/.bashrc #添加环境变量
export JAVA_HOME=/usr/lib/jvm/jdk1.8.0_221
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
source ~/.bashrc #使环境变量生效
java -version #查看版本,出现版本则没有问题
使用jps查看java进程
vim /etc/profile
export JAVA_HOME=/usr/lib/jvm/jdk1.8.0_221
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
source /etc/profile
vim ~/.zshrc
在第七行添加source /etc/profile
source ~/.zshrc
使用docker部署脚本一键部署docker
bash get-docker.sh
查看docker版本
docker version
安装docker-compose
下载docker-compose文件,并移动到/usr/local/bin
mv docker-compose /usr/local/bin/
赋予可执行权限
chmod +x docker-compose
查看docker-compose版本,如显示则安装成功
docker-compose -v
前端代码打包,上传到服务器进行解压
将解压后的代码包放到nginx.conf的文件路径下
后端代码打包,上传到服务器进行解压以及启动
nohup java -jar ~/lili-jar/seller-api-4.2.5.jar > /dev/null 2>&1 &
nohup java -jar ~/lili-jar/common-api-4.2.5.jar > /dev/null 2>&1 &
nohup java -jar ~/lili-jar/buyer-api-4.2.5.jar > /dev/null 2>&1 &
nohup java -jar ~/lili-jar/consumer-4.2.5.jar > /dev/null 2>&1 &
nohup java -jar ~/lili-jar/manager-api-4.2.5.jar > /dev/null 2>&1 &
使用jps进行查看java程序是否启动
部署openresty
安装openresty 需要的组件
apt-get install libpcre3-dev \
libssl-dev perl make build-essential curl
下载安装包
wget https://openresty.org/download/openresty-1.21.4.1.tar.gz
解压
tar -zxvf openresty-1.21.4.1.tar.gz
预编译
cd openresty-1.21.4.1
./configure --prefix=/usr/local/openresty \
--with-luajit \
--without-http_redis2_module \
--with-http_iconv_module \
--with-http_ssl_module \
--with-http_v2_module \
--with-http_gzip_static_module \
--with-http_auth_request_module \
--with-stream_ssl_module \
--with-stream_ssl_preread_module
--with-http_postgres_module
编译
gmake && gmake install
进入openresty目录指定nginx.conf的读取文件路径
cd /usr/local/openresty/nginx/conf
cat 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;
include /data/nginx/conf.d/*.conf;
#gzip on;
#access_log logs/host.access.log main;
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.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;
# }
#}
}
#######################################################################################
在指定的路径/data/nginx/conf.d/*.conf创建.conf的文件
vim admin-b2b2c.conf #运营总后台代码转发
#######################################################
server {
listen 80;
server_name admin-b2b2c.lechongpai.com;
#underscores_in_headers on;
add_header Referrer-Policy no-referrer;
add_header X-Frame-Options SAMEORIGIN;
access_log /data/nginx/logs/admin-b2b2c.access.log;
error_log /data/nginx/logs/admin-b2b2c.error.log;
# /lamp-web 代理前端
location / {
proxy_set_header Host $host:$server_port;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_connect_timeout 60;
proxy_read_timeout 600;
proxy_send_timeout 600;
# 请将第三步打包后生成的 lamp-web 文件夹上传到 nginx 所在服务器的 /data/projects/ 目录
root /home/apper/node-project/lili-shop/manager/dist;
index index.html;
try_files $uri $uri/ /index.html;
}
}
#######################################################
vim store-b2b2c.conf #商后端代码转发
#######################################################
server {
listen 80;
server_name store-b2b2c.lechongpai.com;
#underscores_in_headers on;
add_header Referrer-Policy no-referrer;
add_header X-Frame-Options SAMEORIGIN;
access_log /data/nginx/logs/store-b2b2c.access.log;
error_log /data/nginx/logs/store-b2b2c.error.log;
# /lamp-web 代理前端
location / {
proxy_set_header Host $host:$server_port;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_connect_timeout 60;
proxy_read_timeout 600;
proxy_send_timeout 600;
# 请将第三步打包后生成的 lamp-web 文件夹上传到 nginx 所在服务器的 /data/projects/ 目录
root /home/apper/node-project/lili-shop/seller/dist;
index index.html;
try_files $uri $uri/ /index.html;
}
}
#######################################################
进行nginx配置检测并启动
/usr/local/openresty/nginx/sbin/nginx -t #检查配置文件
/usr/local/openresty/nginx/sbin/nginx -s reload #重启nginx
/usr/local/openresty/nginx/sbin/nginx #启动nginx
根据代理的不同的域名去访问Web UI
store-b2b2c.lechongpai.com
admin-b2b2c.lechongpai.com