Nginx Commands

Nginx Commands

Check for nginx

netstat -lntp | grep nginx

Check that apache is not using the same ports

netstat -lntp | grep httpd

Clear nginx cache

ngxconf -u userna5 -rd

Rebuid rules

You must run this after you change the any nginx config files. This will tell you if there are bad rules.

nginx -s reload

Clear nginx cache for all users

for i in $(\ls /var/cpanel/users | grep -v system); do ngxconf -u $i -rd --nofpm; done

Install nginx

First use WHM > Tweak Settings to change apache to ports 8080 for http and 8884 for https.

yum install imh-ngxconf
yum install imh-cpanel-cache-manager

Reset everything

I grabbed this one from BrianJ. I will break this up into parts later.

yum -y install imh-ngxutil.noarch;for i in $(\ls /var/cpanel/users |grep -v system); do ngxconf -u $i -rd; ngxutil -Xu $i;/scripts/rebuildhttpdconf; service httpd graceful;service nginx restart;service httpd restart;/scripts/restartsrv_apache_php_fpm;done

Rebuild nginx Certificates

This example is for the domain battlegrid.thegreatdivide.info and is not well tested. Take it one line at a time. Replace the “ad124_ab44f” file names with ones that show up in the ls listing.

mv /var/nginx/certs/battlegrid-thegreatdivide-info.pem /var/nginx/certs/battlegrid-thegreatdivide-info.pem.old;
ls -lah /home/battlegrid/ssl/certs/*.crt;
cat battlegrid_thegreatdivide_info_ad124_ab44f_1523145599_4d2e46dff260f5151605136f37d248a0.crt > /var/nginx/certs/battlegrid-thegreatdivide-info.pem;
echo "" >> /var/nginx/certs/battlegrid-thegreatdivide-info.pem;
cat /var/nginx/certs/battlegrid-thegreatdivide-info.pem.old | tail -56 >> /var/nginx/certs/battlegrid-thegreatdivide-info.pem;

mv /var/nginx/certs/battlegrid-thegreatdivide-info.key /var/nginx/certs/battlegrid-thegreatdivide-info.key.old;
ls -lah /home/battlegrid/ssl/keys/;
cp /home/battlegrid/ssl/keys/ad124_ab44f_0ed7d7b217d0c008b3c79b242dee8cff.key /var/nginx/certs/battlegrid-thegreatdivide-info.key;

nginx -s reload;