Skip to main content
Category

Server Admin

Server Management

Centos 7 / Mysql – Too many open files error

By Server Admin No Comments

Even after raising the limit in ‘/etc/security/limits.conf’ and restarting the system, I was getting the ‘Too many open files’ error.

The solution that worked –

edit /usr/lib/systemd/system/mysqld.service and add

LimitNOFILE=infinity
LimitMEMLOCK=infinity

run systemctl daemon-reload and systemctl restart mysql.service

nginx gzip_static module

By Server Admin No Comments

gzip_static module allow nginx to serve gzipped files directly without compressing the files on the fly (saving cpu cycles)

gzip_static ignores the ‘gzip_types’ directive and look for gzipped version for each and every file on every request.

To force gzip_types for specific type of files (css,js) and ignore image files (jpeg,gif,png)
use the location directive-

location ~*.*\.(css|js|ico|txt)$ {
gzip_static on;
}

And to check if the gzip_static is working and nginx is serving the .gz version of static files.
use this command.

ps auxw | grep nginx | awk '{print"-p " $2}' | xargs strace 2>&1 | grep gz

Disable error.log and vhost-error_log in Nginx

By Server Admin No Comments

If you know what you are doing and have a pretty good reason to do it, this is one way to do it.


ln -fs /dev/null /var/log/nginx/error.log
ln -fs /dev/null /var/log/nginx/vhost-error_log

the command will clear the content of the files and create a junction to “/dev/null”. All further logs will be sent to blackhole (discarded).