Centos 7 配置Nginx,常用的nginx操作,启动/停止,代理,反向代理设置以及https ssl 443配置Linux查询nginx主进程号ps -ef | grep nginx启动/重启## 在nginx/sbin下执行命令 . (查看是否在 /usr/local/nginx/sbin)## 启动./nginx -c /usr/local/nginx/conf/nginx.conf## 重启./nginx -s reload停止## 从容停止Nginx:kill -QUIT 主进程号 ## 例如:kill -QUIT 16391## 快速停止Nginx:kill -TERM 主进程号 ## 强制停止Nginx:kill -9 主进程号 ## 停止nginxnginx -s stop代理/请求转发http { server { ### … listen 4000; server_name localhost; location / { root /Users/zhangguoye/Documents/Porject/Gitee/searchWX/src/main/internetapp; index index.html index.htm; } location /oauth/ { proxy_pass http://localhost:8080/oauth/; } location /api/ { proxy_pass http://localhost:8080/api/; } ### … }}443/SSL/未开启SSL模块安装模块切换到源码包:cd /usr/local/src/nginx-1.11.3查看nginx原有的模块/usr/local/nginx/sbin/nginx -V在configure arguments:后面显示的原有的configure参数如下:–prefix=/usr/local/nginx –with-http_stub_status_module那么我们的新配置信息就应该这样写:./configure –prefix=/usr/local/nginx –with-http_stub_status_module –with-http_ssl_module运行上面的命令即可,等配置完配置完成后,运行命令makes然后备份原有已安装好的nginxcp /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.bak然后将刚刚编译好的nginx覆盖掉原有的nginx(这个时候nginx要停止状态)cp ./objs/nginx /usr/local/nginx/sbin/然后启动nginx,仍可以通过命令查看是否已经加入成功/usr/local/nginx/sbin/nginx -V配置Http和Https共存把ssl on;这行去掉,ssl写在443端口后面。这样http和https的链接都可以用server { listen 80 default backlog=2048; listen 443 ssl; server_name wosign.com; root /var/www/html; ssl_certificate /usr/local/Tengine/sslcrt/ wosign.com.crt; ssl_certificate_key /usr/local/Tengine/sslcrt/ wosign.com .Key; }配置SSL安全证书重启避免输入密码可以用私钥来做这件事。生成一个解密的key文件,替代原来key文件。openssl rsa -in server.key -out server.key.unsecureSSL性能调优ssl_protocols TLSv1 TLSv1.1 TLSv1.2;ssl_ciphers ECDHE-RSA-AES256-SHA384:AES256-SHA256:RC4:HIGH:!MD5:!aNULL:!eNULL:!NULL:!DH:!EDH:!AESGCM;ssl_prefer_server_ciphers on;ssl_session_cache shared:SSL:10m;ssl_session_timeout 10m;MAC (Brew Nginx)mac 使用homebrew安装Nginx,Nginx的位置与启动## 在mac上安装完nginx后的提示信息==> nginxDocroot is: /usr/local/var/wwwThe default port has been set in /usr/local/etc/nginx/nginx.conf to 8080 so thatnginx can run without sudo.nginx will load all files in /usr/local/etc/nginx/servers/.To have launchd start nginx now and restart at login: brew services start nginxOr, if you don’t want/need a background service you can just run: nginx## 查看nginx版本nginx -v## 启动nginx服务brew services start nginx## 关闭nginx服务brew services stop nginx## 重新加载nginxnginx -s reload## 停止nginxnginx -s stop