Keep current version of config files when apt-get install on Debian

To automatically keep current config files when doing apt-get install on Debian: apt-get install nginx -y -o Dpkg::Options::="–force-confdef" -o Dpkg::Options::="–force-confold"apt-get install nginx -y -o Dpkg::Options::="–force-confdef" -o Dpkg::Options::="–force-confold" You can find more info on Raphael Hertzog’s Blog. Here are more info about –force-confold and –force-confdef: confold: If a conffile has been modified and the version in […]

How to Extract Links from a Web Page in Linux

In Linux you can extract links from a web page easily: Using Lynx Extract links and save them to links.txt file: lynx -dump | awk ‘/http/{print $2}’ > links.txtlynx -dump | awk ‘/http/{print $2}’ > links.txt If you need to add numbers to lines, use nl command: lynx -dump | awk ‘/http/{print […]

PHP Library for Google Authenticator (Two Factor Authentication 2FA)

Here is a very simple and working PHP library for Google Authenticator: With that library you can easily integrate two factor (2FA) authentication like this: require_once ‘PHPGangsta/GoogleAuthenticator.php’;   $ga = new PHPGangsta_GoogleAuthenticator();   // Save this $secret in a database and load it from the database the next time // The $secret variable should […]

Should I reboot Debian server after apt-get upgrade?

If you ran “apt-get upgrade” you don’t always need to reboot the Debian server. To know if you need to reboot the server after “apt-get upgrade”, check if this file is present (it is generally of 0 bytes, so it is an empty file): /var/run/reboot-required/var/run/reboot-required Here is an example on my Debian server: -rw-r–r– 1 […]

SetDefaultDllDirectories could not be located

To fix this error in Windows 7: setDefaultDllDirectories could not be located in the dynamic link library KERNEL32.dll 1) Open this link: 2) Select the file corresponsiding to your operating system, i.e: Update for Windows 7 for x64-based Systems (KB2533623) 3) Install the Windows Update package (.msu) 4) Reboot the PC 5) Done!

Debian Install GCC Compiler and Development Environment

Install essential applications for building Debian packages: apt-get update apt-get install build-essentialapt-get update apt-get install build-essential The package build-essential will install libc6-dev, gcc, g++, make, etc. That’s all!

How to build ImageMagick so that it’s statically built

First install gcc and other needed packages to build ImageMagick: apt-get install build-essentialapt-get install build-essential Then install important ImageMagick libraries (i.e libpng, libjpeg, etc): apt-get install libpng-dev apt-get install libexif-dev apt-get install zlib1g-dev apt-get install libwebp-dev apt-get install libtiff5-dev apt-get install libjpeg-dev apt-get install libbz2-dev apt-get install liblzma-dev apt-get install libdjvulibre-dev apt-get install libopenjp2-7-dev apt-get […]

Secure ImageMagick to Prevent Vulnerabilities

You can “harden” ImageMagick to prevent code execution and other vulnerabilities. Add this to /etc/ImageMagick-6/policy.xml: <!– Mitigate Image Magick vulnerabilities –> <!– –> <policy domain="coder" rights="none" pattern="URL" /> <policy domain="coder" rights="none" pattern="HTTPS" /> <policy domain="coder" rights="none" pattern="EPHEMERAL" /> <policy domain="coder" rights="none" pattern="MVG" /> <policy domain="coder" rights="none" pattern="MSL" /> <policy domain="coder" rights="none" pattern="TEXT" /> <policy […]

Htaccess file for WordPress websites

Create a .htaccess file on the root directory of your website. Then copy the content below on the .htaccess file: # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ – [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress# BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / […]

How to Create Backups of MySQL via PHP

If you website is hosted on a web hosting like OVH, you should make sure to periodically backup your MySQL database as additional precaution, just in case the automated backup offered by the hosting provider fails. With OVH, for example, you can create cronjobs that execute PHP files located in your FTP home directory, here […]