RHEL CentOs Fedora htop installation

I would like to share with you nice process monitoring program htop.
I am using this program on my Fedora Linux desktop, CentOs and RHEL (Red Hat Enterprise) Linux servers.

To install it several dependent system packages should be installed as root administrator user:

# yum install ncurses ncurses-devel ncurses-libs

Change directory to your installation directory location. Mine is /root/install

# cd /root/install

Download htop using wget:

# wget --output-document=htop-1.0.2.tar.gz http://sourceforge.net/projects/htop/files/htop/1.0.2/htop-1.0.2.tar.gz/download

Unpack it:

# tar xzvf htop-1.0.2.tar.gz 

Change to directory unpacked program folder:

# cd htop-1.0.2

Configure it:

# ./configure

By default htop binary is installed to /usr/local/bin directory. You can change it by passing –prefix parameter to ./configure script
Also, you can create symbolic link using command ln -s /usr/local/bin /root/bin

Make:

# make

Install

# make install

Linux mount Windows samba share

To mount Windows samba share on Linux:
1. Log in as root administrator user.
2. Create mount point:
# mkdir -pv /mnt/share_name
3. Mount share to it using command:
# mount -t cifs -o username=User,password=Password //192.168.0.123/share_name /mnt/share_name
4. Use files from Windows share located in /mnt/share_name

Note, User should have access to Windows share //192.168.0.123/share_name

Plesk for Linux: disable Dr Web update cron notifications

To disable Dr Web update cron notifications via e-mail in Plesk for Linux:

1. Edit file Dr Web configuration file /etc/drweb/drweb32.ini using your favorite editor. Mine is vim:

# vim /etc/drweb/drweb32.ini

# CronSummary = yes
# —>
CronSummary = no

2. Edit file /etc/cron.d/drweb-update and add to the end of string >/dev/null 2>&1

# more /etc/cron.d/drweb-update

*/30 * * * * drweb /opt/drweb/update.pl >/dev/null 2>&1
#

3. If user drweb has cron jobs

# crontab -u drweb -l

55 2,7,12,17,20 * * * /opt/drweb/update.pl
change it to:
55 2,7,12,17,20 * * * /opt/drweb/update.pl >/dev/null 2>&1

4. If file /usr/local/psa/etc/drweb-update exists

# vim /usr/local/psa/etc/drweb-update 

Change its content from:

#!/bin/sh
exec /opt/drweb/update.pl

to:

#!/bin/sh

exec /opt/drweb/update.pl >/dev/null 2>&1

Linux FTP ProFtpd server configuration: setup timeouts

First step before making any changes to configuration files is to create backup:
# cp -fvp /etc/proftpd.conf /etc/proftpd.conf-2013-03-08.bak

Second step is to check service configuration to make sure it is correct.
# proftpd -td10
Checking syntax of configuration file

Syntax check complete.

Edit configuration file /etc/proftpd.conf: add timout directives inside <Global> </Global> section.
TimeoutNoTransfer 900
TimeoutStalled 600
TimeoutIdle 1200

Detaied options description below:

The TimeoutNoTransfer directive configures the maximum number of seconds a client is allowed to spend connected, after authentication, without issuing a command which results in creating an active or passive data connection (i.e. sending/receiving a file, or receiving a directory listing).

The TimeoutStalled directive sets the maximum number of seconds a data connection between the proftpd server and an FTP client can exist but have no actual data transferred (i.e. “stalled”). If the seconds argument is set to 0, data transfers are allowed to stall indefinitely (the default).

The TimeoutIdle directive configures the maximum number of seconds that proftpd will allow clients to stay connected without receiving any data on either the control or data connection. If data is received on either connection, the idle timer is reset. Setting TimeoutIdle to 0 disables the idle timer completely (clients can stay connected for ever, without sending data). This is generally a bad idea as a “hung” tcp connection which is never properly disconnected (the remote network may have become disconnected from the Internet, etc) will cause a child server to never exit (at least not for a considerable period of time) until manually killed.

Next step after making configuration changes is to check FTP service configuration again:
# proftpd -td10

Restart service.

