CentOS7 离线安装fastDFS、jdk1.8、mysql5.7、nginx、libreOffice
生活随笔
收集整理的這篇文章主要介紹了
CentOS7 离线安装fastDFS、jdk1.8、mysql5.7、nginx、libreOffice
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
**因工作需要,在內網環境下安裝運行環境,故寫成腳本以供參考。
以下軟件已在CentOS7下離線安裝成功,成功后個別配置文件(fastDFS,nginx等)需手動配置,腳本中不再贅述。
先說下離線安裝包在linux中的放置路徑:/opt/install_package
install_package文件夾下面文件列表:
?fastDFS:
?
jdk1.8
LibreOffice
mysql 5.7
?nginx
**完整shell代碼如下
#!/bin/bash function install_JDK(){java -version >> /dev/null 2>&1if [ $? -eq 0 ];thenecho "**************JDK is already installed***************"returnfiif [ ! -f "/opt/install_package/jdk1.8/jdk1.8.tar.gz" ];thenecho "*****************JDK installation package does not exist******************"returnfiecho "begin to install jdk"cd jdk1.8tar zxvf jdk1.8.tar.gz -C /usr/local/chmod 777 /usr/local/jdk1.8/bin/javachmod 777 /usr/local/jdk1.8/bin/javacecho 'JAVA_HOME=/usr/local/jdk1.8' >> ~/.bash_profileecho 'JAVA_BIN=$JAVA_HOME/bin' >> ~/.bash_profileecho 'JRE_HOME=$JiAVA_HOME/jre' >> ~/.bash_profileecho 'JRE_BIN=$JRE_HOME/bin' >> ~/.bash_profileecho 'PATH=$JAVA_BIN:$JRE_BIN:$PATH' >> ~/.bash_profileecho 'export JAVA_HOME JRE_HOME PATH' >> ~/.bash_profilesource ~/.bash_profilejava -versionif [ $? -eq 0 ];thenecho "JDK installed successfully"elseecho "jdk install failed!"fi } function install_mysql(){isExit=`ps -ef | grep mysql| grep -v grep`if [ -n "${isExit}" ];thenecho "**********************MySQL is already installed*****************************"returnfiif [ ! -f "mysql/mysql-5.7.9-1.el7.x86_64.rpm-bundle.tar" ];thenecho "*****************MySQL installation package does not exist******************"returnfiecho "**************begin to install mysql*********************"cp -rf mysql /usr/local/cd /usr/local/mysqltar xvf mysql-5.7.9-1.el7.x86_64.rpm-bundle.tarrpm -ivh mysql-community-common-5.7.9-1.el7.x86_64.rpm rpm -ivh mysql-community-libs-5.7.9-1.el7.x86_64.rpm --nodeps --forcerpm -ivh mysql-community-devel-5.7.9-1.el7.x86_64.rpm --nodeps --forcerpm -ivh mysql-community-libs-compat-5.7.9-1.el7.x86_64.rpm --nodeps --forcerpm -ivh mysql-community-client-5.7.9-1.el7.x86_64.rpm --nodeps --forcerpm -ivh mysql-community-server-5.7.9-1.el7.x86_64.rpm --nodeps --forceservice mysqld stopecho "skip-grant-tables" >> /etc/my.cnfservice mysqld start echo "****************mysql install sucessed**********************"echo "****account:root,password is empty,Please change the password in time****" } function install_nginx(){isExit=`ps -ef | grep nginx |grep -v grep`if [ -n "${isExit}" ];thenecho "**********************Nginx is already installed*****************************"returnfiif [ ! -d "nginx" ];thenecho "Nginx installation package does not exist"returnfipacakgeNum=`ls nginx|wc -w`if [ ${pacakgeNum} -ne 4 ];thenecho "*********************Wrong number of installation packages*******************"returnfiecho "**********************begin to install nginx***********************" cp -rf nginx /usr/local/cd /usr/local/nginxtar zxvf openssl-fips-2.0.10.tar.gzcd openssl-fips-2.0.10./config && make && make installcd ..tar zxvf pcre-8.42.tar.gzcd pcre-8.42./configure && make && make installcd ..tar zxvf zlib-1.2.11.tar.gzcd zlib-1.2.11./configure && make && make installcd ..tar zxvf nginx-1.14.2.tar.gzcd nginx-1.14.2./configure && make && make installln -s /usr/local/lib/libpcre.so.1 /lib64/path=`whereis nginx |awk -F: '{print $2}'`systemctl stop firewalld.service${path}/sbin/nginxif [ $? -eq 0 ];thenecho "****************Nginx installed successfully***********************"elseecho "****************Nginx installation failed**************************"fi } function isntall_LibreOffice(){ isExit=`ps -ef | grep libreoffice5.3 | grep -v grep`if [ -n "${isExit}" ];thenecho "*******************Libreoffice is already installed**********************"returnfiif [ ! -f "libreOffice/LibreOffice_5.3.7_Linux_x86-64_rpm.tar.gz" ];thenecho "*****************LibreOffice installation package does not exist******************"returnfitar zxvf libreOffice/LibreOffice_5.3.7_Linux_x86-64_rpm.tar.gz -C /usr/local/cd /usr/local/LibreOffice_5.3.7.2_Linux_x86-64_rpm/RPMSrpm -ivh *.rpmcd /opt/libreoffice5.3/program./soffice --headless --accept="socket,host=127.0.0.1,port=8100;urp;" --nofirststartwizard &isExit=`ps -ef | grep libreoffice5.3 | grep -v grep`if [ -n "${isExit}" ];thenecho "*******************Libreoffice installed successfully**********************"elseecho "*******************Libreoffice installation failed*************************"fi} function install_fastDFS(){while read -p "請輸入fastDFS服務器ip地址:" cur_ipdoipcalc -cs ${cur_ip}if [ "$?" -eq 0 ];thenbreakelse echo "ip地址填寫錯誤,請重新填寫!"continuefidonecp -rf fastDFS /usr/local/cd /usr/local/fastDFStar zxvf libevent-2.0.22-stable.tar.gzcd libevent-2.0.22-stable./configure --prefix=/data/libeventcd /usr/local/fastDFStar -zxvf libfastcommon.tar.gzcd libfastcommon./make.sh./make.sh installln -s /usr/lib64/libfastcommon.so /usr/local/lib/libfastcommon.socd /usr/local/fastDFS/tar -zxvf FastDFS_v5.05.tar.gzcd FastDFSold='TARGET_PREFIX=$DESTDIR/usr'new='TARGET_PREFIX=$DESTDIR/usr/local'sed -i "s#$old#$new#g" make.sh./make.sh && ./make.sh install####配置tracker.confmkdir -p /data/fdfs/trackercp /etc/fdfs/tracker.conf.sample /etc/fdfs/tracker.confold=`cat /etc/fdfs/tracker.conf | grep "^base_path="`new="base_path=/data/fdfs/tracker"sed -i "s#$old#$new#g" /etc/fdfs/tracker.confif [ ! -f "/etc/init.d/fdfs_trackerd" ];thencp -rf /usr/local/fastDFS/FastDFS/init.d/fdfs_trackerd /etc/init.d/fi##設置trackerd開機自啟chkconfig --add fdfs_trackerdchkconfig fdfs_trackerd onservice fdfs_trackerd start##配置storage.confmkdir -p /data/fdfs/storagecp /etc/fdfs/storage.conf.sample /etc/fdfs/storage.confold=`cat /etc/fdfs/storage.conf | grep "^base_path="`new="base_path=/data/fdfs/storage"sed -i "s#$old#$new#g" /etc/fdfs/storage.confold=`cat /etc/fdfs/storage.conf | grep "^store_path0="`new="store_path0=/data/fdfs/storage"sed -i "s#$old#$new#g" /etc/fdfs/storage.confold=`cat /etc/fdfs/storage.conf | grep "^tracker_server="`new="tracker_server=${cur_ip}:22122" sed -i "s#$old#$new#g" /etc/fdfs/storage.confif [ ! -f "/etc/init.d/fdfs_storaged" ];thencp -rf /usr/local/fastDFS/FastDFS/init.d/fdfs_storaged /etc/init.d/fi##設置tracker開機自啟chkconfig --add fdfs_storagedchkconfig fdfs_storaged onservice fdfs_storaged start##配置client.confcp /etc/fdfs/client.conf.sample /etc/fdfs/client.confold=`cat /etc/fdfs/client.conf | grep "^base_path="`new="base_path=/data/fdfs/tracker"sed -i "s#$old#$new#g" /etc/fdfs/client.confold=`cat /etc/fdfs/client.conf | grep "^tracker_server="`new="tracker_server=${cur_ip}:22122"sed -i "s#$old#$new#g" /etc/fdfs/client.conf##獲取tracker配置端口,需與client.conf保持一致 tracker_port=`cat /etc/fdfs/tracker.conf | grep "^http.server_port="|awk -F= '{print $2}'`old=`cat /etc/fdfs/client.conf | grep "http.tracker_server_port="`new="http.tracker_server_port=${tracker_port}"sed -i "s#$old#$new#g" /etc/fdfs/client.confecho "*******************fastDFS installed successfully**********************"echo "path of storage.conf is /etc/fdfs/storage.conf"echo "path of tracker.conf is /etc/fdfs/tracker.conf"echo "path of client.conf is /etc/fdfs/tracker.conf"echo "path of data is /data/fdfs/storage/data"}Tips=" 此腳本用來一鍵安裝各種應用程序軟件,包括jdk、應用程序、nginx等\n 1、離線安裝jdk并配置環境變量\n 2、離線安裝nginx\n 3、離線安裝mysql\n 4、離線安裝word轉pdf打印服務(Libreoffice)\n 5、離線安裝fastDFS\n 0、 退出 " echo -e ${Tips} while read -p "請輸入您的操作序號:" val doif [ "$val" == "0" ];thenbreakelif [ "$val" == "1" ];theninstall_JDKecho -e ${Tips}continueelif [ "$val" == "2" ];theninstall_nginxecho -e ${Tips}continueelif [ "$val" == "3" ];theninstall_mysqlecho -e ${Tips}continueelif [ "$val" == "4" ];thenisntall_LibreOfficeecho -e ${Tips}continueelif [ "$val" == "5" ];theninstall_fastDFSecho -e ${Tips}continueelse echo "Wrong number input, please input again ."fi done?離線安裝包(1G)下載鏈接: https://pan.baidu.com/s/14_NbibeuGwf35K4CmZ7HzQ 提取碼: 829i
總結
以上是生活随笔為你收集整理的CentOS7 离线安装fastDFS、jdk1.8、mysql5.7、nginx、libreOffice的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 电力电子 中英 对照
- 下一篇: 汽车维修企业管理【2】