Skip to content

Instantly share code, notes, and snippets.

@BinWang0213
Last active July 15, 2022 03:33
Show Gist options
  • Save BinWang0213/175516b6c13a543d55baea89114452d7 to your computer and use it in GitHub Desktop.
Save BinWang0213/175516b6c13a543d55baea89114452d7 to your computer and use it in GitHub Desktop.
Install cloud web platform on centos

mysql + flask

Login:

#web platform
ssh -X root@10.78.4.176
password: oaQpcah1a#lcm

#DB platform
ssh -X root@10.78.4.178
password: oaQpcah1a#lcm

#Check linux version
cat /etc/centos-release
#CentOS Linux release 7.9.2009 (Core)

#check packages installed
cd /opt/
yum list installed > my_list.txt

Setup testing environment on docker

#Using node for faster compile
docker run -ti --name centos79 centos:centos7.9.2009 -p 5000:5000
docker run -d -p 5000:5000 -ti --name centos79 --privileged -v G:/CentOS:/opt/ centos:centos7.9.2009 
docker run -dti -m 3g -p 8000:8000 --name centos77 -v G:/CentOS:/opt/ centos:centos7.7.1908 /bin/bash

#setup a non-root user
adduser bwang31
passwd bwang31
1234
1234
sudo usermod -aG wheel bwang31
id bwang31

#login centos as non-root and root user
docker exec -u bwang31 -it centos79 bash
docker exec -u 0 -it centos79 bash

Environment checking and install some essential software for easiler usage

#Baidu
ping www.baidu.com -c 3

cd /opt

#check some pkg is installed
rpm -qa | grep pkg_name

######
#Wget#
######
yumdownloader wget
yum localinstall -y wget-*.rpm

######
#which#
######
yumdownloader which
yum localinstall -y which-*.rpm

######
#make#
######
yumdownloader make
yum localinstall -y make-*.rpm

#####
#gcc#
#####
mkdir gcc && cd gcc
yumdownloader gcc
yumdownloader gcc-c++
yum localinstall --downloadonly --downloaddir=$(pwd) gcc-*.rpm
yum -y --disablerepo=* localinstall *.rpm

#################
#Option1: python#
#################
mkdir python && cd python

#dependency
mkdir deps && cd deps
yumdownloader openssl-devel bzip2-devel libffi-devel -y
yum localinstall --downloadonly --downloaddir=$(pwd) openssl-*.rpm
yum localinstall --downloadonly --downloaddir=$(pwd) bzip2-*.rpm
yum localinstall --downloadonly --downloaddir=$(pwd) libffi-*.rpm
yum --disablerepo=* localinstall *.rpm
cd ..

wget https://www.python.org/ftp/python/3.9.12/Python-3.9.12.tgz
tar -xf Python-3.9.12.tgz

cd Python-3.9.12
./configure --enable-optimizations
make altinstall -j 4

python3.9 -V  
python -V  
pip3.9 -V

####################
#Option2: miniconda#
####################
#this is suitable for 
cd /opt/
mkdir miniconda && cd miniconda
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
#copy to cluster using MobaXterm
sh Miniconda3-latest-Linux-x86_64.sh
chmod +x *
> yes
> install

#setup China channel
conda config --set show_channel_urls yes
cp ~/.condarc /opt/
#copy contents from https://mirrors.tuna.tsinghua.edu.cn/help/anaconda/ to .condarc
cp /opt/.condarc ~/

python -V  #3.9.12
pip -V     #21.2.4
conda -V   #4.12.0

#########
#service#
#########
mkdir service && cd service
yumdownloader initscripts
yum localinstall --downloadonly --downloaddir=$(pwd) initscripts-*.rpm
#copy to cluster using MobaXterm
chmod +x *
yum -y --disablerepo=* localinstall *.rpm


#######
#mysql#
#######
#https://www.tecmint.com/install-latest-mysql-on-rhel-centos-and-fedora/
#https://dev.mysql.com/downloads/repo/yum/
#https://stackoverflow.com/questions/43090321/yum-local-install-to-install-a-package-with-its-dependency

cd /opt
mkdir mysql && cd mysql
wget https://repo.mysql.com/mysql80-community-release-el7-6.noarch.rpm
yum localinstall -y mysql80-community-release-el7-6.noarch.rpm
yumdownloader mysql-community-server

yum localinstall --downloadonly --downloaddir=$(pwd) mysql-community-server-*.rpm
#copy to cluster using MobaXterm
chmod +x *
yum -y --disablerepo=* localinstall *.rpm

#error handling of conflict version
#https://learnku.com/articles/35042
#Error : mysql57-community-release conflicts with mysql80-community-release-el8-1.noarch
rpm -e --nodeps mysql57-community-release-el7-8.noarch

#start service
service mysqld start
systemctl enable mysqld.service

systemctl status mysqld.service
service mysqld status

#restart services
service mysqld restart

#show temp password
grep "A temporary password" /var/log/mysqld.log

#change the root password for the local mysql
mysql_secure_installation

Install the web platform

#https://imshuai.com/python-pip-install-package-offline-tensorflow

#Get our code from gitee
#https://gitee.com/water-jet-lab/Drilling-Risk-Detection-Platform

#unzip to opt/web/ folder

#Dump packages with dependencies
pip freeze > requirement.txt

#Get virtualenv 
pip download virtualenv -d packages

#Install packages using downloaded one
pip install --no-index --find-links=packages virtualenv

#check list
pip list

Create a virtual env using conda for each web app

#create a virtual env for backend
conda create -y --name DSE_env --offline
conda activate DSE_env

#Get the offline python packages
cd /opt/web/Drilling-Risk-Detection-Platform-master
pip download -r requirements.txt -d packages

#Install packages using downloaded one
cd /opt/web/Drilling-Risk-Detection-Platform-master
pip install --no-index --find-links=packages -r requirements.txt

#check instllation
pip list

#deactive or remove it if necessary
conda deactivate
conda env remove --name DSE_env

Install the node.js

cd /opt
mkdir nodejs && cd nodejs

#add nodejs source
yum install epel-release

#download nodejs
yumdownloader nodejs
yum localinstall --downloadonly --downloaddir=$(pwd) nodejs-*.rpm

#install nodejs locally
yum -y --disablerepo=* localinstall *.rpm

#test node.js=16.15.0
node -v

cd /opt
mkdir npm && cd npm
yumdownloader npm
yum localinstall --downloadonly --downloaddir=$(pwd) npm-*.rpm

yum -y --disablerepo=* localinstall *.rpm

#test npm=8.5.5
npm -v

#setup China mirror
npm config set registry=http://registry.npm.taobao.org
npm config get registry

Download and run front-end packages

cd /opt/web/Drilling-Risk-Detection-Platform-master
cd front-end_v2.0

#install packages in packages.json, similar to requirments
npm install -–save

#copy this folder to target cluster
#install it by simply
npm install -g

#run it
npm run start

#Starting the development server...
#Search for the keywords to learn more about each warning.
#To ignore, add // eslint-disable-next-line to the line before.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment