Linux一键安装部署环境
生活随笔
收集整理的這篇文章主要介紹了
Linux一键安装部署环境
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
安裝Java環(huán)境
yum install -y java-1.8.0-openjdk-devel.x86_64安裝mariadb
1. vi install-mariadb.sh 創(chuàng)建文件并打開 2. 輸入 i 進入編輯(復制一下內(nèi)容粘貼)#!/bin/bash MARIADB_DIR=/usr/local/mariadb DATA_DIR=/data/mariadb MARIADB_VER=10.3.27 ROOT_PASSWORD=123456 # 創(chuàng)建數(shù)據(jù)存放目錄 mkdir -p ${DATA_DIR} # 創(chuàng)建mysql的用戶做為mariadb的運行用戶 useradd -r mysql -s /sbin/nologin # 下載 cd /usr/local/src wget https://mirrors.tuna.tsinghua.edu.cn/mariadb/mariadb-${MARIADB_VER}/bintar-linux-systemd-x86_64/mariadb-${MARIADB_VER}-linux-systemd-x86_64.tar.gz tar -zxvf mariadb-${MARIADB_VER}-linux-systemd-x86_64.tar.gz mv mariadb-${MARIADB_VER}-linux-systemd-x86_64 ${MARIADB_DIR} ln -s ${MARIADB_DIR} /usr/local/mysql chown -R mysql.mysql /usr/local/mysql/ # 授權(quán) chown -R mysql.mysql ${DATA_DIR} # my.conf configuration cat > /etc/my.cnf <<EOF [mysqld] port = 3306 character-set-server = utf8 collation-server = utf8_general_ci datadir = ${DATA_DIR} socket = /tmp/mysql.sock skip-external-locking key_buffer_size = 384M max_allowed_packet = 1M table_open_cache = 512 sort_buffer_size = 2M read_buffer_size = 2M read_rnd_buffer_size = 8M myisam_sort_buffer_size = 64M thread_cache_size = 8 query_cache_size = 32M EOF cd ${MARIADB_DIR} ./scripts/mysql_install_db --datadir=${DATA_DIR} --user=mysql # 設置開機自啟動 cp ${MARIADB_DIR}/support-files/mysql.server /etc/init.d/mysqld chkconfig --add mysqld chkconfig mysqld on service mysqld start ${MARIADB_DIR}/bin/mysql -e "grant all privileges on *.* to root@'127.0.0.1' identified by \"${ROOT_PASSWORD}\" with grant option;" ${MARIADB_DIR}/bin/mysql -e "grant all privileges on *.* to root@'localhost' identified by \"${ROOT_PASSWORD}\" with grant option;" ${MARIADB_DIR}/bin/mysql -uroot -p${ROOT_PASSWORD} -e "delete from mysql.user where Password='';" ${MARIADB_DIR}/bin/mysql -uroot -p${ROOT_PASSWORD} -e "delete from mysql.db where User='';" ${MARIADB_DIR}/bin/mysql -uroot -p${ROOT_PASSWORD} -e "delete from mysql.proxies_priv where Host!='localhost';" ${MARIADB_DIR}/bin/mysql -uroot -p${ROOT_PASSWORD} -e "drop database test;" # 添加環(huán)境變量 echo 'PATH=/usr/local/mysql/bin:$PATH' >> /etc/profile.d/mysql.sh # 刷新環(huán)境變量 . /etc/profile.d/mysql.sh 3. 按 Esc 輸入 :wq! 4. 授權(quán)文件為可執(zhí)行命令: chmod 777 install-mariadb.sh 5. 安裝wget命令: yum -y install wget 6. 執(zhí)行安裝mariadb命令 ./install-mariadb.sh安裝 Nginx install-nginx.sh
#!/bin/bash # 版本 NGINX_VERSION=1.16.0 # 安裝目錄 NGINX_DIR=/usr/local/nginx # 安裝依賴 yum install -y gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel wget # 下載 cd /usr/local/src wget http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz # 解壓 tar -zxvf nginx-${NGINX_VERSION}.tar.gz # 安裝 cd nginx-1.16.0 ./configure --prefix=${NGINX_DIR} --with-http_stub_status_module --with-http_ssl_module make install # 設置為系統(tǒng)服務 cat > /etc/systemd/system/nginx.service <<EOF [Unit] Description=nginx service After=network.target [Service] Type=forking ExecStart=${NGINX_DIR}/sbin/nginx ExecReload=${NGINX_DIR}/sbin/nginx -s reload ExecStop=${NGINX_DIR}/sbin/nginx -s quit PrivateTmp=true [Install] WantedBy=multi-user.target EOF # 刷新 systemctl daemon-reload # 設置開機自啟 systemctl enable nginx # 啟動 systemctl start nginx安裝redis install-redis.sh
#!/bin/bash # 版本 REDIS_VERSION=5.0.9 # 安裝目錄 REDIS_DIR=/usr/local/redis # 安裝依賴 yum install -y gcc # 下載 cd /usr/local/src wget http://download.redis.io/releases/redis-${REDIS_VERSION}.tar.gz # 解壓 tar -zxvf redis-${REDIS_VERSION}.tar.gz # 安裝 cd redis-${REDIS_VERSION} make install PREFIX=${REDIS_DIR} # 復制配置文件 cp /usr/local/src/redis-${REDIS_VERSION}/redis.conf ${REDIS_DIR}/bin/ # 配置后臺啟動 sed -i 's/daemonize no/daemonize yes/g' ${REDIS_DIR}/bin/redis.conf # 設置為系統(tǒng)服務 cat > /etc/systemd/system/redis.service <<EOF [Unit] Description=redis-server After=network.target [Service] Type=forking ExecStart=${REDIS_DIR}/bin/redis-server ${REDIS_DIR}/bin/redis.conf PrivateTmp=true [Install] WantedBy=multi-user.target EOF # 刷新 systemctl daemon-reload # 設置開機自啟 systemctl enable redis # 啟動 systemctl start redis總結(jié)
以上是生活随笔為你收集整理的Linux一键安装部署环境的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: pcd 地图转 栅格地图
- 下一篇: linux afs3服务,AFS配置3