How to enable nginx stub status

How to enable nginx stub status

Edit nginx.conf add in the server { ….. } block/context

location /nginx_status {
	# Turn on nginx stats
	stub_status on;

	# I do not need logs for stats
	access_log   off;

	# Security: Only allow access from your IP address #
	allow your ip address;

	# Send rest of the world to /dev/null #
	deny all;
}

For Plesk edit  /etc/nginx/plesk.conf.d/server.conf

Could not open archive dir for / Could not open archive mbox dir

/usr/local/cpanel/scripts/update_mailman_cache

How to fix the errors

Could not open archive mbox dir for somelist: No such file or directory at /usr/local/cpanel/Cpanel/Mailman/DiskUsage.pm
Could not open archive dir for somelist: No such file or directory at /usr/local/cpanel/Cpanel/Mailman/DiskUsage.pm

Solution

If we have a list named list1_webinformat.com the error is

Could not open archive mbox dir for list1_webinformat.com: No such file or directory at /usr/local/cpanel/Cpanel/Mailman/DiskUsage.pm

and we have to create 2 dirs

mkdir /usr/local/cpanel/3rdparty/mailman/archives/private/list1_webinformat.com.mbox
mkdir /usr/local/cpanel/3rdparty/mailman/archives/private/list1_webinformat.com

After we create the needed directories we run 2 commands

/usr/local/cpanel/scripts/fixmailman

/scripts/update_mailman_cache

Let me know in comments if you need any help or if this helped you.
Happy coding 😉

Hot link protection

Simple hot link protection using .htaccess


 RewriteEngine on
 #RewriteCond %{HTTP_REFERER} !^$
 RewriteCond %{REQUEST_FILENAME} -f
 RewriteCond %{REQUEST_FILENAME} \.(gif|jpe?g?|png)$ [NC]
 RewriteCond %{HTTP_REFERER} !^https?://([^.]+\.)?your-domain\. [NC]
 RewriteCond %{HTTP_REFERER} !^https?://([^.]+\.)?google\. [NC]
 RewriteRule \.(gif|jpe?g?|png|bmp)$ http://your-domain/hotlinkdenied [R,L]

  • Replace your-domain with your actual domain name
  • Replace http://your-domain/hotlinkdenied with a valid url

Ubuntu server no login console

After boot there was no console prompt to login.

The issue was related to the VGA resolution.

To fix Ubuntu server no login console

modify in /etc/default/grub

# Grub Resolution
GRUB_GFXMODE=1024x768x24

# Kernel param to set a port to resolution and vertical refresh.
GRUB_CMDLINE_LINUX_DEFAULT="nomodeset video=VGA:[email protected]"

Of course, you can set resolution to suit your needs by replacing 1024x768x24 to whatever you need.

WordPress – give contributor permission to upload images without plugin.

WordPress contributor role lacks the permission to upload images.
There are a few plugins that can let you change role permissions, but I just needed to allow contributor role to upload images.

One minor change in the theme’s functions file is sufficient to give WordPress contributor role the permission to upload & insert images without plugin:

if ( current_user_can('contributor') && !current_user_can('upload_files') )
	add_action('admin_init', 'wif_allow_contributor_uploads');

function wif_allow_contributor_uploads() {
	$contributor = get_role('contributor');
	$contributor->add_cap('upload_files');
}