Installing DokuWiki

DokuWiki – wiki engine, to create documentation.

On the test, I install DokuWiki in Ubuntu Server.

Install the necessary components and activate the module Rewrite:

sudo apt-get install apache2 libapache2-mod-php php-xml
sudo a2enmod rewrite

Download the archive with the latest version of DokuWiki and unpack it:

cd /var/www/html
sudo wget https://download.dokuwiki.org/src/dokuwiki/dokuwiki-stable.tgz
sudo tar xvf dokuwiki-stable.tgz
sudo mv dokuwiki-*/ dokuwiki

We will expose the right owner for all files (under which Apache2 works):

sudo chown -R www-data:www-data /var/www/html/dokuwiki

Create a test web configuration file:

sudo nano /etc/apache2/sites-available/dokuwiki.conf

Add content to it (we will tailor it to your needs, for DokuWiki you need AllowOverride All):

<VirtualHost *:80>
DocumentRoot /var/www/html/dokuwiki
<Directory /var/www/html/dokuwiki>
Options -Indexes
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>

We activate the web configuration and restart the web server:

sudo a2ensite dokuwiki
sudo service apache2 reload

Open the browser in the install page http: //SERVER/dokuwiki/install.php and follow the directions.

After the successful installation, delete the installation file:

sudo rm /var/www/html/dokuwiki/install.php

If you want to send email messages from the server, you can install Postfix for example:

sudo apt-get install postfix

See also:
Installing and Configuring Postfix
Installing and Configuring the Apache2 Web Server

Solution to the error “Unable to lock the administration directory (/var/lib/dpkg/)”

I noticed some error when executing apt-get install and other commands with apt-get:

Unable to lock the administration directory (/var/lib/dpkg/); is another process using it?

I noticed the error on my virtual test Ubuntu Server, on which I performed various settings via apt-get install and during the execution the power was lost and the installation was not completed.

In my case, after the server was turned on, the installation continued in the background and of course apt-get commands were not accepted, so the best option for solving the error is to wait, the “top” command shows that the installation process is continuing.
Also, if auto-update is enabled, the system can install them, in this case it is advisable to wait.

If there is no time to wait, then you can unlock the directory with the command:

sudo fuser -vki /var/lib/dpkg/lock

Bash script to reboot network devices via telnet

I noticed that some cheap managed network equipment can start working incorrectly in a few days or weeks, so I had an idea to write a reboot script and add it to the cron.

Content of the script:

#!/bin/bash
(
sleep 5
echo "admin"
sleep 5
echo "password"
sleep 5
echo "reboot"
sleep 5
echo "y"
sleep 5
echo "quit"
) | telnet 192.168.1.10

sleep 5 means a pause of 5 seconds after each command, this value is optimal for long thinking equipment. For example, for client switches D-Link DES-3200 pause can be completely removed or set 1.

See also:
Using and configuring CRON

Firmware Update Dahua IPC-HFW1320S-W

For the test, I will update the firmware on the IP camera Dahua IPC-HFW1320S-W.

Let’s see what firmware is installed, open the web interface of the device, select the “Setting” tab, on the left the “Information” – “Version” menu.

In my case, the Russian version of the firmware was installed:

System Version 2.400.0001.11.R, Build Date: 2017-04-01
WEB Version 3.2.1.392220
ONVIF Version 2.42

Let’s see a new firmware on the official site and download it
https://www.dahuasecurity.com/products/productDetail/5631

The firmware file is usually in the archive, so unpack it.

In the web interface of the device, open the “Setting” tab, on the left in the “System” menu – “Upgrade”.
Press the “Browse…” button, select the file of the new firmware unpacked from the archive and press the “Upgrade” button to start the update process, which will last about 5 minutes, at this time you can not turn off the power of the device.

I was flashing with the English firmware, after the firmware in the “Information” – “Version” menu, the following was displayed:

System Version 2.400.0000000.16.R, Build Date: 2017-08-31
WEB Version 3.2.1.490211
ONVIF Version 16.12(V2.3.1.458331)

How to remove hiberfil.sys file

The file hiberfil.sys is created and used by the operating system for the correct operation of the sleep mode. When the computer goes into sleep mode, all data from the RAM is stored in this file. The size of this file is usually not less than the amount of computer RAM (RAM).

If you need to delete the hiberfil.sys file, you will have to disable sleep and hibernation on your computer. To do this, open “Control Panel” -> “Power Supply” -> “Power Scheme Setup” and in the window that opens, click “Never” and click “OK” in the opposite window.
Next, you need to type the following command in the command line or “execute” (Windows + R):

powercfg -h off

or

powercfg –hibernate –off

and click “OK”. The hiberfil.sys file will be deleted automatically.
If you suddenly changed your mind and decided to return to hibernation, then you can run the command:

powercfg -h on

These manipulations must be performed on behalf of the administrator.

The solution of the error “Kernel failure” and “Out of memory” in Mikrotik

There was a problem, often began to reboot itself MikroTik CAS125-24G-1S-RM.
The firmware at that time was the last one – WebFig v6.9
The following information was displayed in the logs:

System rebooted because of kernel failure
Out of memory condition was detected
router was rebooted without proper shutdown

Having looked in “system” -> “resources” it was evident that the free memory of the device is constantly decreasing.
Then I began to recall what was involved and configured on the device.
Bumping into and looking “Cache Used” in “IP” -> “Web Proxy” it was evident that the size of the cache is constantly growing.
From here it was clear that when the device’s memory was running out and the kernel crashed.
Therefore, the solution to this problem was to restrict the proxy cache by specifying the maximum size in the “Max. Cache Size“.
Done.

Solution of the error “Please run this cronjob as user amavis”

After installing updates on Ubuntu 14.04.1 LTS, an error with the text began to appear daily:

/etc/cron.daily/amavisd-new:
Please run this cronjob as user amavis
run-parts: /etc/cron.daily/amavisd-new exited with return code 1

The reason was the update of amavis and the migration when updating the configuration file /etc/cron.daily/amavisd-new in /etc/cron.d/amavisd-new, and for some reason the old file was not deleted.

As a result, the solution to this problem – make sure that the configuration file /etc/cron.d/amavisd-new is present and delete the old file /etc/cron.daily/amavisd-new.