#!/bin/bash
sudo wget -O ~/nginx.tar.gz https://nginx.org/download/nginx-1.24.0.tar.gz
sudo tar xfz ~/nginx.tar.gz -C /usr/local/
sudo mv /usr/local/nginx-1.24.0/ /usr/local/nginx
sudo yum -y install gcc gcc-c++
cd /usr/local/nginx
./configure --prefix=/usr/local/nginx --group=nginx --user=nginx --sbin-path=/usr/local/nginx/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/tmp/nginx/client_body --http-proxy-temp-path=/tmp/nginx/proxy --http-fastcgi-temp-path=/tmp/nginx/fastcgi --pid-path=/var/run/nginx.pid --lock-path=/var/lock/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-pcre --with-http_realip_module --with-stream
make && make install
sudo mkdir -p /tmp/nginx &> /dev/null
sudo mkdir /usr/local/nginx/logs &> /dev/null
sudo mkdir /etc/nginx/conf.d &> /dev/null
sudo echo 'user nginx;
worker_processes auto;
error_log logs/error.log;
error_log logs/error.log notice;
error_log logs/error.log info;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
include /etc/nginx/conf.d/*.conf;
charset utf-8;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
}' > /etc/nginx/nginx.conf
sudo echo 'server {
listen 80;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}' > /etc/nginx/conf.d/page.conf
sudo echo 'NGINX_HOME=/usr/local/nginx' >> /etc/profile
sudo echo 'PATH=$NGINX_HOME/sbin:$PATH' >> /etc/profile
source /etc/profile
clear
sudo echo "安装完成,可以输入nginx -V查看详情,安装目录在/usr/local/nginx"
评论
隐私政策
你无需删除空行,直接评论以获取最佳展示效果