nginx常用的命令
时间:2019-04-29 03:17:22 来源:igfitidea点击:
如何安装nginx
$ sudo yum install epel-release && yum install nginx ### CentOS/RHEL $ sudo dnf install nginx ### Debian/Ubuntu $ sudo apt install nginx ### Fedora
如何查看nginx的版本
$ nginx -v nginx version: nginx/1.12.2
查看nginx版本和配置选项
$ nginx -V nginx version: nginx/1.12.2 built by gcc 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC) built with OpenSSL 1.0.2k-fips 26 Jan 2017 TLS SNI supp或者t enabled configure arguments: --prefix=/usr/share/nginx --sbin-path=/usr/sbin/nginx
如何检查Nginx配置文件语法是否正确
$ sudo nginx -t nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful
如何启动nginx服务
$ sudo systemctl start nginx ###systemd 或者 $ sudo service nginx start ###sysvinit
如何设置nginx开机自启动
$ sudo systemctl enable nginx #systemd 或者 $ sudo service nginx enable #sysv init
如何重启nginx服务
$ sudo systemctl restart nginx #systemd 或者 $ sudo service nginx restart #sysv init
如何检查nginx状态
$ sudo systemctl status nginx #systemd 或者 $ sudo service nginx status #sysvinit
如何重新加载nginx配置而不影响当前服务
$ sudo systemctl reload nginx #systemd 或者 $ sudo service nginx reload #sysvinit
如何停止nginx服务
$ sudo systemctl stop nginx #systemd 或者 $ sudo service nginx stop #sysvinit