你在这里

Debian 9 搭建 App Inventor 2 离线服务器

主标签

有关内容请先参考 Centos7安装App Inventor 2 离线服务器     复制命令运行出错,可能是空格被替换为 了。

1.最小系统安装,root用户登陆。

2.升级和基本组件

apt-get upgrade
apt-get install -y software-properties-common dirmngr nano git zip unzip wget lib32z1 lib32stdc++6

// apt-get install libc6:i386 zlib1g:i386 libstdc++6:i386  手册说装这几个.

3.安装JDK8

add-apt-repository "deb http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main"
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys EEA14886
apt-get update
apt-get install -y oracle-java8-installer
    对话框 <yes>,  <yes> 接受协议。
java -version
javac -version
update-alternatives --config javac

主要看看java的目录是哪个。
There is 1 choice for the alternative javac (providing /usr/bin/javac).

  Selection    Path                                  Priority   Status
------------------------------------------------------------
  0            /usr/lib/jvm/java-8-oracle/bin/javac   1081      auto mode
* 1            /usr/lib/jvm/java-8-oracle/bin/javac   1081      manual mode

ln -s  /usr/lib/jvm/java-8-oracle /opt/java

4.安装ant

cd /opt
wget http://mirrors.hust.edu.cn/apache//ant/binaries/apache-ant-1.10.5-bin.zip
unzip apache-ant-1.10.5-bin.zip
ln -s /opt/apache-ant-1.10.5 /opt/apache-ant
 

//下次升级了apache-ant-1.10.6 就 ln -snf /opt/apache-ant-1.10.6 /opt/apache-ant

5.安装appengine-java-sdk

cd /opt
wget https://storage.googleapis.com/appengine-sdks/featured/appengine-java-sdk-1.9.69.zip
unzip appengine-java-sdk-1.9.69.zip
ln -s /opt/appengine-java-sdk-1.9.69 /opt/appengine-java-sdk
 

//下载不了? 考虑用代理。。。 proxychains4 wget https://storage.googleapis.com/appengine-sdks/featured/appengine-java-sdk-1.9.69.zip
// ln -snf

5.设置环境

nano /etc/profile

末尾添加

export ANT_HOME=/opt/apache-ant      
export JAVA_HOME=/opt/java 
export JRE_HOME=/opt/java/jre
export PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin:$ANT_HOME/bin:/opt/appengine-java-sdk/bin
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib

source  /etc/profile

==========================2019.01.01使用普通用户:ai2 运行============================================

groupadd ai2 && useradd -g ai2  -G wheel -s /bin/bash  -d /home/ai2  ai2

//设置ai2d 密码

passwd ai2

//切换普通用户ai2

su ai2

cd ~

//当前目录  /home/ai2

nano    .bash_profile

export ANT_HOME=/opt/apache-ant
export JAVA_HOME=/opt/java
export JRE_HOME=/opt/java/jre
export PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin:$ANT_HOME/bin:/opt/appengine-java-sdk/bin
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib

source  .bash_profile

=====================================================================================

6.git源代码

cd  ~
git  clone https://github.com/mit-cml/appinventor-sources.git
cd  appinventor-sources
cp  sample-.gitignore  .gitignore
git  submodule  update  --init

7.ant源代码

cd  appinventor
ant  clean
ant  MakeAuthKey
ant

8.试运行

 dev_appserver.sh --port=8888 --address=0.0.0.0 --disable_update_check /home/ai2/appinventor-sources/appinventor/appengine/build/war/

 看看有没有出错代码,Ctrl+c 退出。

9.搬到正式运行目录

cd ~
mkdir ai2server
cd ai2server
cp -R /home/ai2/appinventor-sources/appinventor/appengine/build/war ./
cp -R /home/ai2/appinventor-sources/appinventor/buildserver/build/run/lib ./

10.开机启动

nano /home/ai2/ai2server/runai2.sh

      写入:

#!/bin/bash
#
#
#

export ANT_HOME=/opt/apache-ant
export JAVA_HOME=/opt/java
export JRE_HOME=/opt/java/jre
export PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin:$ANT_HOME/bin:/opt/appengine-java-sdk/bin
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib

#pkill -9 java

nohup dev_appserver.sh --port=8888 --address=0.0.0.0  --disable_update_check /home/ai2/ai2server/war/ &> /home/ai2/ai2server/ai2d.log &
echo $! > /home/ai2/ai2server/ai2d.pid

cd /home/ai2/ai2server/lib
nohup java -Xmx1828m -cp "*" -Dfile.encoding=UTF-8 com.google.appinventor.buildserver.BuildServer --dexCacheDir /tmp/ &> /home/ai2/ai2server/ai2b.log &
echo $! > /home/ai2/ai2server/ai2b.pid

  chmod +x /home/ai2/ai2server/runai2.sh

  nano /home/ai2/ai2server/stopai2.sh

     写入:

#!/bin/bash
#
#

#pkill -9 java

read PID < /home/ai2/ai2server/ai2d.pid

kill -15 $PID

read PID < /home/ai2/ai2server/ai2b.pid

kill -15 $PID
 

  chmod +x /home/ai2/ai2server/stopai2.sh

创建service

       cd /lib/systemd/system

      sudo nano ai2.service

       写入:

[Unit]
Description=app inventor 2
After=network.target
 
[Service]
Type=forking
ExecStart=/home/ai2/ai2server/runai2.sh
ExecStop=/home/ai2/ai2server/stopai2.sh
PrivateTmp=true
User=ai2
Group=ai2
 
[Install]
WantedBy=multi-user.target

 systemctl start ai2.service       #启动

 systemctl stop ai2.service       #停止

 systemctl enable ai2.service   #开机启动

 systemctl disable ai2.service # 取消开机启动

11.=============================appinventor-sources更新===============================

cd /home/ai2/appinventor-sources
git pull
git submodule update
cd /home/ai2/appinventor-sources/appinventor   
ant clean  
ant
systemctl stop ai2
sleep 10s
\cp -Rf /home/ai2/appinventor-sources/appinventor/appengine/build/war /home/ai2/ai2server/
\cp -Rf /home/ai2/appinventor-sources/appinventor/buildserver/build/run/lib /home/ai2/ai2server/
systemctl start ai2

 

16。============================拓展=============================

  修改web.xml 禁止访问/_ah/admin https://gte.fsyz.net/node/1900

   三、离线服务器增强                       https://gte.fsyz.net/node/1911

17. 8888 端口 转发 80 请搜索相关资料。