Linux

Configure varnish cache in front of any website

You need to get a dedicated server, VPS or a droplet on the digital ocean to setup varnish server. Now i would be explaining the life cycle of each request. The request will come on 443 which would be nginx in our case or 80 which would be varnish server. Port 443...

Read more...

Record server uptime in text file

Create a shell script and execute that shell script. TODAY=$(date +"%T") SCRIPT=$(uptime | awk '{print $(NF-2)" "$(NF-1)" "$(NF-0)}') echo "$TODAY | $SCRIPT" >> /root/script/out.txt  

Read more...

Correct owner and permissions for folders and files on linux

This command will change ownership of the folder recursively chown -R username:groupname /var/www/ This command will change folder permissions recursively find /var/www/ -type d -exec chmod 755 {} \; This command will change files permissions recursively find /var/www/ -type f -exec chmod 644 {} \;  

Read more...

How To Clear Plesk Mail Queue Via SSH (Postfix)

If you are running a Plesk server and you notice a script which has filled up the server with spam emails awaiting delivery then it is probably a good idea to clear the mailqueue. The mail queue can be cleared using the following: postsuper -d ALL how to flush postfix mail...

Read more...

Install WiringPi and controlling raspberrypi gpio pins with php

WiringPi is a GPIO access library written in C for the BCM2835 used in the Raspberry Pi. How to download wiring pi? If you do not have GIT installed, then under any of the Debian releases (e.g. Raspbian), you can install it with: sudo apt-get install git-core To obtain WiringPi using GIT git clone...

Read more...

How to stress test a server

Siege is an http/https regression testing and benchmarking utility. It was designed to let web developers measure the performance of their code under duress, to see how it will stand up to load on the internet. Install seige apt-get install siege Run the following command to seige a server. -t is the...

Read more...

How to check Internet Speed via Terminal?

Check internet speed by speedtest.net wget -O speedtest-cli https://raw.github.com/sivel/speedtest-cli/master/speedtest_cli.py chmod +x speedtest-cli ./speedtest-cli   You can also install iperf. apt-get install iperf iperf -s  

Read more...

How to render HTML into PDF files

wkhtmltopdf and wkhtmltoimage are open source (LGPLv3) command line tools to render HTML into PDF and various image formats using the QT Webkit rendering engine. These run entirely "headless" and do not require a display or display service. Install wkhtmltopdf and its requried packages sudo apt-get install wkhtmltopdf sudo ln -s /usr/bin/wkhtmltopdf /usr/local/bin/html2pdf sudo...

Read more...