脚本内容如下:#!/bin/bash
#Data:2015-12-09
#Version:1.0
#Author:Jacob(ydh0011@163.com)
#The software list:Nginx,MySQL,PHP,Memcached,memcache for php,Tomcat,Java.
#This script can automatically install all software on your machine.
#@丁丁历险博客(manual.blog.51cto.com)
#Define default variables, you can modify the value.
nginx_version=nginx-1.8.0
mysql_version=mysql-5.6.25
cmake_version=cmake-2.8.10.2
mhash_version=mhash-0.9.9.9
libmcrypt_version=libmcrypt-2.5.8
php_version=php-5.4.24
libevent_vertion=libevent-2.0.21-stable
memcached_version=memcached-1.4.24
memcache_version=memcache-2.2.5
format1=tar.gz
format2=tgz
#Determine the language environment
#@丁丁历险博客(manual.blog.51cto.com)
language(){
echo $LANG |grep -q zh
if [ $? -eq 0 ];then
return 0
else
return 1
fi
}
#Define a user portal menu.
#@丁丁历险博客(manual.blog.51cto.com)
menu(){
clear
language
if [ $? -eq 0 ];then
echo " ##############----Menu----##############"
echo "# 1. 安装Nginx"
echo "# 2. 安装MySQL"
echo "# 3. 安装PHP"
echo "# 4. 安装Memcached"
echo "# 5. 安装memcache for php"
echo "# 6. 安装Java"
echo "# 7. 安装Tomcat"
echo "# 8. 安装以上所有软件"
echo "# 9. 退出程序"
echo " ########################################"
else
echo " ##############----Menu----##############"
echo "# 1. Install Nginx"
echo "# 2. Install MySQL"
echo "# 3. Install PHP"
echo "# 4. Install Memcached"
echo "# 5. Install memcache for php"
echo "# 6. Install Java"
echo "# 7. Install Tomcat"
echo "# 8. Install all above"
echo "# 9. Exit Program"
echo " ########################################"
fi
}
#Read user's choice
#@丁丁历险博客(manual.blog.51cto.com)
#Read User's INPUT
choice(){
language
if [ $? -eq 0 ];then
read -p "请选择一个菜单[1-9]:" select
else
read -p "Please choice a menu[1-9]:" select
fi
}
rotate_line(){
INTERVAL=0.1
TCOUNT="0"
while :
do
TCOUNT=`expr $TCOUNT + 1`
case $TCOUNT in
"1")
echo -e '-'"\b\c"
sleep $INTERVAL
;;
"2")
echo -e '\\'"\b\c"
sleep $INTERVAL
;;
"3")
echo -e "|\b\c"
sleep $INTERVAL
;;
"4")
echo -e "/\b\c"
sleep $INTERVAL
;;
*)
TCOUNT="0";;
esac
done
}
#Install failed error messages.
#@丁丁历险博客(manual.blog.51cto.com)
error_install(){
language
if [ $? -eq 0 ];then
clear
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo -e "\033[1;34m错误:编译安装[ ${1} ]失败!\033[0m"
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
exit
else
clear
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo -e "\033[1;34mERROR:Install[ ${1} ]Failed!\033[0m"
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
exit
fi
}
#Couldn't use yum tool
error_yum(){
language
if [ $? -eq 0 ];then
clear
echo
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "错误:本机YUM不可用,请正确配置YUM后重试."
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo
exit
else
clear
echo
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "ERROR:Yum is disable,please modify yum repo file then try again."
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo
exit
fi
}
#Test target system whether have yum repo.
#Return 0 dedicate yum is enable.
#Return 1 dedicate yum is disable.
#@丁丁历险博客(manual.blog.51cto.com)
test_yum(){
#set yum configure file do not display Red Hat Subscription Management info.
sed -i '/enabled/s/1/0/' /etc/yum/pluginconf.d/subscription-manager.conf
yum clean all &>/dev/null
repolist=$(yum repolist 2>/dev/null |awk '/repolist:/{print $2}'|sed 's/,//')
if [ $repolist -le 0 ];then
error_yum
fi
}
#This function will check depend software and install them.
solve_depend(){
language
if [ $? -eq 0 ];then
echo -en "\033[1;34m正在安装依赖软件包,请稍后...\033[0m"
else
echo -e "\033[1;34mInstalling dependent software,please wait a moment...\033[0m"
fi
case $1 in
nginx)
rpmlist="gcc pcre-devel openssl-devel zlib-devel make"
;;
cmake)
rpmlist="gcc gcc-c++ make"
;;
mysql)
rpmlist="ncurses-devel"
;;
mhash)
rpmlist="gcc"
;;
libmcrypt)
rpmlist="gcc"
;;
php)
rpmlist="gcc libxml2-devel"
;;
libevent)
rpmlist="gcc"
;;
memcached)
rpmlist="gcc"
;;
memcache)
rpmlist="autoconf"
;;
java)
rpmlist="glibc.i686"
esac
for i in $rpmlist
do
rpm -q $i &>/dev/null
if [ $? -ne 0 ];then
yum -y install $i &>/dev/null
fi
done
}
#Determing how to uncompress a tar file.
#@丁丁历险博客(manual.blog.51cto.com)
untar(){
type=$(file $1 |awk '{print $2}')
if [ "$type" == "gzip" ];then
language
if [ $? -eq 0 ];then
echo -e "\033[1;34m正在解压$1,请稍后...\033[0m"
else
echo -e "\033[1;34mUncompress $1,Please wait a moment...\033[0m"
fi
tar -xzf $1
elif [ "$type" == "bzip2" ];then
language
if [ $0 -eq 0 ];then
echo -e "\033[1;34m正在解压$1,请稍后...\033[0m"
else
echo -e "\033[1;34mUncompress $1,Please wait a moment...\033[0m"
fi
tar -xjf $1
else
language
if [ $? -eq 0 ];then
clear
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo -e "\033[1;34m错误:未知的压缩包类型.\033[0m"
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
exit
else
clear
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo -e "\033[1;34mERROR:Unknow compress file type.\033[0m"
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
exit
fi
fi
}
#Display a begin mesages
begin(){
language
if [ $? -eq 0 ];then
clear
echo -e "\033[1;36m----------------------------------\033[0m"
echo -e "\033[1;32m\t现在开始安装${1}!\033[0m"
echo -e "\033[1;36m----------------------------------\033[0m"
else
clear
echo -e "\033[1;36m-----------------------------------\033[0m"
echo -e "\033[1;32m\tInstall ${1} Now!\033[0m"
echo -e "\033[1;36m-----------------------------------\033[0m"
fi
}
#If not found the software package, this script will be exit.
error_nofile(){
language
if [ $? -eq 0 ];then
clear
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo -e "\033[1;34m错误:未找到[ ${1} ]软件包,请下载软件包至当前目录.\033[0m"
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
exit
else
clear
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo -e "\033[1;34mERROR:Not found [ ${1} ] package in current directory, please download it.\033[0m"
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
exit
fi
}
#Display a hint for configure
configure_info(){
language
if [ $? -eq 0 ];then
echo -e "\033[1;34m正在检测编译环境并生成编译文件,请稍后...\033[0m"
else
echo -e "\033[1;34mCheck system environment and configure,Please wait a moment...\033[0m"
fi
}
#Display a hint for make and make install
#@丁丁历险博客(manual.blog.51cto.com)
make_info(){
language
if [ $? -eq 0 ];then
echo -e "\033[1;34m正在编译安装软件,请稍后...\033[0m"
else
echo -e "\033[1;34mComplie and install software,Please wait a moment...\033[0m"
fi
}
#Install cmake to complie MySQL
install_cmake(){
test_yum
solve_depend cmake
if [ -f ${cmake_version}.${format1} ];then
untar ${cmake_version}.${format1}
cd ${cmake_version}
configure_info
rotate_line &
disown $!
./bootstrap --prefix=/usr/local/cmake &>/dev/null
result=$?
kill -9 $!
make_info
language
if [ $? -eq 0 ];then
echo -e "\033[1;32m正常情况下软件被安装在/usr/local/cmake目录.\033[0m"
else
echo -e "\033[1;32mSoftware will be installed to /usr/local/cmake.\033[0m"
fi
if [ $result -eq 0 ];then
rotate_line &
disown $!
make &> /dev/null && make install &>/dev/null
result=$?
kill -9 $!
cd ..
if [ $result -ne 0 ];then
error_install cmake
fi
fi
else
error_nofile cmake
fi
}
install_mhash(){
test_yum
solve_depend mhash
if [ -f ${mhash_version}.${format1} ];then
untar ${mhash_version}.${format1}
cd ${mhash_version}
configure_info
rotate_line &
disown $!
./configure &>/dev/null
result=$?
kill -9 $!
if [ $result -eq 0 ];then
rotate_line &
disown $!
make &>/dev/null
make install &>/dev/null
result=$?
kill -9 $!
fi
if [ $result -ne 0 ];then
error_install mhash
fi
cd ..
if [ ! -f /usr/lib/libmhash.so ];then
ln -s /usr/local/lib/libmhash.so /usr/lib/
fi
ldconfig
else
error_nofile mhash
fi
}
install_libmcrypt(){
solve_depend libmcrypt
if [ -f ${libmcrypt_version}.${format1} ];then
untar ${libmcrypt_version}.${format1}
cd ${libmcrypt_version}
configure_info
rotate_line &
disown $!
./configure &>/dev/null
result=$?
kill -9 $!
if [ $result -eq 0 ];then
rotate_line &
disown $!
make &>/dev/null
make install &>/dev/null
result=$?
kill -9 $!
if [ $result -ne 0 ];then
error_install libmcrypt
fi
fi
cd ..
if [ ! -f /usr/lib/libmcrypt.so ];then
ln -s /usr/local/lib/libmcrypt.so /usr/lib/
fi
ldconfig
else
error_nofile libmcrypt
fi
}
#Install libevent
install_libevent(){
solve_depend libevent
if [ -f ${libevent_vertion}.${format1} ];then
untar ${libevent_vertion}.${format1}
cd ${libevent_vertion}
configure_info
./configure &>/dev/null
make &>/dev/null && make install &>/dev/null
cd ..
if [ ! -f /usr/lib/libevent.so ];then
ln -s /usr/local/lib/libevent.so /usr/lib/
fi
ldconfig
else
error_nofile libevent
fi
}
#Install Nginx
#@丁丁历险博客(manual.blog.51cto.com)
install_nginx(){
begin nginx
test_yum
solve_depend nginx
grep -q nginx /etc/passwd
if [ $? -ne 0 ];then
useradd -s /sbin/nologin nginx
fi
if [ -f ${nginx_version}.${format1} ];then
untar ${nginx_version}.${format1}
cd $nginx_version
configure_info
rotate_line &
disown $!
./configure --user=nginx --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module >/dev/null
result=$?
kill -9 $!
make_info
language
if [ $? -eq 0 ];then
echo -e "\033[1;32m正常情况下软件被安装在/usr/local/nginx目录.\033[0m"
else
echo -e "\033[1;32mSoftware will be installed to /usr/local/nginx.\033[0m"
fi
if [ $result -eq 0 ];then
rotate_line &
disown $!
make &>/dev/null && make install &>/dev/null
result=$?
kill -9 $!
cd ..
if [ $result -ne 0 ];then
error_install nginx
fi
fi
else
error_nofile Nginx
fi
}
#Install MySQL
install_mysql(){
begin mysql
test_yum
install_cmake
solve_depend mysql
grep -q mysql /etc/passwd
if [ $? -ne 0 ];then
useradd -s /sbin/nologin mysql
fi
if [ -f ${mysql_version}.${format1} ];then
untar ${mysql_version}.${format1}
cd ${mysql_version}
configure_info
rotate_line &
disown $!
/usr/local/cmake/bin/cmake . &>/dev/null
result=$?
kill -9 $!
make_info
language
if [ $? -eq 0 ];then
echo -e "\033[1;32m正常情况下软件被安装在/usr/local/mysql目录.\033[0m"
else
echo -e "\033[1;32mSoftware will be installed to /usr/local/mysql.\033[0m"
fi
if [ $result -eq 0 ];then
rotate_line &
disown $!
make &> /dev/null && make install &>/dev/null
result=$?
kill -9 $!
if [ $result -ne 0 ];then
error_install MySQL
fi
cd ..
fi
language
if [ $? -eq 0 ];then
echo -e "\033[1;34m正在初始化数据库...\033[0m"
else
echo -e "\033[1;34mInitialization database...\033[0m"
fi
/usr/local/mysql/scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data/ --basedir=/usr/local/mysql/ &>/dev/null
chown -R root.mysql /usr/local/mysql
chown -R mysql /usr/local/mysql/data
/bin/cp -f /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
/bin/cp -f /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf
echo "/usr/local/mysql/lib/" >> /etc/ld.so.conf
ldconfig
cat >> /etc/profile << EOF
PATH=\$PATH:/usr/local/mysql/bin/
export PATH
EOF
else
error_nofile mysql
fi
}
#Install PHP
install_php(){
begin php
test_yum
install_mhash
install_libmcrypt
solve_depend php
if [ -f ${php_version}.${format1} ];then
untar ${php_version}.${format1}
cd ${php_version}
configure_info
rotate_line &
disown $!
./configure --prefix=/usr/local/php5 --with-mysql=/usr/local/mysql --enable-fpm --enable-mbstring --with-mcrypt --with-mhash --with-config-file-path=/usr/local/php5/etc --with-mysqli=/usr/local/mysql/bin/mysql_config &>/dev/null
result=$?
kill -9 $!
make_info
language
if [ $? -eq 0 ];then
echo -e "\033[1;32m正常情况下软件被安装在/usr/local/php5目录.\033[0m"
else
echo -e "\033[1;32mSoftware will be installed to /usr/local/php5.\033[0m"
fi
if [ $result -eq 0 ];then
rotate_line &
disown $!
make &> /dev/null && make install &>/dev/null
result=$?
kill -9 $!
if [ $result -ne 0 ];then
error_install php
fi
/bin/cp -f php.ini-production /usr/local/php5/etc/php.ini
/bin/cp -f /usr/local/php5/etc/php-fpm.conf.default /usr/local/php5/etc/php-fpm.conf
cd ..
fi
else
error_nofile php
fi
}
#Install memcached
install_memcached(){
begin memcached
test_yum
install_libevent
solve_depend memcached
if [ -f ${memcached_version}.${format1} ];then
untar ${memcached_version}.${format1}
cd ${memcached_version}
configure_info
rotate_line &
disown $!
./configure &>/dev/null && make &>/dev/null && make install &>/dev/null
result=$?
kill -9 $!
if [ $result -ne 0 ];then
error_install memcached
fi
cd ..
else
error_nofile memcached
fi
}
#Install memcahe module for php
install_memcache(){
begin memcache
if [ ! -f /usr/local/php5/bin/phpize ];then
language
if [ $? -eq 0 ];then
clear
echo -e "\033[1;34m错误:未安装PHP.\033[0m"
exit
else
clear
echo -e "\033[1;34mERROR:Can't found PHP.\033[0m"
exit
fi
else
if [ -f ${memcache_version}.${format2} ];then
untar ${memcache_version}.${format2}
cd ${memcache_version}
solve_depend memcache
configure_info
rotate_line &
disown $!
/usr/local/php5/bin/phpize . &>/dev/null
./configure --with-php-config=/usr/local/php5/bin/php-config --enable-memcache &>/dev/null
make_info
make &>/dev/null && make install &>/dev/null
result=$?
kill $!
if [ $result -ne 0 ];then
error_install memcache
fi
cd ..
sed -i '728i extension_dir = "/usr/local/php5/lib/php/extensions/no-debug-non-zts-20100525/"' /usr/local/php5/etc/php.ini
sed -i '856i extension=memcache.so' /usr/local/php5/etc/php.ini
fi
fi
}
#Install JRE
install_java(){
begin JAVA
solve_depend java
if [ -f jdk1.6.0_27.tar.gz ];then
tar -xzf jdk1.6.0_27.tar.gz &>/dev/null
if [ ! -e /usr/local/jdk ];then
mv jdk1.6.0_27/ /usr/local/jdk
fi
cat >> /etc/profile <<EOF
export JRE_HOME=/usr/local/jdk
export JAVA_BIN=/usr/local/jdk/bin
export PATH=/usr/local/jdk/bin:$PATH
export CLASSPATH=.:/usr/local/jdk/lib/dt.jar:$JRE_HOME/lib/tools.jar
export JRE_HOME JAVA_BIN PATH CLASSPATH
EOF
source /etc/profile
else
error_nofile JAVA
fi
}
#Install Tomcat
install_tomcat(){
begin Tomcat
if [ -f apache-tomcat-6.0.32.tar.gz ];then
tar -xzf apache-tomcat-6.0.32.tar.gz &>/dev/null
if [ ! -e /usr/local/tomcat ];then
mv apache-tomcat-6.0.32 /usr/local/tomcat
fi
if [ -f session.tar.gz ];then
tar -xzf session.tar.gz &> /dev/null
cp session/* /usr/local/tomcat/lib/
fi
else
error_nofile tomcat
fi
}
while :
do
menu
choice
case $select in
1)
install_nginx
;;
2)
install_mysql
;;
3)
install_php
;;
4)
install_memcached
;;
5)
install_memcache
;;
6)
install_java
;;
7)
install_tomcat
;;
8)
install_nginx
install_mysql
install_php
install_memcached
install_memcache
install_java
install_tomcat
;;
9)
exit
;;
*)
echo "@丁丁历险博客(manual.blog.51cto.com)"
esac
done很好奇,就使用rubyonrails自动化单元测试而言,你们正在做什么?您是否创建了一个脚本来在cron中运行rake作业并将结果邮寄给您?git中的预提交Hook?只是手动调用?我完全理解测试,但想知道在错误发生之前捕获错误的最佳实践是什么。让我们理所当然地认为测试本身是完美无缺的,并且可以正常工作。下一步是什么以确保他们在正确的时间将可能有害的结果传达给您? 最佳答案 不确定您到底想听什么,但是有几个级别的自动代码库控制:在处理某项功能时,您可以使用类似autotest的内容获得关于哪些有效,哪些无效的即时反馈。要确保您的提
我正在寻找执行以下操作的正确语法(在Perl、Shell或Ruby中):#variabletoaccessthedatalinesappendedasafileEND_OF_SCRIPT_MARKERrawdatastartshereanditcontinues. 最佳答案 Perl用__DATA__做这个:#!/usr/bin/perlusestrict;usewarnings;while(){print;}__DATA__Texttoprintgoeshere 关于ruby-如何将脚
我有一个在Linux服务器上运行的ruby脚本。它不使用rails或任何东西。它基本上是一个命令行ruby脚本,可以像这样传递参数:./ruby_script.rbarg1arg2如何将参数抽象到配置文件(例如yaml文件或其他文件)中?您能否举例说明如何做到这一点?提前谢谢你。 最佳答案 首先,您可以运行一个写入YAML配置文件的独立脚本:require"yaml"File.write("path_to_yaml_file",[arg1,arg2].to_yaml)然后,在您的应用中阅读它:require"yaml"arg
我收到这个错误:RuntimeError(自动加载常量Apps时检测到循环依赖当我使用多线程时。下面是我的代码。为什么会这样?我尝试多线程的原因是因为我正在编写一个HTML抓取应用程序。对Nokogiri::HTML(open())的调用是一个同步阻塞调用,需要1秒才能返回,我有100,000多个页面要访问,所以我试图运行多个线程来解决这个问题。有更好的方法吗?classToolsController0)app.website=array.join(',')putsapp.websiteelseapp.website="NONE"endapp.saveapps=Apps.order("
我是Google云的新手,我正在尝试对其进行首次部署。我的第一个部署是RubyonRails项目。我基本上是在关注thisguideinthegoogleclouddocumentation.唯一的区别是我使用的是我自己的项目,而不是他们提供的“helloworld”项目。这是我的app.yaml文件runtime:customvm:trueentrypoint:bundleexecrackup-p8080-Eproductionconfig.ruresources:cpu:0.5memory_gb:1.3disk_size_gb:10当我转到我的项目目录并运行gcloudprevie
我可以在Azure网站上部署RubyonRails吗? 最佳答案 还没有。目前仅支持.NET和PHP。 关于ruby-on-rails-RubyonRails可以部署在Azure网站上吗?,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/12964010/
我们目前正在为ROR3.2开发自定义cms引擎。在这个过程中,我们希望成为我们的rails应用程序中的一等公民的几个类类型起源,这意味着它们应该驻留在应用程序的app文件夹下,它是插件。目前我们有以下类型:数据源数据类型查看我在app文件夹下创建了多个目录来保存这些:应用/数据源应用/数据类型应用/View更多类型将随之而来,我有点担心应用程序文件夹被这么多目录污染。因此,我想将它们移动到一个子目录/模块中,该子目录/模块包含cms定义的所有类型。所有类都应位于MyCms命名空间内,目录布局应如下所示:应用程序/my_cms/data_source应用程序/my_cms/data_ty
//1.验证返回状态码是否是200pm.test("Statuscodeis200",function(){pm.response.to.have.status(200);});//2.验证返回body内是否含有某个值pm.test("Bodymatchesstring",function(){pm.expect(pm.response.text()).to.include("string_you_want_to_search");});//3.验证某个返回值是否是100pm.test("Yourtestname",function(){varjsonData=pm.response.json
前置步骤我们都操作完了,这篇开始介绍jenkins的集成。话不多说,看操作1、登录进入jenkins后会让你选择安装插件,选择第一个默认的就行。安装完成后设置账号密码,重新登录。2、配置JDK和Git都需要执行路径,所以需要先把执行路径找到,先进入服务器的docker容器,2.1JDK的路径root@69eef9ee86cf:/usr/bin#echo$JAVA_HOME/usr/local/openjdk-82.2Git的路径root@69eef9ee86cf:/#whichgit/usr/bin/git3、先配置JDK和Git。点击:ManageJenkins>>GlobalToolCon
深度学习部署:Windows安装pycocotools报错解决方法1.pycocotools库的简介2.pycocotools安装的坑3.解决办法更多Ai资讯:公主号AiCharm本系列是作者在跑一些深度学习实例时,遇到的各种各样的问题及解决办法,希望能够帮助到大家。ERROR:Commanderroredoutwithexitstatus1:'D:\Anaconda3\python.exe'-u-c'importsys,setuptools,tokenize;sys.argv[0]='"'"'C:\\Users\\46653\\AppData\\Local\\Temp\\pip-instal