# 用了nginx for win很久,安裝也是超級簡單。# 還是用一下linux版的吧。我的是centos 6.5 x64 # 啟動 停止 退出 # 查看進程,埠 檢查運行情況 # 配置文件 nginx.conf 後續再更新更多相關應用 ...
# 用了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出錯時的版本號
後續再更新更多相關應用