服务 Nginx 不起作用

xpe*_*tor 8 nginx

我已经在 debian(jessie v8.2) 系统上从源代码编译了 nginx v1.9.6。但它没有按预期工作。1.9.3 版本没有任何问题。

当我尝试运行时,service nginx start我收到此消息:

无法启动 nginx.service:单元 nginx.service 加载失败:没有这样的文件或目录。

我使用这些参数进行配置:

配置参数:--prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/ nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx。 lock --user=myuser --group=myuser --without-mail_pop3_module --without-mail_imap_module --without-mail_smtp_module --with-http_ssl_module --with-http_v2_module --with-file-aio --with-ipv6 --没有-http_memcached_module

Hen*_*gel 17

如果您收到错误消息Failed to start nginx.service: Unit nginx.service failed to load: No such file or directory. systemd尚未找到unit file.

从源安装没有提供单元文件。您需要像这样为 nginx 创建一个单元文件。

[Unit]
Description=The NGINX HTTP and reverse proxy server
After=syslog.target network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
PIDFile=/run/nginx.pid
ExecStartPre=/usr/sbin/nginx -t
ExecStart=/usr/sbin/nginx
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target
Run Code Online (Sandbox Code Playgroud)

调整安装路径并将文件存储在/lib/systemd/system/nginx.service. 您需要运行systemctl daemon-reload以重新加载 systemd。

查看官方文档以获取更多信息。