Service Nginx doesn't work
I've compiled nginx v1.9.6 from source on a debian(jessie v8.2) system. But it's not working as expected. Didn't have any problem with the 1.9.3 version.
when I try to run service nginx start
i get this message:
Failed to start nginx.service: Unit nginx.service failed to load: No such file or directory.
I used these arguments for configuration:
configure arguments: --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 --without-http_memcached_module
Solution 1:
If you get the error message Failed to start nginx.service: Unit nginx.service failed to load: No such file or directory.
systemd
has not found a unit file
.
The installation from source did not provide a unit file. You need to create a unit file for nginx like this.
[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
Adjust the paths to your installation and store the file under /lib/systemd/system/nginx.service
. You need to run systemctl daemon-reload
to reload systemd.
Take a look at the official documentation for more information.