用shell脚本写一个安装postgresql,nginx,rabbitmq,zookeeper的脚本,具体流程详细点,不要用apt的方式,然后指定安装
时间: 2024-06-09 18:08:05 浏览: 194
CentOS 一键安装PostgreSQL10.2(可更改版本)shell脚本
5星 · 资源好评率100%
以下是一个简单的安装脚本,可以安装 PostgreSQL、Nginx、RabbitMQ 和 Zookeeper。该脚本使用源代码编译和安装这些软件,因此需要一些时间。
```bash
#!/bin/bash
# Define software versions
POSTGRESQL_VERSION=13.2
NGINX_VERSION=1.20.1
RABBITMQ_VERSION=3.9.5
ZOOKEEPER_VERSION=3.7.0
# Define installation directories
POSTGRESQL_INSTALL_DIR=/usr/local/pgsql
NGINX_INSTALL_DIR=/usr/local/nginx
RABBITMQ_INSTALL_DIR=/usr/local/rabbitmq
ZOOKEEPER_INSTALL_DIR=/usr/local/zookeeper
# Install PostgreSQL
echo "Installing PostgreSQL ${POSTGRESQL_VERSION}..."
wget https://ftp.postgresql.org/pub/source/v${POSTGRESQL_VERSION}/postgresql-${POSTGRESQL_VERSION}.tar.gz
tar xf postgresql-${POSTGRESQL_VERSION}.tar.gz
cd postgresql-${POSTGRESQL_VERSION}
./configure --prefix=${POSTGRESQL_INSTALL_DIR}
make && make install
cd ..
rm postgresql-${POSTGRESQL_VERSION}.tar.gz
# Install Nginx
echo "Installing Nginx ${NGINX_VERSION}..."
wget https://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz
tar xf nginx-${NGINX_VERSION}.tar.gz
cd nginx-${NGINX_VERSION}
./configure --prefix=${NGINX_INSTALL_DIR}
make && make install
cd ..
rm nginx-${NGINX_VERSION}.tar.gz
# Install RabbitMQ
echo "Installing RabbitMQ ${RABBITMQ_VERSION}..."
wget https://github.com/rabbitmq/rabbitmq-server/releases/download/v${RABBITMQ_VERSION}/rabbitmq-server-generic-unix-${RABBITMQ_VERSION}.tar.xz
tar xf rabbitmq-server-generic-unix-${RABBITMQ_VERSION}.tar.xz
mv rabbitmq_server-${RABBITMQ_VERSION} ${RABBITMQ_INSTALL_DIR}
rm rabbitmq-server-generic-unix-${RABBITMQ_VERSION}.tar.xz
# Install Zookeeper
echo "Installing Zookeeper ${ZOOKEEPER_VERSION}..."
wget https://downloads.apache.org/zookeeper/zookeeper-${ZOOKEEPER_VERSION}/apache-zookeeper-${ZOOKEEPER_VERSION}-bin.tar.gz
tar xf apache-zookeeper-${ZOOKEEPER_VERSION}-bin.tar.gz
mv apache-zookeeper-${ZOOKEEPER_VERSION}-bin ${ZOOKEEPER_INSTALL_DIR}
rm apache-zookeeper-${ZOOKEEPER_VERSION}-bin.tar.gz
# Add software to PATH
echo "Adding software directories to PATH..."
echo "export PATH=${POSTGRESQL_INSTALL_DIR}/bin:${NGINX_INSTALL_DIR}/sbin:${RABBITMQ_INSTALL_DIR}/sbin:${ZOOKEEPER_INSTALL_DIR}/bin:\$PATH" >> ~/.bashrc
echo "Installation complete!"
```
请注意,此脚本仅适用于 Linux 系统。在运行脚本之前,请确保您有管理员权限。另外,此脚本使用了硬编码的版本号和安装目录,您需要根据您的需求进行修改。
阅读全文