nginx設定スクリプトのインストール
5334 ワード
#!/bin/bash
path=/opt/nginx
conf=/$path/conf
ver=http://nginx.org/download/nginx-1.10.2.tar.gz
wgetd=/usr/local/src
########### #############################
yum -y group install "Development Tools"
useradd -M -s /sbin/nologin nginx
yum -y install lsof wget zlib zlib-devel openssl openssl-devel pcre pcre-devel
if [[ -d $path ]]; then
echo "nginx is installed pls rm"
else
cd $wgetd
wget $ver
tar zxvf nginx-1.10.2.tar.gz
cd nginx-1.10.2
fi
if [[ $? == 0 ]]; then
echo "start configure"
fi
./configure \
--prefix=/opt/nginx \
--user=nginx --group=nginx \
--with-http_ssl_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_sub_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_random_index_module \
--with-http_secure_link_module \
--with-http_stub_status_module \
--with-http_auth_request_module \
--with-mail_ssl_module \
--with-file-aio \
--with-ipv6
if [[ $? == 0 ]]; then
echo " "
make && make install
fi
cd $conf
mkdir -p conf.d
cp nginx.conf nginx.conf_$(date +%F)
cat << EOF >nginx.conf
user nginx nginx; ##
worker_processes auto; ## web ( )
worker_rlimit_nofile 51200; ##worker “too many open files”
error_log /opt/nginx/logs/nginx_error.log error; ## debug, info, notice, warn, error, crit
pid /opt/nginx/logs/nginx.pid;
############events
events ##events nginx
{
use epoll; ## epoll or kqueue
worker_connections 2048; ##
multi_accept on; ##
}
#############http ( )#####################
http
{
include mime.types; ##
default_type application/octet-stream; ##
server_names_hash_bucket_size 128; ## hash
client_header_buffer_size 1024k; ##
large_client_header_buffers 4 32k; ## header
client_max_body_size 50m; ## ("Request Entity Too Large" (413) )
sendfile on; ##
tcp_nopush on; ## ( , )
keepalive_timeout 60; ##
tcp_nodelay on; ## Nagle
###############nginx php.java
fastcgi_connect_timeout 300; ##fastcgi
fastcgi_send_timeout 300; ##fastcgi
fastcgi_read_timeout 300; ##fastcgi
fastcgi_buffer_size 64k; ##
fastcgi_buffers 4 64k; ## (4*64)
fastcgi_busy_buffers_size 128k; ##fastcgi_buffer_sized 2
fastcgi_temp_file_write_size 256k; ##
gzip on;
gzip_min_length 1k; ##
gzip_buffers 4 16k; ##
gzip_http_version 1.1; ##
gzip_comp_level 2; ##
gzip_types text/plain application/javascript application/x-javascript text/javascript text/css application/xml application/xml+rss;
gzip_vary on; ##http hader vary
gzip_proxied expired no-cache no-store private auth;
gzip_disable "MSIE [1-6]\.";
#limit_conn_zone $binary_remote_addr zone=perip:10m;
##If enable limit_conn_zone,add "limit_conn perip 10;" to server section.
server_tokens off; ## nginx
log_format main ##
'$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
include conf.d/*.conf; ## conf.d/ (server ,upstream, )
}
EOF
############################################web.conf
cat << EOF >conf.d/web.conf
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
EOF
ln -s $path/sbin/nginx /usr/local/sbin/nginx
nginx
lsof -i:80