你在这里

Centos7 搭建App Inventor 2 离线服务器 2019.03.05更新

主标签

1.CentOS7最小安装,设定网络,root登陆。  复制命令运行出错,可能是空格被替换为 了。

2.升级系统最新:

  yum -y update

3.必要软件安装:

 yum -y install wget zip unzip git  nano  zlib.i686  libstdc++-4.8.5-28.el7.i686  libstdc++-4.8.5-28.el7_5.1.i686 

 yum provides libstdc++.so.6

已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * epel: mirror01.idc.hinet.net
 * extras: mirrors.aliyun.com
 * updates: centos.ustc.edu.cn
 * webtatic: us-east.repo.webtatic.com
libstdc++-4.8.5-36.el7.i686 : GNU Standard C++ Library
源    :base
匹配来源:
提供    :libstdc++.so.6

yum -y install libstdc++-4.8.5-36.el7.i686

//确保有libstdc++.so.6库文件

4. 下载与安装jdk8:【20190302】 https://www.oracle.com/technetwork/java/javase/downloads/

cd /opt 
wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" https://download.oracle.com/otn-pub/java/jdk/8u191-b12/2787e4a523244c269598db4e85c51e0c/jdk-8u191-linux-x64.tar.gz
wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" https://download.oracle.com/otn-pub/java/jdk/8u201-b09/42970487e3af4f5aa5bca3f542482c60/jdk-8u201-linux-x64.tar.gz
tar -zxvf jdk-8u191-linux-x64.tar.gz
tar -zxvf jdk-8u201-linux-x64.tar.gz
ln -s /opt/jdk1.8.0_201 /opt/java

//若有安装openjdk ,记得先卸载。rpm -qa | grep openjdk  ;yum -y remove 
//以后jdk升级到opt/jdk1.8.0_192 就  ln -snf /opt/jdk1.8.0_192 /opt/java

5.ant安装 http://ant.apache.org/bindownload.cgi

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

6.https://cloud.google.com/appengine/docs/standard/java/download   下载并安装原始 Java 版 App Engine SDK。

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

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

 

7.设置环境

  1. 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

            2. source /etc/profile

                   测试下: 

                   java -version

java version "1.7.0_80"
Java(TM) SE Runtime Environment (build 1.7.0_80-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)
 

                  ant -version

Apache Ant(TM) version 1.9.9 compiled on February 2 2017
 

8.防火墙设置

   firewall-cmd --permanent --zone=public --add-port=8888/tcp
   firewall-cmd --reload

==========================2018.12.31使用普通用户: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

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

9.使用git或者从https://github.com/mit-cml/appinventor-sources/archive/master.zip下载源码。

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

//代理加速 git config --global http.proxy 'socks5://127.0.0.1:8864'
//               git config --global --unset http.proxy

10.ant appinventor代码

cd /home/ai2/appinventor-sources/appinventor
ant clean
ant MakeAuthKey
ant

 

11.试运行

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

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

12.搬到运行目录

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 ./
mkdir pid

 

13.开机启动

      nano /home/ai2/ai2server/runai2.sh

      写入:

#!/usr/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=localhost  --disable_update_check /home/ai2/ai2server/war/ &> /home/ai2/ai2server/pid/ai2d.log &
echo $! > /home/ai2/ai2server/pid/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/pid/ai2b.log &
echo $! > /home/ai2/ai2server/pid/ai2b.pid

 

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

  nano /home/ai2/ai2server/stopai2.sh

     写入:

#!/usr/bin/bash
#
#

#pkill -9 java

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

kill -15 $PID

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

kill -15 $PID
 

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

  创建service

       cd /usr/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       #(等1分钟后,网站能访问了吧)

   systemctl enable ai2.service   #  (开机启动)

 //systemctl daemon-reload 编辑后需要重新加载

13.=============================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 请搜索相关资料。

学习 App Inventor 2,推荐关注微信号:"老巫婆的程序世界"

=============================================安装 google Cloud sdk 笔记=============================

1.nono /etc/yum.conf

proxy=http://192.168.1.1:8080

2.nano  /etc/yum.repos.d/google-cloud-sdk.repo 

[google-cloud-sdk]
name=Google Cloud SDK
baseurl=https://packages.cloud.google.com/yum/repos/cloud-sdk-el7-x86_64
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg
              https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg

3.  yum install google-cloud-sdk
     yum install  google-cloud-sdk-app-engine-java
     gcloud config set proxy/type http
     gcloud config set proxy/address 192.168.1.1
     gcloud config set proxy/port 1080
     gcloud init

4. exec nohup /usr/lib64/google-cloud-sdk/bin/java_dev_appserver.sh --port=8888 --address=ai2n.fsyz.net  --disable_update_check /data/ai2server/war/ &> /data/ai2server/ai2d.log &
echo $! > /data/ai2server/ai2d.pid

5.查看java安装目录 :

rpm -qa | grep java
rpm -ql java-1.8.0-openjdk-1.8.0.111-1.b15.el7_2.x86_64

6.环境:

export ANT_HOME=/opt/apache-ant
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.242.b08-0.el7_7.x86_64
export PATH=$PATH:$ANT_HOME/bin:$JAVA_HOME/bin

 

评论

感谢教程,搭建起来了,测试可以,就是有个问题,研究了好久,不知道怎么办,就是加载首页的时候,有一个*.cache.js文件,加载的特别慢,在教程给出的服务器测试,加载一分钟才跳到登陆页面,这个问题又办法优化么?

访问一次以后就快了.

这个教程已经过期了,目前是推荐openjdk + google-cloud-sdk ,你也可以试试.差不多的.

看到有说使用openjdk+谷歌云jdk,请问能说一下具体怎么用ym指令操作呢,在CentOs7操作环境下