E
E
Eugene Wolf2017-01-21 18:36:42
linux
Eugene Wolf, 2017-01-21 18:36:42

CentOS + Nginx from sources. Why is the service not starting?

Good day dear!
Due to subjective reasons, I decided to tinker with CentOS (before that, I tinkered with Debian for 10+ years). I downloaded CentOS-7, installed it on a virtual machine, updated it, everything is fine. I decided to build Nginx from source, because. this is one of the most frequent procedures in my practice (building software from source) when working with Linux, and Nginx is a program that is quite familiar to me. Well, for a change, I decided to screw ngx_pagespeed into it.
I read the instructions, for example here (there are a lot of very similar ones, I won’t give all the links, they are essentially the same).
I did everything as it should be, downloaded src.rpm, unpacked it, added the module, built Nginx, delivered the dependencies, built the package, installed the package via: yum install local nginx...rpm
I'm writing: service nginx start- error. I look at the error:

янв 21 18:19:27 localhost.localdomain systemd[1]: Starting nginx - high performance web server...
янв 21 18:19:27 localhost.localdomain nginx[2241]: /usr/sbin/nginx: error while loading shared libraries: cannot create cache for search path: Cannot allocate memory
янв 21 18:19:27 localhost.localdomain systemd[1]: nginx.service: control process exited, code=exited status=127
янв 21 18:19:27 localhost.localdomain systemd[1]: Failed to start nginx - high performance web server.

Ok, I try to start nginx with my hands, I write the path as in an error: /usr/sbin/nginx- lo and behold, Nginx has started!
I try again - service start nginx- the error is the same. From the error, I realized that nginx cannot load the "space" libraries, cannot create a folder for the cache at the address "space" and cannot allocate memory ...
Ok, I'm going to look at the "magic" service startup parameters: /usr/lib/systemd/system/nginx.service
I see:
[Service]
Type=forking
PIDFile=/run/nginx.pid
ExecStartPre=/usr/sbin/nginx -t -c /etc/nginx/nginx.conf
ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true

I start in order, "hands":
/usr/sbin/nginx -t -c /etc/nginx/nginx.conf
Conclusion:
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

I start further: /usr/sbin/nginx -c /etc/nginx/nginx.conf
And... nginx is started! It is in the processes and netstat shows that the process is listening on the port such and such, etc. I mean, everything is great.
I try to start the service again, after unloading nginx from memory, of course.:
nginx -s stop
service nginx start
- we return to the same as it was at the beginning.
Can you please explain what kind of magic is this?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
sim3x, 2017-01-21
@Wolfnsex

[nginx] Don't use type=forking in systemd service file
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=...

I
Ivan Novikov, 2017-01-21
@stranger777

This is a memory allocation error. It can happen to both muscle and gzip. Either the server eats a lot of memory when it is started from service, or there is little memory in principle. See how much it eats.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question