https://github.com/DocsHome/nginx-docs
部署
yum -y install nginx
启动相关
虚拟主机
vim /etc/nginx/nginx.conf
user nginx;
worker_processes auto;
worker_rlimit_nofile 65535;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
include /usr/share/nginx/modules/*.conf;
events {
use epoll; #使用epoll事件驱动
worker_connections 51200;
accept_mutex on;
multi_accept on;
}
http {
server_tokens off;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
client_max_body_size 10m;
#开启gzip
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;
gzip_vary on;
gzip_proxied expired no-cache no-store private auth;
gzip_disable "MSIE [1-6]\.";
include /etc/nginx/mime.types;
default_type application/octet-stream;
#设置日志的记录格式
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
log_format log404 '$status [$time_local] $remote_addr $host$request_uri $sent_http_location';
access_log /var/log/nginx/access.log main;
access_log /var/log/nginx/access_404.log log404;
include /etc/nginx/vhost/*.conf;
}
mkdir /etc/nginx/vhost #创建虚拟主机目录
mkdir /opt/www #网站存放目录
chown www:www /opt/www
chmod 755 /opt/www
进阶配置见
Nginx 进阶