new ebuild for Nginx
Unlike Apache httpd server Nginx has no ebuilds which let you select which modules you want to have installed with it. Yet.
On last Saturday I have written an eclass to simplify maintaining Nginx ebuilds and added a new Portage variable NGINX_MODULES to USE_EXPAND. In other words, from that on you can select Nginx modules like for Apache. As an example, to compile with Redis support, you could set that in your make.conf:
NGINX_MODULES="${NGINX_MODULES} redis"
Of course, it is best you added all these lines:
USE_EXPAND="${USE_EXPAND} NGINX_MODULES"
NGINX_MODULES="static rewrite autoindex auth_basic access limit_zone limit_req geo map referer rewrite proxy upstream_ip_hash"
NGINX_MODULES="${NGINX_MODULES} redis"
HTTPD_USER="nginx"
HTTPD_GROUP="www"
- Line 1 does the magic, it adds that dedicated modules section for segregating from USE flags. Please click on this posts’ lead image for a visualization.
- Lines 3 and 4 define the modules which Nginx shall be compiled with. Line 3 is the defaults, which you could leave out. Doing so is no good idea, because you might start relying on them but someone might decide to make some of it optional in future. Keeping them will make you immune to those changes.
- By lines 6 and 7 you can alter the user http deamons run on. Some people prefer “nobody:www”, some use “wwwrun:www” and as sad default Gentoo has “apache:apache” – which only makes sense in the one specific circumstance you are using Apache. “www” as group is a good idea, and Nginx running as “nginx” not the worst.
By the next days I will try to add some more optional third party modules.















Please fix in nginx.eclass [199-201] as in original www-servers/nginx
--http-client-body-temp-path=/var/tmp/${PN}/client \ --http-proxy-temp-path=/var/tmp/${PN}/proxy \ --http-fastcgi-temp-path=/var/tmp/${PN}/fastcgi \Dm, how would this be a fix?
Indeed, on most servers I’ve seen /tmp being on (transient) tmpfs and /var/tmp being a larger, but persistent temporaries’ folder on HDD which is preserved between system reboots. – What conforms to FHS 2.3.
Finally, Nginx does not create subfolders on its own, creates temporary files in a safe manner and does not assume they exist between two program invocations.
Therefore /tmp (or anything beneath it) is the only correct place.
Maybe, but this folders must not be the same by default when running nginx at first time.
client-body-temp-path & proxy-temp-path are new options in nginx and without it default values nginx old configs are broken
Hello Mark,
Having the temporary paths set to /tmp will make the nginx startup script to fail if the system is rebooted since that directory could be wiped via /etc/conf.d/bootmisc or, as you mentioned, being on tmpfs.
You should either create those /tmp/nginx/* directories from within the startup script or keep using /var/tmp/nginx/* which is FHS compliant (“/var/tmp : Temporary files preserved between system reboots”) for this particular case.
Even if /tmp is ‘wiped’, the directory itself is preserved. I have tested it several times, and Nginx
worksstarts fine.But given the demand, I will include a check in future Ebuilds so you can set /var/tmp as temporaries’ directory. (Which will be, Juan, not FHS compliant. But there is no harm, either.)
Hey Mark,
Sorry for being a pain
on the subject but:
“The /var/tmp directory is made available for programs that require temporary files or directories that are preserved between system reboots.”
Nginx requires those directories to start, not the files inside them.
Have a look at the diferences on the FHS, /var/tmp is the right place.
http://www.pathname.com/fhs/pub/fhs-2.3.html#TMPTEMPORARYFILES
http://www.pathname.com/fhs/pub/fhs-2.3.html#VARTMPTEMPORARYFILESPRESERVEDBETWEE
Regards
Juan, I’ve read the FHS, and watched its creation process since the beginning. When having seen many systems and its quirks, you will quickly realize there is no way around standardization. You got a valid point, so it is good we discuss about it.
By introducing the artificial requirement for a subdirectory, indeed, there is no way around using /var/tmp. Just keep in mind it works perfectly (and faster) without that, and we still can create the empty directories by start scripts.
Till Nginx 0.8.34 is released you can fork the overlay. Every
git fetch; git mergewill preserve your adaption. And yet still you can tweak your configuration files. Nothing is written in stone. ^_~