centos安裝python/supervisor/nginx指令碼
阿新 • • 發佈:2022-05-16
"""命令有風險,執行需謹慎"""
1、安裝python38
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel gcc mkdir /tmp/python38 cd /tmp/python38 yum -y install wget wget https://www.python.org/ftp/python/3.8.0/Python-3.8.0.tar.xz xz -d Python-3.8.0.tar.xz tar -xvf Python-3.8.0.tar cd Python-3.8.0 mkdir /usr/local/python38 ./configure --with-ssl --prefix=/usr/local/python38 make && make install ln -s /usr/local/python38/bin/python3.8 /usr/bin/python3 ln -s /usr/local/python38/bin/python3.8 /usr/bin/python ln -s /usr/local/python38/bin/pip3.8 /usr/bin/pip3 pip3 install --upgrade pip if [ -f "/usr/bin/python2" ];then sed -i "1c #! /usr/bin/python2" /usr/bin/yum fi cd . rm -rf /tmp/python38
2、安裝supervisor
#!/usr/bin/env bash python -m pip install supervisor systemctl enable supervisor cp /usr/local/python38/bin/*supervisor* /usr/bin echo_supervisord_conf > /etc/supervisord.conf while true; do read -r -p "請輸入supervisor要執行的程式名稱(為空表示結束): " run_excute if [ "$run_excute" == "" ]; then break fi read -r -p "請輸入執行命令(如 python /home/test.py >>log.log 2>&1 &): " run_cmd read -r -p "請輸入啟動時長(預設5): " run_start_time if [ "$run_start_time" == "" ]; then run_start_time="5" fi read -r -p "請輸入啟動失敗時的重啟次數(預設3): " restart_time if [ "$restart_time" == "" ]; then restart_time="3" fi res_string=" [program:$run_excute] command=$run_cmd startsecs=$run_start_time startretries=$restart_time " echo "$res_string" >> /etc/supervisord.conf done while true; do read -r -p "是否重啟supervisor? [y/n]" yes_no if [ "$yes_no" == "y" ]; then supervisorctl restart all break else if [ "$yes_no" == "n" ]; then break fi fi done
3、安裝nginx
#!/usr/bin/env bash yum -y install gcc pcre-devel zlib-devel net-tools wget mkdir -p /tmp/nginx_install cd /tmp/nginx_install wget http://nginx.org/download/nginx-1.21.6.tar.gz tar -zxf nginx-1.21.6.tar.gz cd nginx-1.21.6 && ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_stub_status_module make && make install nginx=/usr/local/nginx/sbin/nginx $nginx $nginx -s reload cd . rm -rf /tmp/nginx_install