用于在纯净的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