commit db11f83914445206687c7644bd0759fce6b5f598 Author: yanglc Date: Tue Dec 31 01:14:57 2024 +0800 添加 install.sh diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..9a5e6f0 --- /dev/null +++ b/install.sh @@ -0,0 +1,64 @@ +#!/bin/bash +PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin +export PATH + +RED_COLOR="\033[0;31m" +NO_COLOR="\033[0m" +GREEN="\033[32m\033[01m" +BLUE="\033[0;36m" +FUCHSIA="\033[0;35m" + +apt update -y && apt install vim curl lsof wget -y +apt install build-essential libpcre3 libpcre3-dev zlib1g-dev openssl libssl-dev host net-tools dnsutils whois -y +wget -N --no-check-certificate openresty-1.27.1.1.tar.gz && tar -xvzf openresty-1.27.1.1.tar.gz +cd openresty-1.27.1.1 +./configure \ +--prefix=/etc/nginx \ +--sbin-path=/usr/sbin/nginx \ +--conf-path=/etc/nginx/nginx.conf \ +--error-log-path=/var/log/nginx/error.log \ +--http-log-path=/var/log/nginx/access.log \ +--pid-path=/var/run/nginx.pid \ +--lock-path=/var/run/nginx.lock \ +--with-file-aio \ +--with-threads \ +--with-stream \ +--with-stream_realip_module \ +--with-stream_ssl_module \ +--with-stream_ssl_preread_module +make && make install +rm /etc/nginx/nginx.conf +cat << 'EOF' | tee /etc/nginx/nginx.conf > /dev/null +worker_priority -20; +worker_processes auto; +worker_cpu_affinity auto; +worker_rlimit_nofile 204800; +worker_shutdown_timeout 120s; +error_log /dev/null; + +events { + worker_connections 204800; + multi_accept on; + accept_mutex off; + use epoll; +} + +stream { +include /etc/nginx/tunnelconf/*.conf; +} +EOF +cat << 'EOF' | tee /usr/lib/systemd/system/nginx.service > /dev/null +[Unit] +Description=nginx - high performance web server +Documentation=https://nginx.org/en/docs/ +Wants=network-online.target +[Service] +Type=forking +PIDFile=/var/run/nginx.pid +ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf +ExecReload=/bin/sh -c "/bin/kill -s HUP $(/bin/cat /var/run/nginx.pid)" +ExecStop=/bin/sh -c "/bin/kill -s TERM $(/bin/cat /var/run/nginx.pid)" +[Install] +WantedBy=multi-user.target +EOF +systemctl enable nginx --now \ No newline at end of file