查看nginx相关的进程
ps -ef | grep nginx
启动nginx:
sudo nginx
重启nginx:
sudo nginx -s reload
停止nginx:
sudo nginx -s stop
查看nginx路径:
nginx -t
nginx启动或重启时报错(nginx启动时报[error] invalid PID number "" in "/usr/local/var/run/nginx/nginx.pid错误):
sudo nginx -c /usr/local/etc/nginx/nginx.conf
查看端口被哪个程序占用
sudo lsof -i tcp:port
如: sudo lsof -i tcp:8080
权限开放
chmod 777 patent -R
#-R 循环赋值子目录权限
看到进程的PID,可以将进程杀死。
sudo kill -9 PID
如:sudo kill -9 23453
nginx多个conf文件配置方法:
默认的nginx.conf中http最后有一个include servers/*;
可以在当前目录下新建servers文件夹,在该文件夹下随意新建*.conf. 可以在其中书写监听方式,如:# For more information on configuration, see: # * Official English Documentation: http://nginx.org/en/docs/ # * Official Russian Documentation: http://nginx.org/ru/docs/ user nginx; worker_processes auto; error_log /var/log/nginx/error.log; pid /run/nginx.pid; # Load dynamic modules. See /usr/share/doc/nginx/README.dynamic. include /usr/share/nginx/modules/*.conf; events { worker_connections 1024; } 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 4096; include /etc/nginx/mime.types; default_type application/octet-stream; # Load modular configuration files from the /etc/nginx/conf.d directory. # See http://nginx.org/en/docs/ngx_core_module.html#include # for more information. include /etc/nginx/conf.d/*.conf; server { listen 80; listen 443 ssl; ssl_certificate /www/server/nginx/conf/cert/10161314_xdvideomall.hzxiadou.com.pem; # 更换证书文件 ssl_certificate_key /www/server/nginx/conf/cert/10161314_xdvideomall.hzxiadou.com.key; # 更换证书文件 ssl_session_timeout 5m; ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on; server_name xdvideomall.hzxiadou.com; index index.php index.html index.htm default.php default.htm default.html; root /usr/share/nginx/html; # Load configuration files for the default server block. include /etc/nginx/default.d/*.conf; error_page 404 /404.html; location = /404.html { } error_page 500 502 503 504 /50x.html; location = /50x.html { } location /ehrPc { # 指定首页指向地址 alias /opt/web/ehrPc; try_files $uri $uri/ /index.html last; index index.html index.htm; } location /ehrMobile { # 指定首页指向地址 alias /opt/web/ehrMobile; try_files $uri $uri/ /index.html last; index index.html index.htm; } location /okr { # 指定首页指向地址 alias /opt/web/okr; try_files $uri $uri/ /index.html last; index index.html index.htm; } location /f/ { proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header REMOTE-HOST $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass http://117.88.45.241:3080/f/; } location /api/ { proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header REMOTE-HOST $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass http://117.88.45.241:7060/; } } # Settings for a TLS enabled server. # # server { # listen 443 ssl http2; # listen [::]:443 ssl http2; # server_name _; # root /usr/share/nginx/html; # # ssl_certificate "/etc/pki/nginx/server.crt"; # ssl_certificate_key "/etc/pki/nginx/private/server.key"; # ssl_session_cache shared:SSL:1m; # ssl_session_timeout 10m; # ssl_ciphers HIGH:!aNULL:!MD5; # ssl_prefer_server_ciphers on; # # # Load configuration files for the default server block. # include /etc/nginx/default.d/*.conf; # # error_page 404 /404.html; # location = /40x.html { # } # # error_page 500 502 503 504 /50x.html; # location = /50x.html { # } # } }