centos7.9下操作nginx
通过systemctl
启动nginx
shell
systemctl start nginx停止nginx
shell
systemctl stop nginx重启nginx
shell
systemctl restart nginx查看nginx状态
shell
systemctl status nginx直接执行nginx binary file(nginx二进制文件)
启动nginx
shell
nginx停止nginx
shell
nginx -s stop重启nginx
shell
nginx -s reload查看nginx配置文件语法
shell
nginx -t注意事项
systemctl status nginx命令用于查看Nginx服务的状态。它读取Nginx服务的状态信息,并将其显示在终端或命令提示符中。
在CentOS 7.9操作系统中,systemctl是一个系统管理工具,用于管理系统的服务。它通过读取Systemd的配置文件来获取服务的状态信息。对于Nginx服务,systemctl会读取nginx.service配置文件中的信息。(这个和安装nginx时通过./configure命令有关)
nginx.service配置文件通常位于/usr/lib/systemd/system/nginx.service或/etc/systemd/system/nginx.service路径中,具体位置可能因操作系统和Nginx安装方式而有所不同。该配置文件定义了Nginx服务的启动脚本、工作目录、配置文件路径等相关信息。
当您运行systemctl status nginx命令时,systemctl会读取nginx.service配置文件中的相关配置信息,并使用这些信息来确定Nginx服务的状态。然后,它会将状态信息显示给您。
直接执行
nginx binary file,如果没有设置软连接的话,需要进入在你进行nginx编译配置(./configure)时的nginx binary file的路径,比如:/usr/local/nginx/sbin/nginxcd /usr/local/nginx/sbin/然后通过./nginx来启动nginx,及相关命令