Nginx一键安装脚本

!/bin/bash

yum -y install wget libtool expat-devel pcre-devel zlib-devel openssl openssl-devel pcre gcc gcc-c++ glibc automake autoconf libtool make libmcrypt-devel mhash-devel libxslt-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel
cd /usr/local/src
wget http://sourceforge.net/projects/pcre/files/pcre/8.39/pcre-8.39.tar.gz/download -O pcre-8.39.tar.gz
tar -zxvf pcre-8.39.tar.gz
cd pcre-8.39
./configure
make && make install

cd /usr/local/src
wget http://zlib.net/zlib-1.2.11.tar.gz
tar -zxvf zlib-1.2.11.tar.gz
cd zlib-1.2.11
./configure
make && make install

cd /usr/local/src
wget https://www.openssl.org/source/openssl-1.1.0b.tar.gz
tar -zxvf openssl-1.1.0b.tar.gz
cd openssl-1.1.0b
./config
make && make install

cd /usr/local/src
wget http://nginx.org/download/nginx-1.10.2.tar.gz
tar -zxvf nginx-1.10.2.tar.gz
cd nginx-1.10.2
groupadd -r nginx
useradd -r -g nginx nginx

./configure --prefix=/usr/local/nginx --sbin-path=/usr/local/nginx/sbin/nginx --conf-path=/usr/local/nginx/nginx.conf --pid-path=/usr/local/nginx/nginx.pid --user=nginx --group=nginx --with-http_ssl_module --with-http_flv_module --with-http_mp4_module --with-http_stub_status_module --with-http_gzip_static_module --http-client-body-temp-path=/var/tmp/nginx/client/ --http-proxy-temp-path=/var/tmp/nginx/proxy/ --http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi --http-scgi-temp-path=/var/tmp/nginx/scgi --with-pcre=/usr/local/src/pcre-8.39 --with-zlib=/usr/local/src/zlib-1.2.11 --with-openssl=/usr/local/src/openssl-1.1.0b
make && make install
mkdir -p /var/tmp/nginx/client
/usr/local/nginx/sbin/nginx

cat </usr/local/nginx/nginx.conf
user www www;

worker_processes 1;

error_log /usr/local/local/logs/nginx_error.log crit;

pid /usr/local/nginx/logs/nginx.pid;

Specifies the value for maximum file descriptors that can be opened by this process.

worker_rlimit_nofile 51200;

events

{

use epoll;

worker_connections 51200;

}

http

{

include mime.types;

default_type application/octet-stream;

server_names_hash_bucket_size 128;

client_header_buffer_size 32k;

large_client_header_buffers 4 32k;

client_max_body_size 50m;

          access_log off;

            ssi on;

            ssi_types text/shtml;

sendfile on;

tcp_nopush on;

add_header Hit slb-1.keyibao.com;

keepalive_timeout 180;

tcp_nodelay on;

fastcgi_intercept_errors on;

proxy_intercept_errors on;

fastcgi_connect_timeout 1200;

fastcgi_send_timeout 1200;

fastcgi_read_timeout 1200;

fastcgi_buffer_size 128k;

fastcgi_buffers 8 128k;

fastcgi_busy_buffers_size 256k;

fastcgi_temp_file_write_size 256k;

ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

    send_timeout 1200;

    proxy_connect_timeout 1200;

    proxy_read_timeout 1200;

    proxy_send_timeout 1200;

            set_real_ip_from 10.159.0.0/16;

            real_ip_header X-Forwarded-For;

gzip on;

gzip_proxied any;

gzip_http_version 1.0;

gzip_vary on;

gzip_comp_level 6;

gzip_min_length 2k;

gzip_buffers 4 16k;

gzip_types text/plain text/css application/json application/x-javascript application/xml text/javascript image/jpeg image/gif image/png application/x-shockwave-flash;

gzip_disable “MSIE [1-6].(?!.*SV1)”;

limit_req_zone $limit zone=ConnLimitZone:20m rate=30r/s;

limit_conn_zone $limit zone=limit:10m;

limit_req zone=ConnLimitZone;

}
EOF

firewall-cmd --add-port=80/tcp --permanent
firewall-cmd --reload

你可能感兴趣的:(Nginx一键安装脚本)