Installing and Configuring HAProxy on Linux

HAProxy – proxy server for load balancing of TCP and HTTP applications, a method of distribution to multiple servers.

The Haproxy installation command in Ubuntu / Debian:

sudo apt-get install haproxy

For CentOS:

yum install haproxy

To view the installed version, you can use the command:

haproxy -v

We will check whether it will automatically start when the system is turned on, there should be ENABLED = 1 (in the nano editor CTRL+X to exit, y/n to save or cancel changes):

sudo nano /etc/default/haproxy

In CentOS, simply execute the command:

chkconfig haproxy on

Make a copy of the configuration file just in case:

sudo cp /etc/haproxy/haproxy.cfg{,.original}

Open the main configuration file in the editor:

sudo nano /etc/haproxy/haproxy.cfg

I will give an example of a configuration:

global
    log /dev/log    local0
    log /dev/log    local1 notice
    chroot /var/lib/haproxy
    user haproxy
    group haproxy
    daemon

defaults
    log     global
    mode    http
    option  httplog
    option  dontlognull
    contimeout     5000
    clitimeout     50000
    srvtimeout     50000
    errorfile 400 /etc/haproxy/errors/400.http
    errorfile 403 /etc/haproxy/errors/403.http
    errorfile 408 /etc/haproxy/errors/408.http
    errorfile 500 /etc/haproxy/errors/500.http
    errorfile 502 /etc/haproxy/errors/502.http
    errorfile 503 /etc/haproxy/errors/503.http
    errorfile 504 /etc/haproxy/errors/504.http
    retries 3
        
listen webfarm 0.0.0.0:80
    mode http
    stats enable
    stats uri /haproxy?stats
    stats auth user:password
    maxconn 5000
    balance roundrobin
    option httpclose
    option forwardfor
    server webserver01 192.168.88.50:80 check
    server webserver02 192.168.88.51:80 check

Parameter maxconn 5000 defines the maximum number of simultaneous connections, 0 is used to remove the limit, if not specified, it will be standard 2000.

For example, to use Apache2 on the same local machine, change its /etc/apache2/ports.conf and /etc/apache2/sites-enabled/ configuration files from 80 to 81 for example, and /etc/haproxy/haproxy. cfg we indicate:

server webserver01 0.0.0.0:81 check

Each time after a configuration change, you must restart:

sudo service apache2 restart
sudo service haproxy restart

This completes the installation and the basic configuration of HAProxy.

How to install PHP 5.6 in Ubuntu 16

In Ubuntu 16, installing PHP with apt-get install php installs PHP version 7, so to install PHP 5.6, you can add a third-party repository.

If the system has PHP 7 installed, then you can delete all of its components like this:

sudo apt-get purge `dpkg -l | grep php| awk '{print $2}' |tr "\n" " "`

Now add a third-party source:

sudo apt-get install software-properties-common
sudo add-apt-repository ppa:ondrej/php

And install from it PHP 5.6:

sudo apt-get update
sudo apt-get install php5.6

Similarly, you can install modules, for example:

sudo apt-get install php5.6-mysql php5.6-mcrypt php5.6-mbstring php5.6-xml

To check the installed version of PHP, perform:

sudo php -v

See also my article:
Upgrading PHP Version on Ubuntu 14.04

Updating Ubuntu 14.04 to 16.04

Before updating I recommend to make a backup copy of the important information.

Update the system to the current state:

sudo apt-get update
sudo apt-get upgrade

Restart:

sudo reboot

Let’s see the current version:

lsb_release -a

We are ready to upgrade to version 16.04:

sudo update-manager -d

Or so:

sudo do-release-upgrade

After the update is complete, you will need to reboot.
I will note that many packages will also be updated, for example PHP5 will be updated to PHP7, etc., so you need to be ready for this.
How to downgrade the PHP version I described in this article – How to install PHP 5.6 in Ubuntu 16
Or how to upgrade here – Upgrading PHP Version on Ubuntu 14.04

Hard reset on Samsung Galaxy J5

For example, perform a full reset of the Samsung Galaxy J5

1) First you need to turn off the phone.

2) Press the volume addition key at the same time, home (oval below) and the power key, keep them all three before the Samsung logo appears, then release.

3) With the volume keys, select “wipe data / factory reset” in the list, and select the power key (possibly also with the Home key), in the next window select “ Yes ” in the same way. And lastly select “ reboot system now

Done, the phone will start with completely reset settings and remote user data, such as applications, contacts, etc.

Connect to SSH using the keys

To connect to SSH without entering a password, you can generate public and private keys on the local north, then copy it to a remote machine, then the password will not be asked when connecting to it.

On the local machine, generate the keys:

sudo ssh-keygen -t rsa

Copy the public key to the remote server:

sudo ssh-copy-id -i ~/.ssh/id_rsa.pub -p PORT USER@HOST

If an error occurs while copying the key, you can manually copy the line from id_rsa.pub to the remote server in the authorized_keys file.

The specified commands must be executed from the user from whom the connection will be made.
For example, if from root, then you need to execute the following command before the two commands:

sudo -i

You can remove the host by:

ssh-keygen -f "/home/user/.ssh/known_hosts" -R [HOST]:22

See also:
Installing and Configuring SSH

Canon EOS 500D / Rebel T1i Firmware Update

On the test, I will update the firmware 1.1.0 to 1.1.2 in the Canon EOS 500D / Rebel T1i.

First of all, let’s see if there is a newer version on the official siteе and if there is – download it.
https://www.usa.canon.com/internet/portal/us/home/support/details/cameras/support-dslr/eos-rebel-t1i?subtab=downloads-firmware

Unpack the archive with the firmware, in my case I needed one file E7KR6112.FIR

The memory card is pulled out of the camera and connected through the card reader to the computer, we drop the firmware file on it. Through a USB cord directly to a card to write down a file the camera has not given.

We will safely remove the memory card and return it to the camera.

On the camera, set the mode “P” and turn it on, press the “MENU” button, select the yellow key, then “Built-in software ver. … “, agree with the replacement of the current software by selecting” OK “, then follow the prompts on the screen.

Watch the video how I performed the update:

How do I enable the Universe repository in Ubuntu?

I once wanted to install some utilities on the running LiveCD with Ubuntu Desktop, the same MC, etc., which did not want to be installed.

To solve this problem, you need to include the “Universe” repository.

And so, add it:

sudo add-apt-repository universe

In older versions of Ubuntu, you might have to add another command:

sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu $(lsb_release -sc) universe"

If desired, you can include all the repositories:

sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu $(lsb_release -sc) main universe multiverse restricted"

And update the list of packages:

sudo apt-get update

After that, everything was install successfully.

Above $(lsb_release -sc) specifies the version of Ubuntu and inserts it into the link.

You can also manually check the version by running the command:

lsb_release -sc

Installing Open-AudIT on Linux

Open-Audit — a system for collecting information about existing equipment and creating reports.

On an example I will describe the installation process in Linux Ubuntu:

1) Download the latest version from the official site
https://www.open-audit.org/downloads.php

2) Switch to the root user, make the downloaded file with Open-AudIT executable and run it:

sudo -i
chmod u+x ./OAE-Linux-x86_64-release_1.12.10.1.run
sh ./OAE-Linux-x86_64-release_1.12.10.1.run

In the installation process, follow the instructions, agreeing with the questions pressing “y” or “Enter“.
Additional components such as apache2, mysql-server, etc. will be automatically installed.

3) Open in the browser web-interface Open-AudIT by reference http://HOST/omk/oae/
Standard login and password – admin/password

Done.