Nginx 컴 파일 설치 및 설정 최적화
# centos
yum install -y gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel
groupadd www
useradd www -g www
wget https://nginx.org/download/nginx-1.13.9.tar.gz
tar zxvf nginx-1.13.9.tar.gz
cd nginx-1.13.9
./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_stub_status_module --with-pcre --user=www --group=www
make && make install
#service
#centos6
#! /bin/sh
# chkconfig: 2345 55 25
# Description: Startup script for nginx webserver on Debian. Place in /etc/init.d and
# run 'update-rc.d -f nginx defaults', or use the appropriate command on your
# distro. For CentOS/Redhat run: 'chkconfig --add nginx'
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the nginx web server
# Description: starts nginx using start-stop-daemon
### END INIT INFO
# Author: licess
# website: http://lnmp.org
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="nginx daemon"
NAME=nginx
DAEMON=/usr/local/nginx/sbin/$NAME
CONFIGFILE=/usr/local/nginx/conf/$NAME.conf
PIDFILE=/usr/local/nginx/logs/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
set -e
[ -x "$DAEMON" ] || exit 0
do_start() {
$DAEMON -c $CONFIGFILE || echo -n "nginx already running"
}
do_stop() {
kill -INT `cat $PIDFILE` || echo -n "nginx not running"
}
do_reload() {
kill -HUP `cat $PIDFILE` || echo -n "nginx can't reload"
}
case "$1" in
start)
echo -n "Starting $DESC: $NAME"
do_start
echo "."
;;
stop)
echo -n "Stopping $DESC: $NAME"
do_stop
echo "."
;;
reload|graceful)
echo -n "Reloading $DESC configuration..."
do_reload
echo "."
;;
restart)
echo -n "Restarting $DESC: $NAME"
do_stop
do_start
echo "."
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|reload|restart}" >&2
exit 3
;;
esac
exit 0
#centos7+
#! /bin/sh
# chkconfig: 2345 55 25
# Description: Startup script for nginx webserver on Debian. Place in /etc/init.d and
# run 'update-rc.d -f nginx defaults', or use the appropriate command on your
# distro. For CentOS/Redhat run: 'chkconfig --add nginx'
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the nginx web server
# Description: starts nginx using start-stop-daemon
### END INIT INFO
# Author: licess
# website: http://lnmp.org
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="nginx daemon"
NAME=nginx
DAEMON=/usr/local/nginx/sbin/$NAME
CONFIGFILE=/usr/local/nginx/conf/$NAME.conf
PIDFILE=/usr/local/nginx/logs/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
set -e
[ -x "$DAEMON" ] || exit 0
do_start() {
$DAEMON -c $CONFIGFILE || echo -n "nginx already running"
}
do_stop() {
kill -INT `cat $PIDFILE` || echo -n "nginx not running"
}
do_reload() {
kill -HUP `cat $PIDFILE` || echo -n "nginx can't reload"
}
case "$1" in
start)
echo -n "Starting $DESC: $NAME"
do_start
echo "."
;;
stop)
echo -n "Stopping $DESC: $NAME"
do_stop
echo "."
;;
reload|graceful)
echo -n "Reloading $DESC configuration..."
do_reload
echo "."
;;
restart)
echo -n "Restarting $DESC: $NAME"
do_stop
do_start
echo "."
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|reload|restart}" >&2
exit 3
;;
esac
exit 0
# nginx.conf
user www www;
worker_processes auto;
#error_log logs/error.log;
error_log /dev/null ;
#error_log logs/error.log notice;
#error_log logs/error.log error;
pid /usr/local/nginx/logs/nginx.pid;
#pid logs/nginx.pid;
worker_rlimit_nofile 65535;#
events {
use epoll;
worker_connections 65535;# ,
}
http {
#limit_conn
#limit_conn_log_level error;
#limit_conn_status 503;
#limit_conn_zone $binary_remote_addr zone=one:50m; # one ip
#limit_conn_zone $server_name zone=two:50m; # two ,
#limit_req_zone '$binary_remote_addr - $uri' zone=three:50m rate=2r/s; # three zone ip uri
include mime.types;
default_type application/octet-stream;
# charset gb2312;
server_names_hash_bucket_size 128;
log_format main '$host - $remote_addr - $remote_user [$time_local] $request '
'"$status" $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /dev/null;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
#keepalive_timeout 0;
keepalive_timeout 15;
client_header_timeout 3m;
client_body_timeout 3m;
#send_timeout 3m;
send_timeout 15m;
connection_pool_size 256;
client_header_buffer_size 32k;
large_client_header_buffers 1 128k;
ignore_invalid_headers on;
recursive_error_pages on;
server_name_in_redirect off;
request_pool_size 10m;
output_buffers 4 32k;
postpone_output 1460;
client_max_body_size 8m;
client_body_buffer_size 256k;
client_body_temp_path /dev/shm/client_body_temp;
proxy_temp_path /usr/local/nginx/proxy_temp;
fastcgi_temp_path /usr/local/nginx/fastcgi_temp;
open_file_cache max=204800 inactive=20s;
open_file_cache_min_uses 1;
open_file_cache_valid 30s;
gzip on;
gzip_http_version 1.0;
gzip_comp_level 8;
gzip_proxied any;
gzip_types text/plain text/css image/jpeg image/gif image/png application/javascript text/xml application/xml application/sml+rss text/javascript application/x-httpd-php;
gzip_min_length 1k;
gzip_buffers 1 64k;
gzip_vary on;
gzip_disable "MSIE [1-6]\.";
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_intercept_errors on;
fastcgi_buffers 8 256k;
#fastcgi_buffer_size 128k;
fastcgi_buffer_size 256k;
fastcgi_busy_buffers_size 512k;
#fastcgi_busy_buffers_size 256k;
#fastcgi_temp_file_write_size 256k;
fastcgi_temp_file_write_size 512k;
include /usr/local/nginx/conf/vhosts/*.conf;
}
#limit_conn
#server
# {
# limit_conn one 10; # one ip 10
# limit_conn two 10000;# two server_name 10000
# limit_req zone=three burst=5; # three ip 1
#}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
nginx 의 if 내장nginx 설정 에 서 는 if 조건 의 논리 와 & 논리 또는 | 연산 을 지원 하지 않 으 며, if 의 내장 문법 을 지원 하지 않 습 니 다. 그렇지 않 으 면 다음 과 같은 오 류 를 보고 합 니 다: ng...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.