一.配置systemctl之前的启动方式

进入sbin目录下执行以下命令:

 启动nginx的命令为     /usr/local/nginx/sbin/nginx 

3 停止nginx的命令为    /usr/local/nginx/sbin/nginx -s stop
4 重启nginx的命令为 /usr/local/nginx/sbin/nginx -s reload

二.配置systemctl之后的启动方式

systemctl status nginx

systemctl start nginx

systemctl stop nginx

systemctl restart nginx

三.配置方法

1.创建一个nginx.service

 在 /usr/lib/systemd/system/目录下面新建一个nginx.service文件。并赋予可执行的权限
 vim /usr/lib/systemd/system/nginx.service
 chmod +x /usr/lib/systemd/system/nginx.service

2.编辑service内容

[Unit]                                                                                      //对服务的说明
Description=nginx - high performance web server //描述服务
After=network.target remote-fs.target nss-lookup.target //描述服务类别 [Service] //服务的一些具体运行参数的设置
Type=forking //后台运行的形式
PIDFile=/usr/local/nginx/logs/nginx.pid //PID文件的路径
ExecStartPre=/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf //启动准备
ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf //启动命令
ExecReload=/usr/local/nginx/sbin/nginx -s reload //重启命令
ExecStop=/usr/local/nginx/sbin/nginx -s stop //停止命令
ExecQuit=/usr/local/nginx/sbin/nginx -s quit //快速停止
PrivateTmp=true //给服务分配临时空间 [Install]
WantedBy=multi-user.target //服务用户的模式

3.启动服务

在启动服务之前,需要先重载systemctl命令
systemctl daemon-reload
systemctl start nginx.service

4.如果出现端口被占用情况

在nginx配置文件中   /usr/local/nginx/conf/nginx.conf

把listen 后面的数字修改成8080或者81。再重新启动服务。

nginx启动命令以及与配置systemctl的更多相关文章

  1. nginx常用命令及简单配置

    nginx常用命令 nginx -c /usr/local/nginx/conf/nginx.conf 启动nginx(windows下start nginx); nginx -s quit 停止ng ...

  2. win7 php nginx 启动命令

    1 php 启动命令 @echo off e: cd E:/php-/ echo "php is starting on port 9007, php_version is 7.0.6&qu ...

  3. nginx配置, 启动命令, 反向代理配置

    2014年1月3日 13:52:07 喜欢这样的风格,干货 http://huoding.com/2013/10/23/290 -----------------下边是我自己的经验(windows)- ...

  4. Nginx启动停止命令

    操作环境是Windows 一.nginx命令:启动nginx 在Windows上安装好nginx后,我们需要启动nginx服务,启动nginx服务的命令行操作主要有两种方式,即 cd D:\opens ...

  5. Nginx隐藏index.php和配置vhost

    nginx启动命令 启动:nginx停止:nginx -s stop退出:nginx -s quit重启:nginx -s reopen重新加载:nginx -s reload平滑启动:kill -H ...

  6. Windows7安装nginx后,'nginx -t -c nginx.conf' 命令出现 “could not open error log file: CreateFile() "logs/error.log" failed” 错误的原因

    网上搜索安装nginx的方法,按照步骤在 http://nginx.org/en/download.html 下载了安装包,并配置了conf/nginx.conf,将nginx的根目录添加进了环境变量 ...

  7. ubuntu apache nginx 启动 关闭

    转载自:http://www.comflag.com/2011/05/01/apache-web.htm 电影<社交网络>中,facebook创始人马克.扎克失恋后入侵哈佛大学宿舍楼服务器 ...

  8. CentOS7.5下开发systemctl管理的自定义Nginx启动服务程序

    一.systemctl知识简介 从CentOS7 Linux开始,系统里的网络服务启动已经从传统的service改成了systemctl(一个systemd工具,主要负责控制systemd系统和服务管 ...

  9. nginx启动,重启,关闭命令

    nginx启动,重启,关闭命令 停止操作停止操作是通过向nginx进程发送信号(什么是信号请参阅linux文 章)来进行的步骤1:查询nginx主进程号ps -ef | grep nginx在进程列表 ...

随机推荐

  1. python dijkstra 最短路算法示意代码

    def dijkstra(graph, from_node, to_node): q, seen = [(0, from_node, [])], set() while q: cost, node, ...

  2. sql分割函数

    drop function [dbo].[f_split] create function [dbo].[f_split] ( ),--需要分割的字符串(例如:1,2,3,4,5 我|和|你) )-- ...

  3. Mybatis框架-@Param注解

    回顾一下上一个小demo中存在的问题,是是根据用户的id修改用户的密码,我们只是修改了用户的密码,结果我们的在写接口方法的时候掺入的参数确实一个User对象,这样让别人看到我们的代码真的是很难读懂啊! ...

  4. go正则表达式

    单行模式(?s:(.?))万能用法尽量匹配少的文本,最关键的是可以匹配换行的文本,直接写.?不能匹配\n package main import ( "fmt" "reg ...

  5. 事件类型(onfocus和onblur)

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  6. elasticsearch安装和部署

    1.可以在官网上下载不同版本的es,官网地址为:https://www.elastic.co/cn/downloads/past-releases#elasticsearch 2.解压elastics ...

  7. rbenv mac&&linux 安装简单说明

    mac 可以通过brew linux 官方提供了运行脚本 # with curl curl -fsSL https://github.com/rbenv/rbenv-installer/raw/mas ...

  8. circus && web comsole docker-compose 独立部署web console 的一个bug

    如果直接使用以下的docker-compose 文件部署会有通过多播通信获取endpoint 异常的问题(circus 在stats endpoint 获取少了一个c) 这个问题是部分网络情况下会出现 ...

  9. 在触发器中使用{ITEM.LASTVALUE}时在首页问题栏信息显示不全

    在触发器中使用了系统宏变量,当条件满足时,如果这个宏代表的内容超过了20个字符,那么在首页信息就显示不全,会有一堆省略号 感谢https://blog.csdn.net/yu415907917/art ...

  10. Flume 测试 Kafka 案例

    Flume Kafka 测试案例,Flume 的配置. a1.sources = s1 a1.channels = c1 a1.sinks = k1 a1.sources.s1.type = netc ...