- # 用了 nginx for win 很久, 安装也是超级简单.
- # 还是用一下 linux 版的吧. 我的是 centos 6.5 x64
- # 安装开始:
- # 先安装依赖
- yum install gcc-c++
- yum -y install pcre*
- yum -y install openssl*
- # 下载, 可以 wget 目前最新 1.15.3
- cd /opt
- wget http://nginx.org/download/nginx-1.12.2.tar.gz
- tar zxf nginx-1.12.2.tar.gz
- cd nginx-1.12.2
- # 指定安装目录 , 编译安装
- ./configure --prefix=/opt/nginx
- make && make install
- # 检查测试
- /opt/nginx/sbin/nginx -t
- # 启动 停止 退出
- /opt/nginx/sbin/nginx
- /opt/nginx/sbin/nginx -s stop
- /opt/nginx/sbin/nginx -s quit
- #---------------- 官方文档: -s 参数 ------------
- # stop - fast shutdown
- # quit - graceful shutdown
- # reload - reloading the configuration file
- # reopen - reopening the log files
- #----------------------------------------------
- # 查看进程, 端口 检查运行情况
- ps aux |grep nginx # master worker 至少各一个
- netstat -tulnp | grep :80
- # 如果想要命令方便执行, 可将路径加入 PATH 变量中
- vim /etc/profile # 加入 2 行
- export NGINX_HOME=/opt/nginx
- export PATH=$NGINX_HOME/sbin:$PATH
- source /etc/profile # 生效
- #-------------------- 配置文件 nginx.conf ---------------------------
- user nginx;
- worker_processes auto; # 进程数, 一般设置为 CPU 核数, 或者 auto
- pid /var/run/nginx.pid; # 记录进程 PID 文件, 可以不启用
- # Load dynamic modules. See /usr/share/nginx/README.dynamic.
- include /usr/share/nginx/modules/*.conf;
- events {
- use epoll; # 使用高效的 epoll 方式
- worker_connections 65535; # 单个 worker 进程同时打开的最大连接数 跟系统的 ulimit -n 有关
- }
- http {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 /var/log/nginx/access.log main;
- sendfile on;
- tcp_nopush on;
- tcp_nodelay on;
- keepalive_timeout 65;
- types_hash_max_size 2048;
- include /etc/nginx/mime.types;
- default_type application/octet-stream;
- server_tokens off; # 隐藏 web 出错时的版本号
后续再更新更多相关应用
来源: http://www.bubuko.com/infodetail-2759070.html