Manage Your Own Server

SMTP server telnet connection refused on Linux?

I was testing the WP Mail SMTP plugin to send emails in WordPress via SMTP servers but when it was trying to connect to the remote SMTP server, it kept getting error “Connection refused”. So I tried: telnet smtp.xxxx.com 587 To test the connection. Turned out my own server is preventing the outgoing request because …

SMTP server telnet connection refused on Linux? Read More »

Whitelist server IPs for SSH connection against ERROR – ssh: connect to host port: Connection refused

If you have multiple servers you’d probably need rsync to transfer files among servers via SSH. An error like this, however, will occur when CSF protects the servers against malicious SSH connection attempts: The solution is very simple. Just whitelist each server IP on the other server and vice versa: Wherein 1.1.1.1 is the other …

Whitelist server IPs for SSH connection against ERROR – ssh: connect to host port: Connection refused Read More »

Clone any static site by a simple Linux command WGET

Just use this and the WGET command will start crawling the target site and download certain levels of pages from the starting URL, including all its assets such as images or CSS files. wget -k -K -E -r -l 1 -p -N -F –convert-links -H -Dcdn.shopify.com,v.shopify.com,www.yoursite.com,your-site.myshopify.com –restrict-file-names=windows https://www.yoursite.com/ The -D option specifies all the hosts …

Clone any static site by a simple Linux command WGET Read More »

500 Internet Server Error for Incorrect Permissions after Installing suPHP and Uploading PHP Script

Many’s the time after you have uploaded some PHP script to your server and point the web browser to the address it gives 500 Internet Server Error. If you have suPHP installed this is very likely because the uploaded PHP script (files and directories) have wrong permissions set to them. With regards to Linux permissions, …

500 Internet Server Error for Incorrect Permissions after Installing suPHP and Uploading PHP Script Read More »

Make phpMyAdmin Show Exact Number of Records for InnoDB Tables

By default, phpMyAdmin shows an estimated number of records for InnoDB tables that have more than 20,000 rows. It can vary by every fresh as much as 50% or even more. Makes it hard to get an exact number of records for the tables as we have to explicitly run an SQL query to do …

Make phpMyAdmin Show Exact Number of Records for InnoDB Tables Read More »

PHP Class for Handling .htpasswd and .htgroup (Member Login & User Management)

Apache is a marvelous web server that offers .htpasswd and .htgroup for controlling restricted access to your website. By help of .htaccess, they work as a member login & user management system that is so simple and easy to deploy. You can even define user groups / roles with it. Basically, .htpasswd defines pairs of …

PHP Class for Handling .htpasswd and .htgroup (Member Login & User Management) Read More »

<IfModule></IfModule> in .htaccess

I was debugging about some mod_rewrite errors caused by the .htaccess file on one of my sites and couldn’t solve the problem myself so I opted for a help thread on the SitePoint.com forum. Turned out it’s not the problem of my mod_rewrite rules in .htaccess but some incorrect file permissions that were causing the …

<IfModule></IfModule> in .htaccess Read More »

Linux: How to delete / remove hidden files with ‘rm’ command?

To delete all content in any directory, including all sub-directories and files, I’ve been using this: rm -rf somedir/* If it is to delete all content of the current directory: rm -rf * However, it turns out ‘rm -rf’ doesn’t remove hidden files such as .htaccess (Files with a name starting with a dot are …

Linux: How to delete / remove hidden files with ‘rm’ command? Read More »

Linux: How to ‘find’ and search ONLY text files?

The ‘find’ command in Linux systems searches through a directory and return files that satisfy certain criteria. For instance, to find a file that contains the string ‘needle text’ in the ‘mydocs’ directory: find mydocs -type f -exec grep -l “needle text” {} \; The problem of this approach is that it would search through ALL files …

Linux: How to ‘find’ and search ONLY text files? Read More »

How to bring down / optimize memory usage in your unmanaged Linux VPS box and avoid OOM (Out Of Memory) errors?

The other day I was very upset about some extraordinary down times of my unmanaged VPS box at Linode. As it’s unmanaged, support staff at Linode are not responsible for the failures. I contacted them and they told me it’s OOM (Out Of Memory), pointing me to the right documentation to figure out how to …

How to bring down / optimize memory usage in your unmanaged Linux VPS box and avoid OOM (Out Of Memory) errors? Read More »

Use .htaccess to allow access only from a single HTTP referrer

Sometimes you want the user to access something (a web page or a downloadable file) only by clicking a link on your own website instead of being able to directly access it by typing in the URL address in the browser address bar. This is achievable by a few lines in .htaccess. RewriteEngine On RewriteCond …

Use .htaccess to allow access only from a single HTTP referrer Read More »

Turn off and disable magic_quotes_gpc in .htaccess

It’s not only insecure but it inconveniently commands the use of PHP function stripslashes() every time you pull something from the database or when you get something from the client side. While most of the hosts out there are using factory settings of PHP that turn off magic_quotes_gpc by default, there are a few that …

Turn off and disable magic_quotes_gpc in .htaccess Read More »

Use stat command to display file system meta information of any file or directory under Linux

PHP has a stat() function that returns an array containing the meta information of a file such as owner, size, time of last access, last modification or last change. It’s basically the stat command under Linux that returns and shows the file system meta information of any file or directory: stat myfile.txt Which returns: File: …

Use stat command to display file system meta information of any file or directory under Linux Read More »

Linux: How to open and extract an RAR zipped file and unrar the archive?

Funny I should use “zipped” for an RAR compressed package. Anyway, you can easily zip or unzip a zip file or tar compress a package, but how does one do it with an RAR file? WinRAR is well distributed across all Windows systems. But on Linux, you have to first install the command package rar. …

Linux: How to open and extract an RAR zipped file and unrar the archive? Read More »

Scroll to Top