-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·80 lines (64 loc) · 2.19 KB
/
install.sh
File metadata and controls
executable file
·80 lines (64 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/bash
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Check if running as root
if [ "$EUID" -ne 0 ]; then
echo -e "${RED}Please run as root${NC}"
exit 1
fi
echo -e "${GREEN}Installing FastHTTP for RHEL...${NC}"
# Detect RHEL version
if [ -f /etc/redhat-release ]; then
RHEL_VERSION=$(cat /etc/redhat-release)
echo -e "${YELLOW}Detected: $RHEL_VERSION${NC}"
else
echo -e "${YELLOW}Warning: This script is designed for RHEL/CentOS/Rocky Linux${NC}"
fi
# Install required packages
echo -e "${GREEN}Installing dependencies...${NC}"
dnf install -y golang php-fpm || yum install -y golang php-fpm
# Check if Go is installed
if ! command -v go &> /dev/null; then
echo -e "${RED}Go installation failed. Please install Go manually.${NC}"
exit 1
fi
# Get Go version
GO_VERSION=$(go version)
echo -e "${GREEN}Found: $GO_VERSION${NC}"
# Build the application
echo -e "${GREEN}Building FastHTTP...${NC}"
go build -o fasthttp fasthttp.go
if [ ! -f "./fasthttp" ]; then
echo -e "${RED}Build failed!${NC}"
exit 1
fi
# Install binary
echo -e "${GREEN}Installing binary to /usr/local/bin/fasthttp...${NC}"
cp fasthttp /usr/local/bin/fasthttp
chmod +x /usr/local/bin/fasthttp
# Create directories
echo -e "${GREEN}Creating directories...${NC}"
mkdir -p /fast-http
mkdir -p /var/log/fasthttp
mkdir -p /var/run
# Install configuration file if it doesn't exist
if [ ! -f "/fast-http/fasthttp.json" ]; then
echo -e "${GREEN}Installing default configuration...${NC}"
cp fasthttp.json /fast-http/fasthttp.json
echo -e "${YELLOW}Configuration file installed to /fast-http/fasthttp.json${NC}"
echo -e "${YELLOW}Please edit this file to configure your virtual hosts${NC}"
else
echo -e "${YELLOW}Configuration file already exists at /fast-http/fasthttp.json${NC}"
fi
# Set permissions
chmod 644 /fast-http/fasthttp.json
echo -e "${GREEN}Installation complete!${NC}"
echo -e "${YELLOW}Usage:${NC}"
echo -e " Start server: ${GREEN}fasthttp start${NC}"
echo -e " Stop server: ${GREEN}fasthttp stop${NC}"
echo -e " Check status: ${GREEN}fasthttp status${NC}"
echo -e " Config file: ${GREEN}/fast-http/fasthttp.json${NC}"