什么是Parse
Parse是非常优秀的Bass服务后台,非常适合移动平台的数据存储和消息推送。开源后发展更快 ,新的数据库也支持了,实时消息也实现了。
围观一下官方的自述,
For a decade or so before Parse, everyone had to build this stuff individually. It required knowledge across many disciplines, including network and hardware maintenance, server-side development and scaling, and front-end development and design. Very few could do it all alone; the rest grouped up and worked with others to complete the whole picture.
The concept behind Parse has always been a simple one. Abstract away almost the entire process, allowing a solo mobile developer to build the next great mobile app. For several years now, Parse has been the easiest and most comprehensive platform for mobile-focused developers.
一键安装脚本
这个脚本做了些什么工作:
- 安装Parse server的所需软件, 主要是express, nodejs和pm2
- 创建一个无密码的用户,默认用户名parse, 之后所有的项目的创建启动工作都在这个用户下面
- 在parse用户(假设你用的是默认用户名)下面, 开启了pm2常驻后台,重启机器无需手动启动服务。同时,提供一个项目配置的demo,方便围观和学习如何配置自己的项目文件
运行脚本需要哪些准备工作:
- 一台运行Debian的VPS。脚本在Debian7,8上测试通过,Centos和Mac上稍作修改也可以跑起来。
- 一些非常基础的linux命令,比如ssh登录,切换用户等。
全部脚本代码如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
#!/bin/bash PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin PATH=$PATH:/usr/lib/node_modules export $PATH DEFAULT_USER="parse" parse_user=$DEFAULT_USER; # Make sure only root can run our script [[ $EUID -ne 0 ]] && echo -e "This script must be run as root!" && exit 1 apt-get update & apt-get upgrade -y; # add an user with default name 'parse'. pre_install(){ clear echo;echo "-----------------------------------------------";echo; # create a user named 'parse' and run this script by the user read -p "Enter username(default: parse) : " username [ -z "$username" ] && echo "Input is empty, use default user name: parse." && username=$DEFAULT_USER egrep "^$username" /etc/passwd >/dev/null [ $? -eq 0 ] && echo "$username exists!" && return 1 useradd -m $username -s /bin/bash [ $? -eq 0 ] && echo "User has been added to system!" || echo "Failed to add a user!" parse_user=$username } install_mongo(){ echo "install mongodb"; apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927 echo "deb http://repo.mongodb.org/apt/debian wheezy/mongodb-org/3.2 main" | tee /etc/apt/sources.list.d/mongodb-org-3.2.list apt-get update apt-get install -y mongodb-org } install_parse(){ echo ">> install parse server to user:$username"; curl -sL https://deb.nodesource.com/setup_6.x -o nodesource_setup.sh chmod +x ./nodesource_setup.sh && ./nodesource_setup.sh apt-get install -y nodejs build-essential git npm install -g express --save npm install -g parse-server parse-dashboard pm2 pm2 startup ubuntu -u $parse_user --hp /home/$parse_user/ } start_sample(){ echo "start sample parse app and parse dashborad." cd; wget https://dl.lidalao.com/parse-app-sample.js -O ./parse-app-sample.js; mv ./parse-app-sample.js /home/$parse_user; echo echo -e "Congratulations, Parse server install completed wihth a sample!" echo -e "Just run below commands to start the sample project:" echo -e "sudo $parse_user" echo -e "pm2 start parse-app-sample.js" echo -e "pm2 save" echo echo "Welcome to visit: https://lidalao.com" echo "Enjoy it!" echo } pre_install; install_mongo; install_parse; start_sample; |