自用easyswoole 环境部署shell脚本

举报
仙士可 发表于 2023/06/21 17:17:18 2023/06/21
【摘要】 用于在纯净的centos系统上迅速部署一个easyswoole程序,还支持git代码拉取##!/usr/bin/env bash#PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin#export PATH;installPhp() { yum install -y php php-devel php...

用于在纯净的centos系统上迅速部署一个easyswoole程序,还支持git代码拉取

##!/usr/bin/env bash
#PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
#export PATH;

installPhp() {
  yum install -y php php-devel php-gd php-xml php-json php-mbstring # 安装php,扩展
}

installSwoole() {
  swooleVesrionDefualt="4.4.23"
  swooleBuildConfigureDefualt="--enable-openssl"
  phpIniPathDefualt="/etc/php.ini"
  echo -n "请输入swoole版本 [${swooleVesrionDefualt}] :"
  read swooleVesrion
  if [ ! $swooleVersion ]; then
    swooleVesrion=$swooleVesrionDefualt
  fi
  echo $swooleVesrion
  echo -n "请输入 configure 参数[${swooleBuildConfigureDefualt}] :"
  read swooleBuildConfigure
  if [ ! $swooleBuildConfigure ]; then
    swooleBuildConfigure=$swooleBuildConfigureDefualt
  fi
  echo $swooleBuildConfigure

  echo -n "请输入 phpini 路径 [${phpIniPathDefualt}] :"
  read phpInitPath
  if [ ! $phpInitPath ]; then
    phpInitPath=$phpIniPathDefualt
  fi
  echo $phpInitPath

  cd /tmp
  wget "https://github.com/swoole/swoole-src/archive/v${swooleVesrion}.tar.gz" # 下载swoole
  tar -zvxf v${swooleVesrion}.tar.gz swoole-src-${swooleVesrion}/
  cd swoole-src-${swooleVesrion}/
  phpize
  ./configure $swooleBuildConfigure
  make && make install
  sed -i "2i extension=swoole.so" $phpInitPath
}

installMysql() {
  yum install -y mysql mysql-server mysql-devel # 安装mysql
}
installOpenssl() {
  yum install -y openssl openssl-devel # 安装openssl
}
installGit() {
  yum install git -y # git
}

installNginx() {
  yum install nginx -y # nginx
}
installNodejs() {
  yum install nodejs -y # nodejs
  npm install -g yarn   # nodejs yarn
}
installComposer() {
  curl -sS https://getcomposer.org/installer | php
  mv composer.phar /usr/local/bin/composer
}
initEasyswooleProject(){
    echo -n "请输入 git 地址:"
    read gitUrl;
    echo -n "请输入项目名:"
    read projectName
    echo -n "是否保存git用户名密码: [y/N]"
    read isSavePassword
    if [ $isSavePassword = "y" ]; then
        git config --global credential.helper store
    fi

    git clone $gitUrl $projectName
    cd  $projectName
    composer up
    php ./vendor/bin/easyswoole install
    php easyswoole server start
}

echo "欢迎使用tioncico php swoole 安装程序"
echo "1:php"
echo "2:swoole"
echo "3:mysql"
echo "4:openssl"
echo "5:git"
echo "6:nginx"
echo "7:nodejs"
echo "8:composer"
echo "9:initEasyswooleProject"
echo "n:exit"

while [ 1 ]; do
  read num
  case $num in
  1)
    installPhp
    ;;
  2)
    installSwoole
    ;;
  3)
    installMysql
    ;;
  4)
    installOpenssl
    ;;
  5)
    installGit
    ;;
  6)
    installNginx
    ;;
  7)
    installNodejs
    ;;
  8)
    installComposer
    ;;
  9)
    initEasyswooleProject
    ;;
  *)
    break
    ;;
  esac

done
复制
【版权声明】本文为华为云社区用户原创内容,转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息, 否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。