1. If your ProFTPD server installed as part of xinetd:
# /sbin/service xinetd restart
Stopping xinetd: [ OK ]
Starting xinetd: [ OK ]

2. If your ProFTPD server installed as standard Linux service:
# /sbin/service proftpd restart
or
# /etc/init.d proftpd restart

Linux: enable or disable PHP APC opcode cache for virtual host

1. To install PHP APC module run commands:
# yum install php-devel php-pear pcre-devel
# pecl install apc

2. Example configuration file for APC
# more /etc/php.d/apc.ini
extension=apc.so
apc.enabled=”1″
; [ disable APC opcode cache by default
apc.cache_by_default=0
; ]
apc.shm_segments=”1″
apc.num_files_hint=”1024″
apc.ttl=”7200″
apc.user_ttl=”7200″
apc.gc_ttl=”3600″
apc.cache_by_default=”1″
;apc.filters=””
apc.slam_defense=”0″
apc.file_update_protection=”2″
apc.enable_cli=”0″
apc.max_file_size=”1M”
apc.stat=”1″
apc.write_lock=”1″
apc.report_autofilter=”0″
apc.include_once_override=”0″
apc.rfc1867=”0″
apc.rfc1867_prefix=”upload_”
apc.rfc1867_name=”APC_UPLOAD_PROGRESS”
apc.rfc1867_freq=”0″
apc.localcache=”0″
apc.localcache.size=”512″
apc.coredump_unmap=”0″
;default is 32M
apc.shm_size=512M
apc.mmap_file_mask=”/tmp/apcphp5.XXXXXX”
apc.mmap_address=703687441776
; file uploads progress for Drupal
apc.rfc1867=”1″
#

To check web server Apache configuration run command:
# /sbin/service httpd configtest

To apply new APC module configuration restart web server Apache using command:
# /sbin/service httpd restart

3. Example changes in main .htaccess file for virtual host shkodenko.com
# vim /home/taras/shkodenko.com/public_html/.htaccess

3.1. To enable APC opcode cache for virtual host inside IfModule block add line:

# PHP 5, Apache 1 and 2.
<IfModule mod_php5.c>

# [ enable APC opcode cache for domain
php_flag apc.cache_by_default On
# ]

</IfModule>

3.2. To disable APC opcode cache for virtual host inside IfModule block add line:

# PHP 5, Apache 1 and 2.
<IfModule mod_php5.c>

# [ disable APC opcode cache for domain
php_flag apc.cache_by_default Off
# ]

</IfModule>

Backup WordPress website procedure for Linux

To backup your WordPress website on Linux you can follow these steps:

1. Log in via ssh to your server.

2. Change directory where your website files are located. For example:
$ cd /home/shkodenko/public_html

3. Find out MySQL connection settings using command:
$ grep -ni "DB" ./wp-config.php

You will need these lines below.
19:define(‘DB_NAME’, ‘db_name’);
22:define(‘DB_USER’, ‘db_user’);
25:define(‘DB_PASSWORD’, ‘db_password’);
28:define(‘DB_HOST’, ‘localhost’);

4. Create backup of MySQL database using mysqldump utility. For example:
$ mysqldump -h localhost -u db_user -p db_name > ./wp-content/uploads/db_name.sql

5. I am checking MySQL dump using tail and head utilities:
$ tail -n 15 -f ./wp-content/uploads/db_name.sql
$ head -n 15 -f ./wp-content/uploads/db_name.sql
I am using sha1sum command to get SQL dump file checksum:

$ sha1sum -b ./wp-content/uploads/db_name.sql
I am checking SQL dump file information usinng ls command:

$ ls -Alh ./wp-content/uploads/db_name.sql
All these steps above in 5 can be skipped. I making these checks for history and possible future verification purposes if something will go wrong.

6. Making archive:
tar cpjf /home/shkodenko/shkodenko.com-backup.tar.bz2 ./

7. Some additional commands for verification with backup file:
$ sha1sum -b /home/shkodenko/shkodenko.com-backup.tar.bz2
$ ls -Alh /home/shkodenko/shkodenko.com-backup.tar.bz2

8. Cleaning garbage:
$ rm -fv ./wp-content/uploads/db_name.sql