Access Control Apache2

Access control Apache2 version 2.4 slightly different from 2.2, for example, to allow access to all, in version 2.4 you need to specify:

Require all granted

Allow access to the specified IP addresses:

Require local
Require ip 192.168.56.1 192.168.22.10

Allow all but the specified IP:

Require all granted
Require not ip 192.168.56.1

Allow the specified host:

Require host example.com

Prohibit all:

Require all denied

And in the version of Apache2 2.2, permit everyone access like this:

Order allow,deny
Allow from all

Prohibit all:

Order deny,allow
Deny from all

Allow access by specified IP:

Order allow,deny
Allow from 192.168.56.1 192.168.22.10

Allow the specified host:

Order Deny,Allow
Deny from all
Allow from example.com

After the changes in the Apache2 configuration, a reboot is required (if the changes were in the .htaccess file, then the reboot is not required):

sudo service apache2 restart

See also:
Using .htaccess

Change connect_timeout in MySQL

connect_timeout – the number of seconds that the mysql server waits for the connection package before terminating the connection.

Connect to MySQL and see the current value:

mysql -u USER -p
show variables like "connect_timeout";
quit;

The value of connect_timeout can be specified in the file /etc/mysql/my.cnf, for example:

[mysqld]
connect_timeout=10

In real time, you can change by executing the SQL query (after restarting MySQL it will be reset to the standard or specified in the configuration file):

SET GLOBAL connect_timeout=10;

The standard value is 10, the minimum value is 2, the maximum is 31536000.

How to install and enable mbstring

To install mbstring in Ubuntu/Debian, run the following command:

sudo apt-get install php-mbstring

In CentOS like this:

sudo yum install php-mbstring

You can activate/deactivate the module like this:

sudo phpenmod mbstring
sudo phpdismod mbstring

Restart Apache2 to apply the changes:

sudo service apache2 restart

Let’s see if mbstring is activated:

php -i | grep -i mbstring

How to get into BIOS on Lenovo laptops

Today it was necessary to go into the BIOS on the Lenovo IdeaPad 110-15IBR laptop (80T7), but when you press all the keys that are usually used to enter the BIOS, the laptop did not respond and the system continued to boot.

As it turned out, in the BIOS of this Lenovo laptop model, the HotKey Mode function is activated as standard and the functional keys are activated instead of the F1-F12 keys.

Therefore, to enter the BIOS, it is necessary to press two Fn and F2 keys simultaneously, if HotKey Mode is disabled, then simply F2.

See alsoFunction keys Fn on the laptop work the other way around

Troubleshooting /usr/sbin/ejabberdctl: line 428: 14615 Segmentation fault

I noticed once after installing EJabberd in Ubuntu Server 16.04 and adding the user from the root command:

ejabberdctl register USER localhost PASSWORD

The following error:

/usr/sbin/ejabberdctl: line 428: 14615 Segmentation fault $EXEC_CMD “$CMD”

The log file /var/log/syslog reported:

Sep 11 11:17:00 mail kernel: [4647543.535271] audit: type=1400 audit(1505117820.598:43): apparmor=”DENIED” operation=”file_mmap” profile=”/usr/sbin/ejabberdctl//su” name=”/bin/su” pid=14439 comm=”su” requested_mask=”m” denied_mask=”m” fsuid=0 ouid=0

To solve the error, I opened the apparmor configuration file:

nano /etc/apparmor.d/usr.sbin.ejabberdctl

Found the string:

/bin/su                                 r,

And changed it by adding m:

/bin/su                                 rm,

Restarted the apparmor:

sudo service apparmor restart

Done, the error no longer appears.

Eliminating duplicate headers on WordPress pages

Once asked to remove on the pages of one WordPress site repeated headlines.

After viewing the code, noticed that they are adding the plugin Yoast SEO, edited in its settings Titles & Metas – Yoast SEO line:

%%title%% %%page%% %%sep%% %%sitename%%

But it did not turn out very nicely, because the plugin sometimes missed the space after the hyphen, so I returned it as it was.

I fixed the error by commenting out the following line in the code of the active template (layout-head.php file):

// bloginfo( 'name' );

After that, the title of the pages was displayed correctly.

P.S. If you disable the Yoast SEO plugin, the above line will need to be uncommented back.
If the topic is not self-explanatory, then probably after the appearance and installation of its update, the layout-head.php file will return to the original state.

See also:
How to remove a repeating title in wordpress rss

Configuring the ircd-hybrid

Suppose we installed ircd-hybrid as I described in this article – Installing the IRC server – ircd-hybrid
Now proceed to setup.

Let’s edit the text of the welcome message:

sudo nano /etc/ircd-hybrid/ircd.motd

Make a copy of the configuration file just in case:

sudo cp /etc/ircd-hybrid/ircd.conf /etc/ircd-hybrid/ircd_original.conf

Open the main configuration file in the text editor, configure the parameters and comment out the unnecessary ones:

sudo nano /etc/ircd-hybrid/ircd.conf

In the configuration file, the standard serverinfo parameters are first followed, if desired, we change them:

serverinfo {
        name = "hybrid8.debian.local";
        description = "test";
        network_name = "debian";
        network_desc = "This is My Network";
        hub = no;
        default_max_clients = 512;
        max_nick_length = 15;
        max_topic_length = 300;
};

Further, contact the server administrator, if desired, change them:

admin {
        name = "SYSADMIN";
        description = "Main Server Administrator";
        email = "<admin@example.com>";
};

Network parameters (on which ports the ircd-hybrid will work, for example, you can change to 6667):

listen {
        port = 6665 .. 6669;
};

The first auth block that allows you to connect everything from the local address 127.0.0.1:

auth {
        user = "*@127.0.0.1";
        spoof = "i.love.debian.org";
        class = "opers";
        flags = need_password, spoof_notice, exceed_limit, kline_exempt,
                xline_exempt, resv_exempt, no_tilde, can_flood;
};

Another auth block allows you to connect to all (comment or change to your own needs):

auth {
        user = "*@*";
        class = "users";
        flags = need_ident;
};

For example, create a password for the user, copy the result of the command in an encrypted form:

mkpasswd PASSWORD

We add the possibility of authorization to any users only with a password and from the specified network:

auth {
        user = "*@192.168.3.0/24";
        class = "users";
        flags = need_password;
encrypted = yes;
password = "PASSWORD_FROM_mkpasswd";
};

In the auth block the password will be stored in encrypted form, in the IRC client it is specified as it is.
To specify the password in the auth block in the unencrypted form, you need to remove encrypted.

In the general section, disable the need_ident:

general {
...
disable_auth = yes;
...
};

Restart ircd-hybrid to apply the changes:

sudo /etc/init.d/ircd-hybrid restart
sudo service ircd-hybrid restart

We can also add an operator:

auth {
name = "admin";
user = "admin@192.168.3.254/32";
class = "opers";
flags = need_password, spoof_notice, exceed_limit, kline_exempt;
encrypted = yes;
password = "PASSWORD_FROM_mkpasswd";
};

You can block IP addresses as necessary in the following ways:

deny {
       ip = "192.168.4.4/32";
       reason = "Spam";
};

After the changes in the configuration file, you need to restart the ircd-hybrid.
As a customer you can use for example free AdiIRC.