You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi there! First of all: awesome script, I found it by mere chance, and it works so flawlessly that it's actually scary...
Now for a suggestion — I've mostly used this script to add pagespeed & brotli support on nginx. pagespeed in particular has a gazillion options, but one that pretty much everyone will be using is, obviously, adding the cache directory.
By convention — and your script follows this convention! — /var/ngx_pagespeed_cache is the default. However, a common configuration change (at least on Ubuntu/Debian) is to use a tmpfs-mounted directory for the cache, say, /run/ngx_pagespeed_cache (and just use a symlink to keep the rest of the default configuration working).
This has a problem: when rebooting, as expected, the content of /run will be lost, and when nginx starts, it expects /run/ngx_pagespeed_cache to exist, and because it doesn't exist any more (just a broken symlink pointing to it), nginx will fail to run.
On systems using systemd, one simple solution is to add a small file under /usr/lib/tmpfiles.d, which will tell the system what to create when starting up. In fact, a lot of packages (mysql, php-fpm, among so many others...) use this method to set up sockets, for example, which are conveniently created on a tmpfs volume for added speed.
It would be nice if a future version of nginx-autoinstall would be able to create something like that automatically, e.g.:
This could be one of the (many) extra options for those interested in having a tmpfs-based cache for pagespeed...
Keep updating nginx-autoinstall, great job so far, and thanks again!
The text was updated successfully, but these errors were encountered:
GwynethLlewelyn
changed the title
Enhancement suggestion: for PageSpeed, automatically create directory
Enhancement suggestion: for PageSpeed, automatically create cache directory
Jun 4, 2019
EDIT: Foot in mouth.
Create a directory. Insert this into fstab for nginx or other uses in your stack: tmpfs /var/cache/stack_cache tmpfs size=256m,mode=0775,uid=www-data,gid=www-data 0 0
Creating a tmpfs would be a headache because it's only usable by root, and it is, well, temp. I've been down this rabbit hole.
Most flavors of Linux offer tmpfs device which any user can use called /dev/shm. It is not mounted to a specific directory by default, but you can still use it as one. Just create a directory in /dev/shm and then symlink it to wherever you want. You can give the created directory any permissions you choose, so that www-data and PHP users can use it.
This is a RAM backed device, so what's there is in memory by default. You can create any directories you need inside /dev/shm Naturally, files placed here will not survive a reboot, and if your machine starts swapping, /dev/shm won't help you.
Whoops. Sorry. I sort of get lost with all threads waiting for my input... and this one has been around for two years. Ugh!
Note that I originally suggested this as an option — not as a default setting — which, as you so well pointed out, could be a really bad idea.
However, there are many other weird and potentially dangerous options on the script... if you don't know what they're for. That's why they are options...
Hi there! First of all: awesome script, I found it by mere chance, and it works so flawlessly that it's actually scary...
Now for a suggestion — I've mostly used this script to add
pagespeed
&brotli
support onnginx
.pagespeed
in particular has a gazillion options, but one that pretty much everyone will be using is, obviously, adding the cache directory.By convention — and your script follows this convention! —
/var/ngx_pagespeed_cache
is the default. However, a common configuration change (at least on Ubuntu/Debian) is to use atmpfs
-mounted directory for the cache, say,/run/ngx_pagespeed_cache
(and just use a symlink to keep the rest of the default configuration working).This has a problem: when rebooting, as expected, the content of
/run
will be lost, and whennginx
starts, it expects/run/ngx_pagespeed_cache
to exist, and because it doesn't exist any more (just a broken symlink pointing to it),nginx
will fail to run.On systems using
systemd
, one simple solution is to add a small file under/usr/lib/tmpfiles.d
, which will tell the system what to create when starting up. In fact, a lot of packages (mysql
,php-fpm
, among so many others...) use this method to set up sockets, for example, which are conveniently created on atmpfs
volume for added speed.It would be nice if a future version of
nginx-autoinstall
would be able to create something like that automatically, e.g.:This could be one of the (many) extra options for those interested in having a
tmpfs
-based cache forpagespeed
...Keep updating
nginx-autoinstall
, great job so far, and thanks again!The text was updated successfully, but these errors were encountered: