Short HOWTO/FAQ for FreeBSD 9 (Tutorial: How to leave paradi

3.6.3. Configuring nVidia Video Card.

To view the complete contents of the HOWTO/FAQ: Back to content.

P.S. Sorry for my bad English.
P.P.S. If you find something of interest, tell me: "thank you man" - I will be pleased. If you think that this is useless, do not scold me - I will be unpleasant. If you know a better solution - I'll be glad to see your adjustments.

Code:
=============================================================================
                            HOWTO FOR FREEBSD 9.x.
=============================================================================
CREATED:
    Author: valsorym
    E-mail: valsorym.e@gmail.com
    
DATE:
    2013.03.23

DESCRIPTION:
    Configuring nVidia Video Card.
=============================================================================
-----------------------------------------------------------------------------
Note.
-----------------------------------------------------------------------------
    You must have installed the ports collection.

-----------------------------------------------------------------------------
Install software.
-----------------------------------------------------------------------------
  I.Install drivers.
    1.  Install drivers from ports collection.
        # setenv BATCH yes
        # kldload linux

        # cd /usr/ports/x11/nvidia-driver
        # make && make install clean

        # cd /usr/ports/x11/nvidia-settings
        # make && make install clean
    
        # cd /usr/ports/x11/nvidia-xconfig
        # make && make install clean
        
    2.  Install drivers from packages.
        # kldload linux
   
        # pkg_add -r nvidia-driver
        # pkg_add -r nvidia-settings
        # pkg_add -r nvidia-xconfig

-----------------------------------------------------------------------------
Additional settings.
-----------------------------------------------------------------------------
  I.Create config files.
    1.  Modified /boot/loader.conf.
        # vi /boot/loader.conf

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
# LINUX
# + Binary compatibility with Linux.
linux_load="YES"

# VIDEO
# + nVidia drivers.
nvidia_load="YES"
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

 II.Run and config it.
    **  First - configure the Xorg.
    # rehash
    # nvidia-xconfig

=============================================================================
                                                             Author: valsorym
 
3.6.4. Configuring Intel Video Card.

To view the complete contents of the HOWTO/FAQ: Back to content.

P.S. Sorry for my bad English.
P.P.S. If you find something of interest, tell me: "thank you man" - I will be pleased. If you think that this is useless, do not scold me - I will be unpleasant. If you know a better solution - I'll be glad to see your adjustments.

Code:
=============================================================================
                            HOWTO FOR FREEBSD 9.x.
=============================================================================
CREATED:
    Author: valsorym
    E-mail: valsorym.e@gmail.com
    
DATE:
    2013.03.23

DESCRIPTION:
    Configuring Intel Video Card.
=============================================================================
-----------------------------------------------------------------------------
Note.
-----------------------------------------------------------------------------
    You must have installed the ports collection.

-----------------------------------------------------------------------------
Install software.
-----------------------------------------------------------------------------
 I.Install drivers from ports collection.
    # setenv BATCH yes
    # cd /usr/ports/x11-drivers/xf86-video-intel
    # make && make install clean

=============================================================================
                                                             Author: valsorym
 
4.1.1. Finding application.

To view the complete contents of the HOWTO/FAQ: Back to content.

P.S. Sorry for my bad English.
P.P.S. If you find something of interest, tell me: "thank you man" - I will be pleased. If you think that this is useless, do not scold me - I will be unpleasant. If you know a better solution - I'll be glad to see your adjustments.

Code:
=============================================================================
                            HOWTO FOR FREEBSD 9.x.
=============================================================================
CREATED:
    Author: valsorym
    E-mail: valsorym.e@gmail.com
    
DATE:
    2013.03.23

DESCRIPTION:
    Finding application.
=============================================================================
-----------------------------------------------------------------------------
Find in Ports Collections.
-----------------------------------------------------------------------------
  I.Use whereis tool.
    For example:
    # whereis opera
    opera: /usr/ports/www/opera

    # whereis nosoftware
    nosoftware:

 II.Default method.
    # cd /usr/ports
    # make search name=opera
    Port:   www/opera
    Moved:
    Date:   2011-10-04
    ...

III.Use psearch tool. Its is good tools for search ports.
    ** First you should be Installed it.
    # pseacrh opera
    ...
    www/opera  Blazingly fast, full-featured, standards-compliant browser.
    ...

-----------------------------------------------------------------------------
Install pseacrh.
-----------------------------------------------------------------------------
  I.Find psearch tool.
    # whereis psearch
    psearch: /usr/ports/ports-mgmt/psearch

 II.Installation.
    # setenv BATCH yes
    # cd /usr/ports/ports-mgmt/psearch
    # make && make install clean
    # rehash

=============================================================================
                                                             Author: valsorym
 
4.1.2. Installation of the packages.

To view the complete contents of the HOWTO/FAQ: Back to content.

P.S. Sorry for my bad English.
P.P.S. If you find something of interest, tell me: "thank you man" - I will be pleased. If you think that this is useless, do not scold me - I will be unpleasant. If you know a better solution - I'll be glad to see your adjustments.

Code:
=============================================================================
                            HOWTO FOR FREEBSD 9.x.
=============================================================================
CREATED:
    Author: valsorym
    E-mail: valsorym.e@gmail.com
    
DATE:
    2013.03.23

DESCRIPTION:
    Installation of the packages.
=============================================================================
-----------------------------------------------------------------------------
Install software.
-----------------------------------------------------------------------------
  I.Use local repository.
    1.  Go to the directory on the local repository.
        **  For example: ~/localrepo/.
        # cd ~/localrepo/

    2. Find the right package.
        **  For example opera_11_4.tar.gz
        # ls | grep ^opera
        opera_11_4.tar.gz

    3. Installing the package.
        # pkg_add opera_11_4.tar.gz
        
    **  In the local repository should be all the necessary dependencies.

 II.Use global repository.
    1.  Choice of place of a global repository. Is responsible for this
        PACKAGESITE global variable.
        A.  For FreeBSD 8.2.
            # setenv PACKAGESITE "http://ftp.freebsd.org/pub/FreeBSD/
                                    ports/i386/packages-8.2-release/All/"
                                    
        B.  For FreeBSD 9.0.
            # setenv PACKAGESITE "ftp://ftp.freebsd.org/pub/FreeBSD/
                                    ports/i386/packages-9-stable/Latest/"

    2.  Install software.
        **  For example install opera and all dependencies.
        # pkg_add -r opera
        
-----------------------------------------------------------------------------
Create a local repository of installed programs.
-----------------------------------------------------------------------------
  I.Create a custom script.
    1.  Create script.
        # mkdir -p ~/localrepo
        # cd ~/localrepo
        # vi create.csh
    
[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
#!/bin/csh

set packages = `pkg_info | cut -d' ' -f1`
set localrepo = "$HOME/localrepo/"
mkdir -p $localrepo
cd $localrepo

foreach package ($packages)
    pkg_create -b $package
end

unset localrepo packages

exit(0)
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    2.  Run script.
        # csh create.csh

=============================================================================
                                                             Author: valsorym
 
4.1.3. Installation of the ports collections.

To view the complete contents of the HOWTO/FAQ: Back to content.

P.S. Sorry for my bad English.
P.P.S. If you find something of interest, tell me: "thank you man" - I will be pleased. If you think that this is useless, do not scold me - I will be unpleasant. If you know a better solution - I'll be glad to see your adjustments.

Code:
=============================================================================
                            HOWTO FOR FREEBSD 9.x.
=============================================================================
CREATED:
    Author: valsorym
    E-mail: valsorym.e@gmail.com
    
DATE:
    2013.03.23

DESCRIPTION:
    Installation of the ports collections.
=============================================================================
-----------------------------------------------------------------------------
Install software.
-----------------------------------------------------------------------------
  I.Find the right port.
    **  For example psearch.
    # whereis psearch
    psearch: /usr/ports/ports-mgmt/psearch

  II.Installation.
    1.  Hands mode.
        **  Will have to answer some questions.
        # cd /usr/ports/ports-mgmt/psearch
        # make && make install clean

    2.  Automatic mode.
        **  All questions will be answered "Yes".
        # setenv BATCH yes
        # cd /usr/ports/ports-mgmt/psearch
        # make && make install clean

=============================================================================
                                                             Author: valsorym
 
4.1.4. Uninstall programs and clean debris.

To view the complete contents of the HOWTO/FAQ: Back to content.

P.S. Sorry for my bad English.
P.P.S. If you find something of interest, tell me: "thank you man" - I will be pleased. If you think that this is useless, do not scold me - I will be unpleasant. If you know a better solution - I'll be glad to see your adjustments.

Code:
=============================================================================
                            HOWTO FOR FREEBSD 9.x.
=============================================================================
CREATED:
    Author: valsorym
    E-mail: valsorym.e@gmail.com
    
DATE:
    2013.03.23

DESCRIPTION:
    Uninstall programs and clean debris.
=============================================================================
-----------------------------------------------------------------------------
Uninstall programs.
-----------------------------------------------------------------------------
  I.Use ports collection.
    **  If you do not used when installing ports: make clean.
    # cd /usr/ports/<CATEGORY>/<PORT>
    # make deinstall

 II.Use pkg_delete.
    **  For example, remove wine software.
    # pkg_info | grep wine
    wine-1.3.32,1    Microsoft Windows  compatibility layer for UNIX sys.
    # pkg_delete wine-1.3.32,1

-----------------------------------------------------------------------------
Remove the dependency.
-----------------------------------------------------------------------------
  I.Use ports-mgmt/pkg-orphan
    **  pkg-orphan is a console utility for managing orphan i.e. unreferenced
        FreeBSD packages. It finds all or selected orphans and lets the user
        choose which ones to remove and which ones to keep. It maintains a 
        keep-list file, so previously kept packages will be skipped 
        automatically. In batch mode, all packages, not present in the keep-
        list are either deleted or kept in the list.

    # pkg-orphan
    Package 1 of 104:
    ImageMagick-6.7.3.4: Image processing tools
    ImageMagick-6.7.3.4: Delete/Kepp/Ignore [I]: 
    ...

 II.Use ports-mgmt/pkg_cutleaves.
    **  pkg_cutleaves finds installed 'leaf' packages, i.e. packages that are
        not referenced  by any other  installed  package, and lets you decide
        for each one if you want to keep or deinstall it (via pkg_deinstall).

    # pkg_cutleaves
    autoconf-2.13.000227_6 - [keep]/(d)elete/(f)lush marked pkgs/(a)bort?
    ...
    
=============================================================================
                                                             Author: valsorym
 
4.2.1. Script automatic software installation (only from port collections).

To view the complete contents of the HOWTO/FAQ: Back to content.

P.S. Sorry for my bad English.
P.P.S. If you find something of interest, tell me: "thank you man" - I will be pleased. If you think that this is useless, do not scold me - I will be unpleasant. If you know a better solution - I'll be glad to see your adjustments.

Code:
=============================================================================
                            HOWTO FOR FREEBSD 9.x.
=============================================================================
CREATED:
    Author: valsorym
    E-mail: valsorym.e@gmail.com
    
DATE:
    2013.03.23

DESCRIPTION:
    Script automatic software installation using ports collections.
=============================================================================
-----------------------------------------------------------------------------
Theory.
-----------------------------------------------------------------------------
    The script is used when you want to install a lot of ports. You create a
    list of installed ports and run script. The script has a log file - in
    case of a break network, the script can be restarted and installed only
    software that has not yet been established.
    
-----------------------------------------------------------------------------
Source code.
-----------------------------------------------------------------------------

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
#!/bin/csh

# Author: valsorym
# Date: 2013.01.20

# DEFINES
# ------------------------------------------------------------------------- #
set TYPE_AUTOMODE = 'automode'
set TYPE_HANDMODE = 'handmode'
set TYPE_STEPBYSTEP = 'step by step'

# OPTIONS
# ------------------------------------------------------------------------- #
# To test script set DEBUG = 1.
set DEBUG = 0

# ON (0)/OFF (1) mode type.
set automode_enable = 1
set handmode_enable = 0
set stepbystep_enable = 1

# Load additional kernel modules.
### kldload cuse4bsd
kldload linux

# AUTOMODE
# ------------------------------------------------------------------------- #
# List port collections (automatic mode and hand mode).
# ** For $automode and $handmode use the "endlist" marker to set the end of
#    the list.

set a_devel = (devel/valgrind devel/geany)
set a_graphics = (graphics/evince graphics/inkscape graphics/epdfview \
graphics/djview4 graphics/gimp)
set a_audio = (audio/gmixer audio/moc)
set a_editors = (editors/vim-lite)
set a_multimedia = (multimedia/xmms multimedia/mplayer)
set a_misc = (misc/mc)
set a_ports_mgmt = (ports-mgmt/psearch ports-mgmt/pkg-orphan)
set a_sysutils = (sysutils/tmux sysutils/dvd+rw-tools sysutils/tree \
sysutils/screen)
set a_security = (security/sudo)
set a_archivers = (archivers/unrar archivers/p7zip)
set a_x11 = (x11/xterm x11/rxvt-unicode x11-wm/xfce4 x11/xev \
x11/xxkb x11/xorg x11-fonts/webfonts \
x11-fonts/terminus-font) ### x11-wm/dwm x11/dmenu x11/gnome-terminal 
set a_www = (www/nginx www/fcgi www/firefox www/firefox-i18n)
set a_java = (java/openjdk7 java/netbeans)

# HANDMODE
# ------------------------------------------------------------------------- #
set h_x11 = (endlist)

# INSTALL LIST
# ------------------------------------------------------------------------- #
set automode = ( \
$a_devel $a_graphics $a_audio $a_editors \
$a_multimedia $a_misc $a_ports_mgmt $a_sysutils $a_security \
$a_archivers $a_x11 $a_java $a_www \
endlist)

set handmode = (\
$h_x11 \
endlist)

# STEP BY STEP
# ------------------------------------------------------------------------- #
# ** Add to the scenario of list-specific commands.

set arr = 1
set scmax = 100
set scenario = ( \
\
# LIBREOFFICE \
'setenv BATCH yes' \
'cd /usr/ports/editors/libreoffice' \
'make LOCALIZED_LANG=ru' \
'make LOCALIZED_LANG=ru install' \
'make clean' \
'cd /usr/ports/russian/libreoffice' \
'make && make install clean' \
\
# NEXT CMD \
'ls' \
endlist)

# ------------------------------------------------------------------------- #

# + Log files.
set logdir = "/tmp/software"
set logfile = "logfile"
set logready = "logready"

# PREPARATION
set logfile="$logdir/$logfile"
set logready = "$logdir/$logready"

# + Create log-construction.
mkdir -p $logdir

if ( $DEBUG == '1' ) then
# Clear logfiles.
    echo '' > $logfile
    echo '' > $logready
endif

if ( -e $logfile ) then
    echo "Logfile: $logfile ... ok."
else
    touch $logfile
    if ( $? == '0' ) then
        echo "Logfile: $logfile ... ok."
    else
        exit(1)
    endif
endif
    
if ( -e $logready ) then
    echo "Logready: $logready ... ok."
else
    touch $logready
    if ( $? == '0' ) then
        echo "Logready: $logready ... ok."
    else
        exit(1)
    endif
endif

# INSTALL
# ------------------------------------------------------------------------- #
# + Automatically.
setenv BATCH yes
set type = "$TYPE_AUTOMODE"
set i = 0

HANDMODE:
foreach port (`echo $automode`)
# ...
    if ( $type == $TYPE_AUTOMODE ) then
        if ( $automode_enable == '0' ) then
            break
        endif
    else if ( $type == $TYPE_HANDMODE ) then
        if ( $handmode_enable == '0' ) then
            break
        endif
    endif

# Check for the port.
    # + User's end of list.
    if ( "$port" == "endlist" ) then
    # End list.
        break
    endif
    
    # + Already installed.
    less $logready | grep ^${port}$
    if ( $? == '0' ) then
        continue
    endif 
    
    # + Port is exist.
    if ( -d "/usr/ports/$port" ) then
        cd "/usr/ports/$port"
    else
        continue
    endif
    
    # Install port and write report to logfile.
    @ i += 1
    set date = `date "+%H:%M:%S %Y.%m.%d"`
    printf "$i.\tPort:\t$port\n\tStart:\t$date\n" >> $logfile
    
    set result = '1'
    if ( $DEBUG == '1' ) then
    # Debug.
        echo "DEBUGGING"
        pwd && ls
        set result = $?
    else
    # Work.    
        ### make LOCALIZED_LANG=ru && make LOCALIZED_LANG=ru install
        make && make install
        set result = $?
    
        make clean
    endif

    echo "Result ($type): $result"

    set date = `date "+%H:%M:%S %Y.%m.%d"`
    printf "\tStop:\t$date\n\tStatus: " >> $logfile
    
    if ( $result == '0' ) then
        printf "INSTALLED" >> $logfile
        echo $port >> $logready
    else
        printf "ERROR" >> $logfile
    endif
        
    printf " ($type)\n\n" >> $logfile
    rehash
end

# + Hand mode.
if ( $type != $TYPE_HANDMODE ) then
    setenv BATCH no
    set type = "$TYPE_HANDMODE"
    set automode = `echo $handmode`
    goto HANDMODE
endif

# + Step by step.
if ( $stepbystep_enable == '1' ) then
# Step by step run.
    set type = "$TYPE_STEPBYSTEP"
 
    while ( $arr < $scmax )
    # Run all cmd.
        set cmd = "$scenario[$arr]"

        if ( "$cmd" == "endlist" ) then
        # End list.
            break
        endif 

    # Run current cmd.
        @ i += 1
        set date = `date "+%H:%M:%S %Y.%m.%d"`
        printf "$i.\tCmd:\t$cmd\n\tStart:\t$date\n" >> $logfile

        set result = '1'
        if ( $DEBUG == '1' ) then
        # Debug.
            echo "DEBUGGING"
            echo "$cmd"
            set result = $?
        else
        # Work.
            eval "$cmd"
            set result = $?
        endif
    
        echo "Result ($type): $result"
        set date = `date "+%H:%M:%S %Y.%m.%d"`
        printf "\tStop:\t$date\n\tStatus: " >> $logfile
    
        if ( $result == '0' ) then
            printf "GOOD" >> $logfile
            echo $port >> $logready
        else
            printf "ERROR" >> $logfile
        endif
        
        printf " ($type)\n\n" >> $logfile

    # Next cmd.
        @ arr = $arr + 1
        unset cmd result date
    end

endif # end if ($stepbystep_enable)

# END
# ------------------------------------------------------------------------- #

less $logfile
if ( $DEBUG == '1' ) then
# Clear logfiles.
    echo '' > $logfile
    echo '' > $logready
endif

printf "\nDone!\n"

exit(0)

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

-----------------------------------------------------------------------------
View results.
-----------------------------------------------------------------------------
  I.Installed Software.
    # less /tmp/software/logfile
    1.      Port:   audio/moc
            Start:  14:15:40 2012.09.20
            Stop:   14:32:53 2012.09.20
            Status: INSTALLED (automatically)
    
    2.      Port:   misc/mc
            Start:  14:32:53 2012.09.20
            Stop:   14:54:35 2012.09.20
            Status: INSTALLED (automatically)
    
    3.      Port:   ports-mgmt/psearch
            Start:  14:54:35 2012.09.20
            Stop:   14:54:39 2012.09.20
            Status: INSTALLED (automatically)
    
    ...

=============================================================================
                                                             Author: valsorym
 
4.3.1. Databases MySQL55.

To view the complete contents of the HOWTO/FAQ: Back to content.
See also the short FAQ on MySQL here.

P.S. Sorry for my bad English.
P.P.S. If you find something of interest, tell me: "thank you man" - I will be pleased. If you think that this is useless, do not scold me - I will be unpleasant. If you know a better solution - I'll be glad to see your adjustments.

Code:
=============================================================================
                            HOWTO FOR FREEBSD 9.x.
=============================================================================
CREATED:
    Author: valsorym
    E-mail: valsorym.e@gmail.com
    
DATE:
    2013.03.23

DESCRIPTION:
    Database MySQL 55.
=============================================================================
-----------------------------------------------------------------------------
Settings.
-----------------------------------------------------------------------------
  I.Configure system files.
    1.  Configure /etc/make.conf.
        # vi /etc/make.conf

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
# MAIN
# + Ports.
PORTSDIR?=/usr/ports

# MySQL
DEFAULT_MYSQL_VER=55

# + Server.
.if ${.CURDIR} == ${PORTSDIR}/databases/mysql55-server
# BUILD_OPTIMIZED=yes
# BUILD_STATIC=yes
# WITHOUT_INNODB=yes

WITH_ARCHIVE=yes
WITH_CHARSET=utf8
WITH_COLLATION=utf8_unicode_ci
WITH_LINUXTHREADS=yes
.endif

# + Client.
.if ${.CURDIR} == ${PORTSDIR}/databases/mysql55-client
# BUILD_STATIC=yes

BUILD_OPTIMIZED=yes
WITH_CHARSET=utf8
WITH_COLLATION=utf8_unicode_ci
.endif
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    2.  Configure /etc/rc.conf.
        # vi /etc/rc.conf

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
# LINUX
# + Binary compatibility with Linux.
linux_enable="YES"
 
# DATABASES
# + MySQL settings.
mysql_enable="YES"
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

-----------------------------------------------------------------------------
Installation.
-----------------------------------------------------------------------------
  I.Installation MySQL 55.
    A.  From ports collections.
        # cd /usr/ports/databases/mysql55-server
        # make && make install clean

    B.  From packages.
        # pkg_add -r mysql55-server
        
 II.Creating a configuration file.
    **  MySQL has four simple configuration files that located in the
        /usr/local/share/mysql/ directory:
        1) my-small.cnf  - for systems with up to 64 Mb of RAM.
        2) my-medium.cnf - for systems with up to 128 Mb of RAM.
        3) my-large.cnf  - for systems with 512 Mb of RAM.
        4) my-huge.cnf   - for systems with 1/2 Gb of RAM.

    # mkdir -p /var/db/mysql/
    # cp /usr/local/share/mysql/my-small.cnf /var/db/mysql/my.cnf

    **  Add UTF-8 support:
        Modify the blocks [client], [mysqld] and [mysql], see the comments 
        in the text.
        # vi /etc/my.cnf

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
# ** Add to the end of the [client] block.
[client]
# ... 
default-character-set = utf8

# ** Add to the end of the [mysqld] block.
[mysqld]
# ...
init-connect="SET NAMES utf8"
collation-server = utf8_unicode_ci
character-set-server = utf8
skip-character-set-client-handshake

# ** Add to the end of the [mysql] block.
[mysql]
# ...
default-character-set = utf8
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

**  In the file my.cnf, in case the assembly is installed without using
    innodb and launch is accompanied by message "[ERROR] Default storage
    engine (InnoDB) is not available", comment out [> skip-innodb <] and
    instead specify [> default-storage-engine = MyISAM5 <].

III.Installing database.
    # cd /usr/local; mysql_install_db
    # chown -R mysql:mysql /var/db/mysql
    # /usr/local/etc/rc.d/mysql-server start

 IV.Create MySQL root password.
    # mysqladmin -u root password 'mysqlpass'
    # mysql -uroot -pmysqlpass mysql

  V.Remove others localhost users.
    > delete from user where not (user='root' and host='localhost');
    > select user, host from user;

    +------+-----------+
    | user | host      |
    +------+-----------+
    | root | localhost |
    +------+-----------+

    **  Ok, everything is ready, you can use the MySQL.
-----------------------------------------------------------------------------
Short HOWTO on MySQL 
-----------------------------------------------------------------------------
*****************************************************************************
    Create first root password for MySQL.
*****************************************************************************
    A.  Syntax:
        # mysqladmin -u [USER] password '[PASSWORD]'

    B.  For example:
        - User: root
        - Password: mysqlpass
        # mysqladmin -u root password 'mysqlpass'

*****************************************************************************
    MySQL database management.
*****************************************************************************
    A.  Syntax:
        **  Without separators between -u and -p flags.
        # mysql -u[USER] -p[PASSWORD] mysql
    
        or:
        # mysql -u [USER] -p
        Enter password: [PASSWORD]

    B.  For example:
        - User: root
        - Password: mysqlpass
        # mysql -uroot -pmysqlpass mysql

*****************************************************************************
    Change the root password.
*****************************************************************************
    A.  Login into mysql use old root password:
        # mysql -u root -p

    B.  Create a MySQL query:
        > set password for 'root'@'localhost' = password('[NEWPASSWORD]');

*****************************************************************************
    Create new database.
*****************************************************************************
    A.  Syntax:
        > create database [DATABASE] charset=utf8;

    B.  For example:
        - Database:  mysite_db
        - Coding:    utf-8

        > create database mysite_db charset=utf8;

*****************************************************************************
    Create new user and setting permissions.
*****************************************************************************
    A.  Syntax:
        > grant all privileges on [DATABASE].* to '[USER]'@'[HOSTNAME]'
        -> identified by '[PASSWORD]' with grant option;

    B.  For example:
        - Database: mysql_db
        - New user: mysite_db_user
        - Password: mysite_db_password
        - Hostname: localhost
 
        > grant all privileges on mysite_db.* to 'mysite_db_user'@'localhost' 
        -> identified by 'mysite_db_password' with grant option;

        **  Access to the database for a given user is only possible with
            the localhost. If you want to give him access to the database
            from any host, use [ % ] instead of [ localhost ]:
            - Database: mysql_db
            - New user: mysite_db_user
            - Password: mysite_db_password
            - Hostname: localhost
 
            > grant all privileges on mysite_db.* to 'mysite_db_user'@'%' 
            -> identified by 'mysite_db_password' with grant option;

*****************************************************************************
    Checking the text encoding.
*****************************************************************************
    A.  Checking the text encoding (should be utf-8).
        > show variables like 'coll%';
        +----------------------+-------------------+
        | Variable_name        | Value             |
        +----------------------+-------------------+
        | collation_connection | utf8_general_ci   |
        | collation_database   | latin1_swedish_ci |
        | collation_server     | latin1_swedish_ci |
        +----------------------+-------------------+
                
        > show variables like 'char%';
        +--------------------------+----------------------------------+
        | Variable_name            | Value                            |
        +--------------------------+----------------------------------+
        | character_set_client     | utf8                             |
        | character_set_connection | utf8                             |
        | character_set_database   | latin1                           |
        | character_set_filesystem | binary                           |
        | character_set_results    | utf8                             |
        | character_set_server     | latin1                           |
        | character_set_system     | utf8                             |
        | character_sets_dir       | /usr/local/share/mysql/charsets/ |
        +--------------------------+----------------------------------+

=============================================================================
                                                             Author: valsorym
 
4.3.2. Devel Ruby-Gems.

To view the complete contents of the HOWTO/FAQ: Back to content.

P.S. Sorry for my bad English.
P.P.S. If you find something of interest, tell me: "thank you man" - I will be pleased. If you think that this is useless, do not scold me - I will be unpleasant. If you know a better solution - I'll be glad to see your adjustments.

Code:
=============================================================================
                            HOWTO FOR FREEBSD 9.x.
=============================================================================
CREATED:
    Author: valsorym
    E-mail: valsorym.e@gmail.com
    
DATE:
    2013.03.23

DESCRIPTION:
    Devel Ruby-Gems.
=============================================================================
-----------------------------------------------------------------------------
Settings.
-----------------------------------------------------------------------------
  I.Configure config files.
    In /etc/make.conf add:
    # vi /etc/make.conf

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
RUBY_VERSION=1.9.3
RUBY_DEFAULT_VER=1.9
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

-----------------------------------------------------------------------------
Installation.
-----------------------------------------------------------------------------
  I.Installation Ruby 1.9.3.
    A.  From ports collections.
        # /usr/ports/devel/ruby-gems
        # make && make install clean

    B.  From packages.
        # pkg_add -r ruby-gems

 II.To work correctly, install additional ports.
    **  In most cases, devel/libehetsinfo already installed.
    # setenv BATCH yes 
    # cd /usr/ports/devel/libexecinfo
    # make && make install clean

    # cd cd /usr/ports/www/node
    # make && make install clean
        
-----------------------------------------------------------------------------
Installing Ruby packages.
-----------------------------------------------------------------------------
**  Use the gem utility.
  I.For example, installation rails framework.
    # gem install rails

    **  Verify the installation:
        # rehash
        # rails -v
          Rails 3.2.11

    **  Gem short help:
        # gem list - Show list installed gem-packages.
        # gem update - Updtae all gem-packages.
        # gem update --system - Update gem-system.
        # gem update <GEM_PKG_NAME> - Update gem-package, for exmaple:
            > gem update rails - Update rails framework.
        # gem uninstall <GEM_PKG_NAME> - Uninstall gem-package.
        # gem enviroment - Show config RubyGems.

=============================================================================
                                                             Author: valsorym
 
4.3.3. Dynamic DNS.

To view the complete contents of the HOWTO/FAQ: Back to content.

P.S. Sorry for my bad English.
P.P.S. If you find something of interest, tell me: "thank you man" - I will be pleased. If you think that this is useless, do not scold me - I will be unpleasant. If you know a better solution - I'll be glad to see your adjustments.

Code:
=============================================================================
                            HOWTO FOR FREEBSD 9.x.
=============================================================================
CREATED:
    Author: valsorym
    E-mail: valsorym.e@gmail.com
    
DATE:
    2013.03.23

DESCRIPTION:
    Dynamic DNS.
=============================================================================
-----------------------------------------------------------------------------
Register a domain name.
-----------------------------------------------------------------------------
  I.Register here.
    URL: http://www.no-ip.com/services/managed_dns/free_dynamic_dns.html
    **  To activate your account please click on the activation URL in your
        e-mail.
    
 II.Add new domain name.
    1.  Login in no-ip system.
        URL: http://www.no-ip.com/login/
        
    2.  Go to admin menu.
        URL:https://www.no-ip.com/members/
        
        Clik to "Add a Host" menu.
        URL: https://www.no-ip.com/members/dns/host.php
        
    3.  Add new domain.
        For WWW:
            - Host Type: DNS Host (A).
        
-----------------------------------------------------------------------------
FreeBSD settings.
-----------------------------------------------------------------------------
  I.Install special software.
    # cd /usr/ports/dns/noip
    # make && make install clean
    
 II.Create config file.
    **  Choosing the right interface.
    **  Enter the authorization data (E-mail/Password) with NO-IP service.
    # /usr/local/bin/noip2 -C
    
    ...
    New configuration file '/usr/local/etc/no-ip2.conf' created.

III.Set the owner to the configuration file:
    # chown noip:noip /usr/local/etc/no-ip2.conf
    
 IV.Modified /etc/rc.conf, add:
    # vi /etc/rc.conf

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
# NETWORK
# + NO-IP.
noip_enable="YES"
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
    
  V.Run service.
    # /usr/local/etc/rc.d/noip start

    **  To check, go to the domain name that you created.
	
-----------------------------------------------------------------------------
Global SSH access.
-----------------------------------------------------------------------------
	** If your computer has a dynamic IP address, and you need access to it
       through SSH: configure SHH demon (HOWTO: "Setting up SSH access");
       registration in NO-IP service (HOWTO: "Dynamic DNS").

  I.Modified your no-ip domain.
    Host Type: DNS Host (A).

 II.Configure NAT (Network Address Translation) on your router.
    +--------------+------------+--------------+------------+----------+
    | Service Name | Port Range |    Local IP  | Local port | Protocol |
    +--------------+------------+--------------+------------+----------+
    | SSH Server   |       2222 | 192.168.x.xx |         22 |    TCP   |
    +--------------+------------+--------------+------------+----------+

    **  IP 192.168.x.xx - IP your local web server.
    **  If your router use DHCP - assign the IP address use MAC address.
    **  Check your SSH access, use 2222 port to access.
    
=============================================================================
                                                             Author: valsorym
 
4.3.4. Editor Vim.

To view the complete contents of the HOWTO/FAQ: Back to content.

P.S. Sorry for my bad English.
P.P.S. If you find something of interest, tell me: "thank you man" - I will be pleased. If you think that this is useless, do not scold me - I will be unpleasant. If you know a better solution - I'll be glad to see your adjustments.

Code:
=============================================================================
                            HOWTO FOR FREEBSD 9.x.
=============================================================================
CREATED:
    Author: valsorym
    E-mail: valsorym.e@gmail.com
    
DATE:
    2013.03.23

DESCRIPTION:
    Vim editor.
=============================================================================
-----------------------------------------------------------------------------
Installation.
-----------------------------------------------------------------------------
  I.Installation Apache22.
    A.  From ports collections.
        # cd /usr/ports/editors/vim-lite
        # make && make install clean
        
    B.  From packages.
        # pkg_add -r vim-lite

-----------------------------------------------------------------------------
Settings.
-----------------------------------------------------------------------------
  I.Configure .vimrc
    **  Please go to the website www.vim.org and install these plugins:
        - NERD_tree

    # cd ~/
    # vi .vimrc

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
" VIM CONFIGURATIONS
" Author: valsorym
" Date: 2012-12-12

" OPTIONS
" ****************************************************************************
 
""" Including support for Russian language.
set keymap=russian-jcukenwin
set iminsert=0
set imsearch=0
highlight lCursor guifg=NONE guibg=Cyan

set tabpagemax=40     " Maximum open tabs using: vim -p f1 f2 .. f40
set showtabline=2     " Show tab panel.

""" Options.
set bs=2              " Full use of the backspace.
set tw=78             " String length.
""" set ai                " To include auto-indent for new lines.
""" set cin               " Include C-style indentation.
""" set autoindent        " Set auto-indent.
set tabstop=4         " Magnitude of the indentation for Tab.
set softtabstop=4     " Magnitude of the indentation for Space.
set shiftwidth=4      " The number of spaces used in the indentation
                      " ... commands, such as >> or <<;
set smarttab
set expandtab         " Insert spaces instead of Tab.
                      " To insert a tab character if  expandtab is enabled:
                      " ... 1. In edit mode: Ctrl+v, Ctrl+i
                      " ... 2. Off expandtab: set noexpandtab
set nocompatible      " Turn arrows in the mode of INSERT.
colorscheme slate     " Change the color scheme
                      " ... /usr/local/share/vim/vim73/colors/
syntax on             " Include syntax highlighting.
set background=dark   " Into thinking that the VIM background is black.
set ignorecase        " Ignore upper/lower case when searching.
set smartcase
""" set backup            " Create .bak files (default <oldname> ~).
set showmatch         " Check the brackets.
set sidescroll=5      " Scrolling (Left/Right in nowrap).
set listchars+=precedes:<,extends:> " display ">" or "<" scrolling nowrap.
set sidescrolloff=5
set guifont=terminus

set nowrap            " Do not break the line.
""" set warp              " Transfer of long lines.
""" set linebreak         " Transfer word to rather 
""" set dy=lastline       " ... than symbols.

set nu                " Line number.
set showcmd           " Show cmd in statusbar.
set wildmenu          " List menu.

set backup            " Backup.
set backupdir=/tmp    " Backup dir.

""" UTF8 and type ending of line.
set termencoding=utf-8
set fileencodings=usc-bom,utf-8mdefault,cp1251
set ffs=unix,dos,mac

""" Information about open file.
set wildmenu          " Commands autocomplete.
set laststatus=2      " Value 2 - always show the status of the status bar.
set statusline=%<%f\%{(&modified)?'\*\ ':''}%*%=C:%c%V,R:%l\ %P

" MAPPING
" ***************************************************************************

" FILES
" Open file.
imap <C-o> <Esc>:e<Space>
nmap <C-o> :e<Space>

" Save current tab.
imap <F2> <Esc>:w!<CR>
nmap <F2> :w!<CR>

" TABS
" Tab list.
imap <C-t> <Esc>:tabs<CR>
nmap <C-t> :tabs<CR>

" Move tab in N position.
imap <F3> <Esc>:tabm<Space>
nmap <F3> :tabm<Space>

" Go to N tab.
imap <F4> <Esc>:tabn<Space>
nmap <F4> :tabn<Space>

" Prev tab.
imap <F5> <Esc>:tabprev<CR>
nmap <F5> :tabprev<CR>

""" imap <C-h> <Esc>:tabprev<CR>
""" nmap <C-h> :tabprev<CR>

" Next tab.
imap <F6> <Esc>:tabnext<CR>
nmap <F6> :tabnext<CR>

""" imap <C-l> <Esc>:tabnext<CR>
""" nmap <C-l> :tabnext<CR>

" Create tab.
imap <F7> <Esc>:tabnew<CR>
nmap <F7> :tabnew<CR>

imap <C-n> <Esc>:tabnew<CR>
nmap <C-n> :tabnew<CR>

" Close current tab without save.
imap <F10> <Esc>:q!<CR>
nmap <F10> :q!<CR>

" Save and close current tab.
imap <F11> <Esc>:wq!<CR>
nmap <F11> :wq!<CR>

" EDITOR
" On / Off display of line numbers.
imap <F12> <Esc>:set<Space>nu!<CR>a
nmap <F12> :set<Space>nu!<CR>

" Encoding menu.
set wildmenu
set wcm=<Tab>
menu Encoding.koi8-r :e ++enc=koi8-r ++ff=unix<CR>
menu Encoding.windows-1251 :e ++enc=cp1251 ++ff=dos<CR>
menu Encoding.cp866 :e ++enc=cp866 ++ff=dos<CR>
menu Encoding.utf-8 :e ++enc=utf8 <CR>
menu Encoding.koi8-u :e ++enc=koi8-u ++ff=unix<CR>
map <F8> :emenu Encoding.<TAB>


" PLUGINS
" ***************************************************************************

" NERDTree.
" * HELP:
" * Use F9 for open NERDTree.
" *
" * Download NERDTree:
" * http://www.vim.org/scripts/script.php?script_id=1658
" * 
" * Unzip NERDTree archive to ~/.vim/.
" * 
" * To work with windows, use:
" * Ctrl+w, arrows - move the window to the left/right/up/down.
" * Ctrl+w, o - expand the window.
" * Ctrl+w, c - close the window.
" * Ctrl+w, s - window horizontally split.
" * Ctrl+w, v - window vertically split.
nmap <silent> <F9> :NERDTreeToggle<CR>

" FINE-TUNING
" ****************************************************************************

""" TAB'S NAMES {BEGIN}
function TabLabel(n)
    let label = ''
    let buflist = tabpagebuflist(a:n)
    let label = substitute(bufname(buflist[tabpagewinnr(a:n) - 1]), '.*/', '', '')

    if label == ''
        let label = '[No Name]'
    endif

    let label = ' ' . a:n . '. ' . label

    for i in range(len(buflist))
        if getbufvar(buflist[i], "&modified")
            let label = label . '*'
             break
        endif
    endfor

    return label
endfunction " end TabLabel().

function TabName()
    let str = ''

    for i in range(tabpagenr('$'))
        if i + 1 == tabpagenr()
            let str .= '%#TabLineSel#'
        else
            let str .= '%#TabLine#'
        endif

        let str .= '%' . (i + 1) . 'T'
        let str .= ' %{TabLabel(' . (i + 1) . ')} |'
    endfor

    let str .= '%#TabLineFill#%T'

    if tabpagenr('$') > 1
        let str .= '%=%#TabLine#%999XX'
    endif

    return str
endfunction " end TabName().

set tabline=%!TabName()

""" TAB'S NAMES {END}

""" TAB MOVE {BEGIN}
function MoveTabLeft()
    let current_tab = tabpagenr()
    if current_tab > 1
        let current_tab = current_tab - 2
        execute 'tabmove' current_tab
    endif
endfunction " end MoveTabLeft().

function MoveTabRight()
    let current_tab = tabpagenr()
    execute 'tabmove' current_tab
endfunction " end MoveTabRight().

imap <C-j> <Esc>:call MoveTabLeft()<CR>
nmap <C-j> :call MoveTabLeft()<CR>

imap <C-k> <Esc>:call MoveTabRight()<CR>
nmap <C-k> :call MoveTabRight()<CR>

""" TAB MOVE {END}

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

=============================================================================
                                                             Author: valsorym
 
4.3.5. Lang Python27 and Django.

To view the complete contents of the HOWTO/FAQ: Back to content.

P.S. Sorry for my bad English.
P.P.S. If you find something of interest, tell me: "thank you man" - I will be pleased. If you think that this is useless, do not scold me - I will be unpleasant. If you know a better solution - I'll be glad to see your adjustments.

Code:
=============================================================================
                            HOWTO FOR FREEBSD 9.x.
=============================================================================
CREATED:
    Author: valsorym
    E-mail: valsorym.e@gmail.com
    
DATE:
    2013.03.23

DESCRIPTION:
    Lang Python27 and Django14.
=============================================================================
-----------------------------------------------------------------------------
Python installation.
-----------------------------------------------------------------------------
  I.Installation Python 2.7.
    A.  From ports collections.
        # /usr/ports/lang/python27
        # make && make install clean

    B.  From packages.
        # pkg_add -r python27

-----------------------------------------------------------------------------
Django installation.
-----------------------------------------------------------------------------

  I.Installation Django 1.4.5.
    A.  Hand mode.
        1.  Create a special dir for the temporary deployment of Django.
            # mkdir -p /tmp/Django/
            # cd /tmp/Django/

        2.  Download Django.
            # fetch https://www.djangoproject.com/download/1.4.5/tarball/

        3.  Install Django.
            # mv fetch.out Django-1.4.5.tar.gz
            # tar xzvf Django-1.4.5.tar.gz
            # cd Django-1.4.5
            # python setup.py install

    B.  From ports collections.
        # cd /usr/ports/www/py-django14
        # make && make install

 II.Django installation verification.
    # python
      Python 2.7.3 (default, Jan 16 2013, 01:29:45)
      [GCC 4.2.1 20070831 patched [FreeBSD]] on freebsd9
      Type "help", "copyright", "credits" or "license" for more information.
      >>> import django
      >>> django.VERSION
      (1, 4, 5, 'final', 0)

    **  If you see this - then all ok.
    **  Use Ctrl+Z to exit the Python interactive interpreter.

III.Installation MySQL for Django.
    **  Also, you can install: databases/py-psycopg2, databases/py-postgresql
    A.  From ports collections.
        # cd /usr/ports/databases/py-MySQLdb55
        # make && make install clean

    B.  Hand mode.
        **  This method is not very good.
        1.  Download MySQL library.
            # fetch -o MySQL-python-1.2.4b4.tar.gz \
            http://sourceforge.net/projects/mysql-python/files/latest/download
    
        2.  Unpack MySQL-python-1.2.4b4.tar.gz and install it.
            # cd MySQL-python-1.2.4b4
            # python setup.py install

-----------------------------------------------------------------------------
Running a simple example.
-----------------------------------------------------------------------------
  I.Create Django project directory.
    **  I have a special section (/heap) and its structure of directories.
        You can use any other directory to hold Django projects.
    **  Do not use the directory /var/www to store Django projects - it's
        a bad idea.
    # mkdir -p /heap/warehouse/valsorym/development/projects/webworld/
    # cd /heap/warehouse/valsorym/development/projects/webworld
    # django-admin.py startproject example

    # tree example/
    example/
    |__ example/
    |   |__ __init__.py
    |   |__ settings.py
    |   |__ urls.py
    |   |__ wsgi.py
    |__ manage.py

    # cd example/
    # python manage.py runserver
    
    **  Open your browser: http://127.0.0.1:8000/
        You will see:
        
        It worked!
        Congratulations on your first Django-powered page.
    
        ...

    **  If you want to start the server using a different port or address:
        # python manage.py runserver 8000
        or
        # python manage.py runserver 0.0.0.0:8000

=============================================================================
                                                             Author: valsorym
 
4.3.6. Sysutils Tmux.

To view the complete contents of the HOWTO/FAQ: Back to content.

P.S. Sorry for my bad English.
P.P.S. If you find something of interest, tell me: "thank you man" - I will be pleased. If you think that this is useless, do not scold me - I will be unpleasant. If you know a better solution - I'll be glad to see your adjustments.

Code:
=============================================================================
                            HOWTO FOR FREEBSD 9.x.
=============================================================================
CREATED:
    Author: valsorym
    E-mail: valsorym.e@gmail.com
    
DATE:
    2013.03.23

DESCRIPTION:
    Terminal multiplexer.
=============================================================================
-----------------------------------------------------------------------------
Note.
-----------------------------------------------------------------------------
    Tmux is a terminal multiplexer: it enables a number of terminals, each
    running a separate program, to be created, accessed, and controlled from
    a single screen. Tmux may be detached from a screen and continue running
    in the background, then later reattached.

-----------------------------------------------------------------------------
Configurate.
-----------------------------------------------------------------------------
  I.Change ~/.tmux.conf
    1.  Rewrite .tmux.conf
        # vi ~/.tmux.conf

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
# Move around panes with hjkl, as one would in vim after pressing ctrl-w.
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R

# Resize panes like vim.
# Feel free to change the "1" to however many lines you want to resize by,
# only one at a time can be slow.
bind < resize-pane -L 10
bind > resize-pane -R 10
bind - resize-pane -D 10
bind + resize-pane -U 10

bind-key R respawn-window
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

=============================================================================
                                                             Author: valsorym
 
4.3.7. Web Server Apache22.

To view the complete contents of the HOWTO/FAQ: Back to content.

P.S. Sorry for my bad English.
P.P.S. If you find something of interest, tell me: "thank you man" - I will be pleased. If you think that this is useless, do not scold me - I will be unpleasant. If you know a better solution - I'll be glad to see your adjustments.

Code:
=============================================================================
                            HOWTO FOR FREEBSD 9.x.
=============================================================================
CREATED:
    Author: valsorym
    E-mail: valsorym.e@gmail.com
    
DATE:
    2013.03.23

DESCRIPTION:
    Web Server Apache22.
=============================================================================
-----------------------------------------------------------------------------
Installation.
-----------------------------------------------------------------------------
  I.Installation Apache22.
    A.  From ports collections.
        # cd /usr/ports/www/apache22
        # make && make install clean
        
    B.  From packages.
        # pkg_add -r apache22
        
-----------------------------------------------------------------------------
Settings.
-----------------------------------------------------------------------------
  I.Configure config files.
    1.  Add to /etc/rc.conf.
        # vi /etc/rc.conf

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
# WEB-SERVER
# + Apache22.
apache22_enable="YES"
apache22_http_accept_enable="YES"
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    2.  Open the /usr/local/etc/apache22/httpd.conf and comment
        unique_id_modules.so.
        # vi /usr/local/etc/apache22/httpd.conf
        
[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
...
LoadModule usertrack_module libexec/apache22/usertrack_module.so
# LoadModule unique_id_module libexec/apache22/unique_id_module.so
LoadModule setenvif_module libexec/apache22/setenvif_module.so
...
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

-----------------------------------------------------------------------------
Start.
-----------------------------------------------------------------------------
  I.Start Apache22.
    1.  Run Web Server.
        # /usr/local/etc/rc.d/apache22 start
        
    2.  Check result.
        # lynx 127.0.0.1

        **  You can see: It works!
        **  Local project here: /usr/local/www/nginx/
=============================================================================
                                                             Author: valsorym
 
4.3.8. Web Server Nginx.

To view the complete contents of the HOWTO/FAQ: Back to content.

P.S. Sorry for my bad English.
P.P.S. If you find something of interest, tell me: "thank you man" - I will be pleased. If you think that this is useless, do not scold me - I will be unpleasant. If you know a better solution - I'll be glad to see your adjustments.

Code:
=============================================================================
                            HOWTO FOR FREEBSD 9.x.
=============================================================================
CREATED:
    Author: valsorym
    E-mail: valsorym.e@gmail.com
    
DATE:
    2013.03.23

DESCRIPTION:
    Web Server Nginx.
=============================================================================
-----------------------------------------------------------------------------
Installation.
-----------------------------------------------------------------------------
  I.Installation Nginx.
    A.  From ports collections.
        # /usr/ports/www/nginx
        # make && make install clean
        
    B.  From packages.
        # pkg_add -r nginx
        
-----------------------------------------------------------------------------
Settings.
-----------------------------------------------------------------------------
  I.Configure config files.
    In /etc/rc.conf add:
    # vi /etc/rc.conf

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
# WEB_SERVER
# + Ngnix.
nginx_enable="YES"
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

-----------------------------------------------------------------------------
Start.
-----------------------------------------------------------------------------
  I.Start Ngnix.
    1.  Run Web Server.
        # /usr/local/etc/rc.d/nginx start
        
    2.  Check result.
        # lynx 127.0.0.1

        **  You can see: Welcome to ngnix.

-----------------------------------------------------------------------------
FastCGI interface and FCGI Program on C language.
-----------------------------------------------------------------------------
  I.Install FastCGI Devel Kit.
    A.  From ports collections.
        # cd /usr/ports/www/fcgi
        # make && make install clean
        
    B.  From packages.
        # pkg_add -r fcgi
        
 II.Install spawn-fcgi tool.
    A.  From ports collections.
        # cd /usr/ports/www/spawn-fcgi
        # make && make install clean
        
    B.  From packages.
        # pkg_add -r spawn-fcgi
        
III.Create virtual host.
    1.  For example, host name: site-a.vals - add to /etc/hosts
        # vi /etc/hosts
        
[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
...
127.0.0.1       site-a.vals
...
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
   
    2.  Configure nginx.
        # cd /usr/local/etc/nginx/
        # vi nginx.conf

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
    server {
        listen          80;
        server_name     site-a.vals;
        access_log      /var/log/nginx/site-a.vals.access.log;

        location / {
            root            /usr/local/www/site-a.vals/www;
            index           index.htm index.html;
            include         fastcgi_params;
            fastcgi_pass    127.0.0.1:9000;
        }
    }
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    3.  Reload configuration.
        # mkdir -p /var/log/nginx/
        # mkdir -p /usr/local/www/site-a.vals/www
        # /usr/local/etc/rc.d/nginx restart
        
    4.  Create FCGI program.
        # cd /usr/local/www/site-a.vals/www
        # vi index.c
        
[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
/* cc -O2 -o index.fcgi index.c -L/usr/local/lib -lfcgi */
#include </usr/local/include/fcgi_stdio.h>
#include <stdlib.h>

int
main(int argc, char **argv)
{
/* Initialization. */
    int count = 0;

/* Response loop. */
    while (FCGI_Accept() >= 0) {
        printf("Content-type: text/html\r\n"
                "\r\n"
                "<title>FastCGI A! (C, fcgi_stdio library)</title>"
                "<h1>FastCGI Hello! (C, fcgi_stdio library)</h1>"
                "Request number %d running on host <i>%s</i>\n",
                ++count, getenv("DOCUMENT_URI"));
    }

    return 0;
}
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
    
    5.  Run FCGI program.
        # cc -O2 -o index.fcgi index.c -L/usr/local/lib -lfcgi
        # spawn-fcgi -a 127.0.0.1 -p 9000 ./index.fcgi
        spawn-fcgi: child spawned successfully: PID: 4477
        
        Check result.
        # lynx site-a.vals

-----------------------------------------------------------------------------
Local Server in Global World.
-----------------------------------------------------------------------------
    **  In here we use NO-IP service.
    **  See "Dynamic DNS" HOWTO.

  I.Create no-ip domain name.
    Host Type: DNS Host (A).
    
 II.Modified nginx config file.
    We will be listen 777 port.
    # vi  vim /usr/local/etc/nginx/nginx.conf

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
    server {
        listen          777;
        server_name     site-a.vals;
        access_log      /var/log/nginx/site-a.vals.access.log;
        
        ...
    }
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

III.Configure NAT (Network Address Translation) on your router.
    +--------------+------------+--------------+------------+----------+
    | Service Name | Port Range |    Local IP  | Local port | Protocol |
    +--------------+------------+--------------+------------+----------+
    | HTTP Server  |         80 | 192.168.x.xx |        777 |    TCP   |
    +--------------+------------+--------------+------------+----------+

    **  IP 192.168.x.xx - IP your local web server.
    **  If your router use DHCP - assign the IP address use MAC address.

  V.Restart nginx.
    # /usr/local/etc/rc.d/nginx restart
    
    **  Check your website.

=============================================================================
                                                             Author: valsorym
 
4.3.9. X11 Dwm (Ptr 1).

To view the complete contents of the HOWTO/FAQ: Back to content.
Go to 4.3.9. X11 Dwm (Ptr 2).

P.S. Sorry for my bad English.
P.P.S. If you find something of interest, tell me: "thank you man" - I will be pleased. If you think that this is useless, do not scold me - I will be unpleasant. If you know a better solution - I'll be glad to see your adjustments.

Code:
=============================================================================
                            HOWTO FOR FREEBSD 9.x.
=============================================================================
CREATED:
    Author: valsorym
    E-mail: valsorym.e@gmail.com
    
DATE:
    2013.03.23

DESCRIPTION:
    DWM Window manager.
=============================================================================
-----------------------------------------------------------------------------
Note.
-----------------------------------------------------------------------------
    Dwm is a dynamic window manager. It manages windows in tiled, monocle and
    floating layouts. All of the layouts can be applied dynamically,
    optimising the environment for the application in use and the task
    performed.

-----------------------------------------------------------------------------
Installing from ports collections.
-----------------------------------------------------------------------------
  I.Installing DWM.
    # cd /usr/ports/x11-wm/dwm
    # make && make install 

    **  Do not use goal "clean" in make, etc - make clean. After installing
        we need ./work/dwm-x.n/ directory.

 II.Installation of additional software.
    1.  Program to identify the key code.
        # cd /usr/ports/x11/xev
        # make && make install clean
        
-----------------------------------------------------------------------------
Configure and recompile DWM.
-----------------------------------------------------------------------------
  I.Go to the working directory.
    # cd /usr/ports/x11-wm/dwm/work/dwm-6.0/

    **  In my case, I use DWM-6.0.
    **  We are interested in the files: config.h and dwm.c.
    
 II.Rewrite DWM configurations.
    # vi config.h

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
/* DWM DWM Window manager.
 * Author: valsorym
 * Date: 2012.08.12
 */

/***************************************************************************/
/*******                          MAIN                               *******/
/***************************************************************************/
/* Font scheme. 
 * Support Latin (Russian, Ukrainian, Belarusian).
 */
static const char font[] = "-*-fixed-medium-r-normal-*-13-*-*-*-*-*-koi8-r";

/* Color scheme. */
static const char normbordercolor[] = "#444444";
static const char normbgcolor[] = "#222222";
static const char normfgcolor[] = "#bbbbbb";
static const char selbordercolor[] = "#222222";
static const char selbgcolor[] = "#222222";
static const char selfgcolor[] = "#eeeeee";

/* View scheme. */
static const unsigned int borderpx = 1;   /* Border pixel of windows. */
static const unsigned int snap = 32;      /* Snap pixel. */
static const Bool showbar = True;         /* False means no bar. */
static const Bool topbar = True;          /* False means bottom bar. */

/***************************************************************************/
/*******                          TAGGING                            *******/
/***************************************************************************/
/* Tabs caption. */
static const char *tags[] = {"[cmd]", "[www]", "[free]", "[free]", "[free]"};

/* Parameters of the run programs. */
/* Tags mask:
 *     ~0      -   free and run everywhere.
 *     1 << 4  -   run only in the 5 tab.
 *     1 << 1  -   run only in the 2 tab.
 */
static const Rule rules[] = {
  /*  CLASS      INSTANCE  TITLE     TAGS MASK   ISFLOATING  MONITOR */
  /*{ "Gimp",    NULL,     NULL,     ~0,         True,       -1 },
    { "MPlayer", NULL,     NULL,     ~0,         True,       -1 },
    { "Conky",   NULL,     NULL,     1 << 4,     False,      -1 }, 
    { "XTerm",   NULL,     NULL,     1 << 4,     False,      -1 }, */
    
    { "gnome-terminal",   
                 NULL,     NULL,     1 << 4,     False,      -1 },
    { "Opera",   NULL,     NULL,     1 << 1,     False,      -1 },
};

/***************************************************************************/
/*******                         LAYOUT(S)                           *******/
/***************************************************************************/
/* Factor of master area size [0.05..0.95]. */
static const float mfact = 0.75; 

/* Number of clients in master area. */
static const int nmaster = 1;    

/* True means respect size hints in tiled resizals. */
static const Bool resizehints = True; 

static const Layout layouts[] = {
    /* SYMBOL  |  ARRANGE
     *            FUNCTION */
    { "[t]",      tile },  /* First entry is default. */
    { "[f]",      NULL },  /* No layout function means floating behavior. */
    { "[m]",      monocle },
};

#define MODKEY Mod1Mask
#define TAGKEYS(KEY,TAG) \
    { MODKEY,                       KEY,  view,       {.ui = 1 << TAG} }, \
    { MODKEY|ControlMask,           KEY,  toggleview, {.ui = 1 << TAG} }, \
    { MODKEY|ShiftMask,             KEY,  tag,        {.ui = 1 << TAG} }, \
    { MODKEY|ControlMask|ShiftMask, KEY,  toggletag,  {.ui = 1 << TAG} },

/* Helper for spawning shell commands in the pre dwm-5.0 fashion. */
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }

/* Commands. */
static const char *dmenucmd[] = { "dmenu_run", "-fn", font, "-nb",
    normbgcolor, "-nf", normfgcolor, "-sb", selbgcolor, "-sf",
    selfgcolor, NULL };
static const char *termcmd[]  = { "urxvt", NULL };

/***************************************************************************/
/*******                      KEY DEFINITIONS                        *******/
/***************************************************************************/
static Key keys[] = {
    /* MODIFIER          KEY        FUNCTION        ARGUMENT */
    { MODKEY,            XK_p,      spawn,          {.v = dmenucmd } },
    { MODKEY|ShiftMask,  XK_Return, spawn,          {.v = termcmd } },
    { MODKEY,            XK_b,      togglebar,      {0} },
    { MODKEY,            XK_j,      focusstack,     {.i = +1 } },
    { MODKEY,            XK_k,      focusstack,     {.i = -1 } },
    { MODKEY,            XK_i,      incnmaster,     {.i = +1 } },
    { MODKEY,            XK_d,      incnmaster,     {.i = -1 } },
    { MODKEY,            XK_h,      setmfact,       {.f = -0.05} },
    { MODKEY,            XK_l,      setmfact,       {.f = +0.05} },
    { MODKEY,            XK_Return, zoom,           {0} },
    { MODKEY,            XK_Tab,    view,           {0} },
    { MODKEY|ShiftMask,  XK_c,      killclient,     {0} },
    { MODKEY,            XK_t,      setlayout,      {.v = &layouts[0]} },
    { MODKEY,            XK_f,      setlayout,      {.v = &layouts[1]} },
    { MODKEY,            XK_m,      setlayout,      {.v = &layouts[2]} },
    { MODKEY,            XK_space,  setlayout,      {0} },
    { MODKEY|ShiftMask,  XK_space,  togglefloating, {0} },
    { MODKEY,            XK_0,      view,           {.ui = ~0 } },
    { MODKEY|ShiftMask,  XK_0,      tag,            {.ui = ~0 } },
    { MODKEY,            XK_comma,  focusmon,       {.i = -1 } },
    { MODKEY,            XK_period, focusmon,       {.i = +1 } },
    { MODKEY|ShiftMask,  XK_comma,  tagmon,         {.i = -1 } },
    { MODKEY|ShiftMask,  XK_period, tagmon,         {.i = +1 } },
    
    /* [!] Add this function in dwm.c file.
     * Function resets the position of windows to the standard.
     */
    { MODKEY,            XK_q,      zeronmaster,    {.i = 0 } },
    
    /* Learn the key code with the utility "xev". */
    TAGKEYS(0xffbe,  0) /* F1 */
    TAGKEYS(0xffbf,  1) /* F2 */
    TAGKEYS(0xffc0,  2) /* .. */
    TAGKEYS(0xffc1,  3)
    TAGKEYS(0xffc2,  4)
    TAGKEYS(0xffc3,  5)
    TAGKEYS(0xffc4,  6)
    TAGKEYS(0xffc5,  7)
    TAGKEYS(0xffc6,  8) /* F9 */
    
    { MODKEY|ShiftMask,  XK_q,   quit, {0} },
};

/***************************************************************************/
/*******                     BUTTON DEFINITIONS                      *******/
/***************************************************************************/
/* Click can be ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin,
 * or ClkRootWin
 */
static Button buttons[] = {
    /* CLICK         EVENT MASK  BUTTON    FUNCTION     ARGUMENT */
    { ClkLtSymbol,   0,          Button1,  setlayout,   {0} },
    { ClkLtSymbol,   0,          Button3,  setlayout,   {.v = &layouts[2]} },
    { ClkWinTitle,   0,          Button2,  zoom,        {0} },
    { ClkStatusText, 0,          Button2,  spawn,       {.v = termcmd } },
    { ClkClientWin,  MODKEY,     Button1,  movemouse,   {0} },
    { ClkClientWin,  MODKEY,     Button2,  togglefloating, {0} },
    { ClkClientWin,  MODKEY,     Button3,  resizemouse,    {0} },
    { ClkTagBar,     0,          Button1,  view,           {0} },
    { ClkTagBar,     0,          Button3,  toggleview,     {0} },
    { ClkTagBar,     MODKEY,     Button1,  tag,            {0} },
    { ClkTagBar,     MODKEY,     Button3,  toggletag,      {0} },
};
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
 
4.3.9. X11 Dwm (Ptr 2).

To view the complete contents of the HOWTO/FAQ: Back to content.
Go to 4.3.9. X11 Dwm (Ptr 1).

P.S. Sorry for my bad English.
P.P.S. If you find something of interest, tell me: "thank you man" - I will be pleased. If you think that this is useless, do not scold me - I will be unpleasant. If you know a better solution - I'll be glad to see your adjustments.

Code:
III.Add our zeronmaster function in DWM.
    # vi dwm.c

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
...
static void incnmaster(const Arg *arg);
static void zeronmaster(const Arg *arg);    /* [!] Add it. Line: ~196 */
static void initfont(const char *fontstr);
...

...
/* [!] Add it. Line: ~1035 */
void									
zeronmaster(const Arg *arg) {
	selmon->nmaster = 1;
	arrange(selmon);
}
...
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

 IV.Reinstall DWM.
    # cd /usr/ports/x11-wm/dwm/
    # make deinstall
    # make && make install

-----------------------------------------------------------------------------
Additional software.
-----------------------------------------------------------------------------
    Program that displays the time, keyboard layoutand and battery status.
    # cd /usr/ports/x11-wm/dwm/work/dwm-6.0/
    # vi dwmbar.c

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
*****************************************************************************

SEE URL: http://pastebin.com/tuRfDzGc

*****************************************************************************
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .    


    Compile it:
    # cc -Wall -ansi -o dwmbar dwmbar.c -I/usr/local/include \
		-L/usr/local/lib -lX11
    
    Copy bin file:
    # cp ./dwmbar /usr/bin/

-----------------------------------------------------------------------------
Setup utility.
-----------------------------------------------------------------------------
  I.Switching the keyboard layout.
    # vi ~/.xxkbrc

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
XXkb.button.enable: no

XXkb.controls.two_state: no
XXkb.controls.focusout: yes
XXkb.controls.add_when_start: yes
XXkb.controls.add_when_create: yes
XXkb.controls.add_when_change: yes

XXkb*label.text.1: En
XXkb*label.text.2: Ru
XXkb*label.text.3: Ua

XXkb.mainwindow.type: tray
XXkb.mainwindow.enable: no
XXkb.mainwindow.appicon: no
XXkb.mainwindow.geometry: 20x20

XXkb.mainwindow.label.enable: no
XXkb.mainwindow.label.background: transperent
XXkb.mainwindow.label.foreground: #ffffff
XXkb.mainwindow.label.font: -misc-*-r-*-13-*

XXkb.mainwindow.border.color: white
XXkb.mainwindow.border.width: 2
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    Copy config file others users.
    # cp .xxkbrc /usr/home/<USERNAME>/
    
-----------------------------------------------------------------------------
Setting Xorg.
-----------------------------------------------------------------------------
  I.Install Xorg.
    A.  From ports collections.
        # cd /usr/ports/x11/xorg
        # make && make install clean
        
    B.  From packages.
        # pkg_add -r xorg
    
 II.Configure.
    **  Add next options.
    # vi /etc/rc.conf
    
[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
# GUI
# + Mouse and Keyboard in GUI.
hald_enable="YES"
dbus_enable="YES"
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

III.Create xorg.conf.
    1.  Configure.
        # Xorg -configure
        # Xorg -config /root/xorg.conf.new

    2.  After go to next screen (Alt+F3).
        # cd /root/
        # cp xorg.conf.new /etc/X11/xorg.conf

-----------------------------------------------------------------------------
Launch DWM.
-----------------------------------------------------------------------------
  I.Configure X.
    **  DWM will only run under the user.
    # vi /usr/home/<USERNAME>/.xinitrc
  
[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
export LANG="ru_RU.UTF-8"
export LC_ALL="ru_RU.UTF-8"

setxkbmap -layout us,ru,ua -variant \
-option grp:lwin_toggle,grp_led:scroll,terminate:ctrl_alt_bksp &

xxkb &
mixer 95:95 &
gnome-terminal &
dwmbar &

exec dwm
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

 II.Launch DWM.
    # startx

=============================================================================
                                                             Author: valsorym
 
4.3.10. X11 Kde4.

To view the complete contents of the HOWTO/FAQ: Back to content.

P.S. Sorry for my bad English.
P.P.S. If you find something of interest, tell me: "thank you man" - I will be pleased. If you think that this is useless, do not scold me - I will be unpleasant. If you know a better solution - I'll be glad to see your adjustments.

Code:
=============================================================================
                            HOWTO FOR FREEBSD 9.x.
=============================================================================
CREATED:
    Author: valsorym
    E-mail: valsorym.e@gmail.com
    
DATE:
    2013.03.23

DESCRIPTION:
    Kde4 Desktop Environment.
=============================================================================
-----------------------------------------------------------------------------
Note.
-----------------------------------------------------------------------------
    KDE is an international free software community producing an integrated 
    set of cross-platform applications designed to run on GNU/Linux, FreeBSD,
    Solaris, Microsoft Windows, and OS X systems.

-----------------------------------------------------------------------------
Installing from packages.
-----------------------------------------------------------------------------
  I.Installing KDE4.
    **  KDE4 installation time can be problems with the packages:
        qt4-doc-4.7.4.tbz, kdeartwork-4.7.3.tbz - we need to download the
        packages and install them manually and restart the cycle KDE4
        installation.
	**	For FreeBSD 9.1 packages do not exist - to change the value of a
	    global variable PACKAGESITE for installation packages version 9.0.

    # pkg_add -r kde4
    
 II.Russification.
    # pkg_add -r ru-kde-l10n
    
    **  After starting KDE: settings - language - russian.

-----------------------------------------------------------------------------
Change of system files.
-----------------------------------------------------------------------------
  I.Automatic start.
    # vi /etc/rc.conf

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
# GUI I/O
# + Mouse and Keyboard in GUI.
hald_enable="YES"
dbus_enable="YES"

# DE/WM
# + KDE
kdm4_enable="YES"
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

 II.Start use xstart.
    # vi /etc/rc.conf

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
# GUI I/O
# + Mouse and Keyboard in GUI.
hald_enable="YES"
dbus_enable="YES"
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    # vi ~/.xinitrc
[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
export LANG="ru_RU.UTF-8"
export LC_ALL="ru_RU.UTF-8"

# KDE4
exec /usr/local/kde4/bin/startkde
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .	


=============================================================================
                                                             Author: valsorym
 
4.3.11. X11 Xcompmgr.

To view the complete contents of the HOWTO/FAQ: Back to content.

P.S. Sorry for my bad English.
P.P.S. If you find something of interest, tell me: "thank you man" - I will be pleased. If you think that this is useless, do not scold me - I will be unpleasant. If you know a better solution - I'll be glad to see your adjustments.

Code:
=============================================================================
                            HOWTO FOR FREEBSD 9.x.
=============================================================================
CREATED:
    Author: valsorym
    E-mail: valsorym.e@gmail.com
    
DATE:
    2013.03.23

DESCRIPTION:
    Xcompmgr composite manager.
=============================================================================
-----------------------------------------------------------------------------
Note.
-----------------------------------------------------------------------------
    Xcompmgr is a simple composite manager capable of rendering drop shadows
    and, with the use of the transset utility, primitive window transparency.

-----------------------------------------------------------------------------
Installing.
-----------------------------------------------------------------------------
  I.Installing Xcompmgr.
    A.  From packages.
        # pkg_add -r xcompmgr

-----------------------------------------------------------------------------
Run.
-----------------------------------------------------------------------------
  I.Simple run.
    % xcompmgr -c

-----------------------------------------------------------------------------
Gnome2 + Gcompmgr.
-----------------------------------------------------------------------------
**  gcompmgr, is a Gnome GUI interface to xcompmgr, it is an anjuta managed
    project in C++ with a GTKmm/Gnome2 backend. Through xcompmgr it allows 
    you to use your graphics card to create effects in your Gnome window 
    manager.

  I.Install.
    **
    # pkg_add -r gcompmgr
    # rehash

 II.And run.
    # gcompmgr

=============================================================================
                                                             Author: valsorym
 
4.3.12. X11 Xfce4.

To view the complete contents of the HOWTO/FAQ: Back to content.

P.S. Sorry for my bad English.
P.P.S. If you find something of interest, tell me: "thank you man" - I will be pleased. If you think that this is useless, do not scold me - I will be unpleasant. If you know a better solution - I'll be glad to see your adjustments.

Code:
=============================================================================
                            HOWTO FOR FREEBSD 9.x.
=============================================================================
CREATED:
    Author: valsorym
    E-mail: valsorym.e@gmail.com
    
DATE:
    2013.03.23

DESCRIPTION:
    Xfce4 Desktop Environment.
=============================================================================
-----------------------------------------------------------------------------
Note.
-----------------------------------------------------------------------------
    Xfce is a lightweight desktop environment for UNIX operating systems.
    It aims to be fast and low on system resources, while still being
    visually appealing and user friendly.

-----------------------------------------------------------------------------
Installing from ports collections.
-----------------------------------------------------------------------------
  I.Installing Xfce4.
    # cd /usr/ports/x11/xorg
    # make && make install clean

    # cd /usr/ports/x11-fonts/webfonts
    # make && make install clean
    
    # cd /usr/ports/x11-wm/xfce4
    # make && make install clean

 II.Installation of additional software.
    1.  Program to identify the key code.
        # cd /usr/ports/x11/xev
        # make && make install clean

    2.  Program to displays the current layout in the panel Xfce.
        # cd /usr/ports/deskutils/xfce4-xkb-plugin
        # make && make install clean

    3.  Program to display the battery status on the panel Xfce.
        # cd /usr/ports/sysutils/xfce4-battery-plugin
        # make && make install clean

-----------------------------------------------------------------------------
Change of system files.
-----------------------------------------------------------------------------
  I.Change /boot/loader.con file.
    # vi /boot/loader.conf

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
# ACPI
# + Control (on/off) video outputs.
acpi_video_load="YES"

# + Adds additional controls in the system tree MIB (for example, you can 
#   on/off wifi module or card reader, etc.).
acpi_asus_load="YES"

# MOUNTING
# + Filesystem.
libiconv_load="YES"
libmchain_load="YES"
cd9660_iconv_load="YES"
msdosfs_iconv_load="YES"
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

 II.Change /usr/local/etc/PolicyKit/PolicyKit.conf file.
    **  Give users the right to restart and shutdown.
    # vi /usr/local/etc/PolicyKit/PolicyKit.conf

    **  Between <config> </config> tags add:
[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
<match action="org.freedesktop.hal.power-management.shutdown">
    <return result="yes"/>
</match>
 
<match action="org.freedesktop.hal.power-management.reboot">
    <return result="yes"/>
</match>
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

III.Change /etc/fstab file.
    **  Software could to get information on access rights.
    1.  Add to file.
        # vi /etc/fstab

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
proc    /proc    procfs    rw    0    0
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    2.  Mount poc filesystem.
        # mount /proc

 IV.Change org.freedesktop.consolekit.pkla file.
    **  Activate button shutdown and reboot.
    # cd /usr/local/etc/polkit-1/localauthority/50-local.d/
    # vi org.freedesktop.consolekit.pkla

    **  Notice the line:
        Identity=unix-group:ENTER_HERE_YOUR_GROUP
[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
[Restart]
Identity=unix-group:ENTER_HERE_YOUR_GROUP
Action=org.freedesktop.consolekit.system.restart
ResultAny=yes
ResultInactive=yes
ResultActive=yes
 
[Shutdown]
Identity=unix-group:ENTER_HERE_YOUR_GROUP
Action=org.freedesktop.consolekit.system.stop
ResultAny=yes
ResultInactive=yes
ResultActive=yes
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

-----------------------------------------------------------------------------
Start Xfce4 (console method).
-----------------------------------------------------------------------------
  I.Run the command.
    **  Under simple user.
    # gconftool-2 --type list --list-type=string \
    --set /system/storage/default_options/vfat/mount_options \
    "[longnames,-u=,-L=ru_RU.UTF-8,-D=cp866]"

 II.Configure start Xfce4.
    **  Under simple user.
    # vi ~/.xinitrc

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
export LANG="ru_RU.UTF-8"
export LC_ALL="ru_RU.UTF-8"

mixer 95:95 &
exec /usr/local/bin/startxfce4
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    **  To start, use the command:
        # xstart
 
-----------------------------------------------------------------------------
Start Xfce4 (custom method).
-----------------------------------------------------------------------------
  I.Run the command.
    **  Under simple user.
    # gconftool-2 --type list --list-type=string \
    --set /system/storage/default_options/vfat/mount_options \
    "[longnames,-u=,-L=ru_RU.UTF-8,-D=cp866]"
    
 II.Install and configure xdm.
    1.  Install xdm.
        # cd /usr/ports/x11/xdm
        # make && make install clean
        
    2.  Configure xdm.
    **  Modified /etc/ttys.
        # vi /etc/ttys

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
ttyv8   "/usr/local/bin/xdm -nodaemon"  xterm   on  secure
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    3.  Change ~/.xsession
    **  Under simple user.
        # vi ~/.xsession
        
[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
export LANG="ru_RU.UTF-8"
export LC_ALL="ru_RU.UTF-8"

exec /usr/local/bin/startxfce4
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    **  The end. Reboot system.

=============================================================================
                                                             Author: valsorym
 
5.1.1. Dump and Restore.

To view the complete contents of the HOWTO/FAQ: Back to content.

P.S. Sorry for my bad English.
P.P.S. If you find something of interest, tell me: "thank you man" - I will be pleased. If you think that this is useless, do not scold me - I will be unpleasant. If you know a better solution - I'll be glad to see your adjustments.

Code:
=============================================================================
                            HOWTO FOR FREEBSD 9.x.
=============================================================================
CREATED:
    Author: valsorym
    E-mail: valsorym.e@gmail.com
    
DATE:
    2013.03.23

DESCRIPTION:
    Dump and Restore.
=============================================================================
-----------------------------------------------------------------------------
Create snapshot your systemi (dump & restore).
-----------------------------------------------------------------------------
    ** For example, use an external drive /dev/da0a to store the backup.
    
  I. Without compression.
    A.  Create.
        # mount /dev/da0a /mnt
        # dump -C16 -0uanL -h0 -f /mnt/root.dump /
        # dump -C16 -0uanL -h0 -f /mnt/var.dump /var
        # dump -C16 -0uanL -h0 -f /mnt/usr.dump /usr
        # umount /mnt

    B.  Restore.
        # mount /dev/da0a /mnt
        # cd / && restore -ruf /mnt/root.dump
        # cd /var && restore -ruf /mnt/var.dump
        # cd /usr && restore -ruf /mnt/usr.dump
        # umount /mnt
        
 II.Use compression.
    A.  Create.
        # mount /dev/da0a /mnt
        # dump -C16 -0uanL -h0 -f - /    | gzip -2 > /mnt/root.dump.gz
        # dump -C16 -0uanL -h0 -f - /var | gzip -2 > /mnt/var.dump.gz
        # dump -C16 -0uanL -h0 -f - /usr | gzip -2 > /mnt/usr.dump.gz
        # umount /mnt

    B.  Restore.
        # mount /dev/da0a /mnt
        # gzcat /mnt/root.dump.gz | (cd / && restore -ruf -)
        # gzcat /mnt/var.dump.gz  | (cd /var && restore -ruf -)
        # gzcat /mnt/usr.dump.gz  | (cd /usr && restore -ruf -)
        # umount /mnt
        
-----------------------------------------------------------------------------
Backup via SSH.
-----------------------------------------------------------------------------
  I.Create and restore.
    A.  Create.
        # dump -C16 -0uanL -h0 -f - /    | gzip -2 | 
            ssh -c blowfish user@host dd of=root.dump.gz
        # dump -C16 -0uanL -h0 -f - /var | gzip -2 | 
            ssh -c blowfish user@host dd of=var.dump.gz
        # dump -C16 -0uanL -h0 -f - /usr | gzip -2 | 
            ssh -c blowfish user@host dd of=usr.dump.gz

    B.  Restore.
        # mkdifr /tmp/root /tmp/var /tmp/usr
        # ssh -c blowfish usr@host gzcat root.dump.gz | 
            (cd /tmp/root && restore -ruf -)
        # ssh -c blowfish usr@host gzcat var.dump.gz  | 
            (cd /tmp/var && restore -ruf -)
        # ssh -c blowfish usr@host gzcat usr.dump.gz  | 
            (cd /tmp/usr && restore -ruf -)

=============================================================================
                                                             Author: valsorym
 
5.2.1. Create local repository.

To view the complete contents of the HOWTO/FAQ: Back to content.

P.S. Sorry for my bad English.
P.P.S. If you find something of interest, tell me: "thank you man" - I will be pleased. If you think that this is useless, do not scold me - I will be unpleasant. If you know a better solution - I'll be glad to see your adjustments.

Code:
=============================================================================
                            HOWTO FOR FREEBSD 9.x.
=============================================================================
CREATED:
    Author: valsorym
    E-mail: valsorym.e@gmail.com
    
DATE:
    2013.03.23

DESCRIPTION:
    Create local repository.
=============================================================================
-----------------------------------------------------------------------------
Create a local repository of installed programs.
-----------------------------------------------------------------------------
  I.Create a custom script.
    1.  Create script.
        # mkdir -p ~/localrepo
        # cd ~/localrepo
        # vi create.csh
    
[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
#!/bin/csh

# Author: valsorym
# Date: 2013.01.20

# OPTIONS
set packages = `pkg_info | cut -d' ' -f1`
set localrepo = "$HOME/localrepo/"

# WORK
mkdir -p $localrepo
cd $localrepo

foreach package ($packages)
    pkg_create -b $package
end

unset localrepo packages

echo "Done!"
echo ""

exit(0)
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    2.  Run script.
        # csh create.csh

    **  Local repository will be created in ~/localrepo/
    **  See "Installation of the packages" HOWTO for installed software from
        local repository.

=============================================================================
                                                             Author: valsorym
 
1.1.1. Short MySQL FAQ (Part 1).

To view the complete contents of the HOWTO/FAQ: Back to content.
See also the short HOWTO for MySQL here.
Go to 1.1.1. Short MySQL FAQ (Part 2).

P.S. Sorry for my bad English.
P.P.S. If you find something of interest, tell me: "thank you man" - I will be pleased. If you think that this is useless, do not scold me - I will be unpleasant. If you know a better solution - I'll be glad to see your adjustments.

Code:
=============================================================================
                                   FAQ MySQL 55
=============================================================================
CREATED:
    Author: valsorym
    E-mail: valsorym.e@gmail.com
    
DATE:
    2013.03.23

DESCRIPTION:
    Database MySQL 55.
=============================================================================
-----------------------------------------------------------------------------
Attention.
-----------------------------------------------------------------------------
    **  Installation instructions, see in the MySql55 HOWTO.
    **  We use syntax of the form: [USERNAME] or [PASSWORD] - you need 
        instead to specify a username or password.

-----------------------------------------------------------------------------
Useful links.
-----------------------------------------------------------------------------
  I.http://www.mysql.ru/docs/pautov/sql.htm

*****************************************************************************
                                MAIN OPTIONS
*****************************************************************************
-----------------------------------------------------------------------------
First run MysqlAdmin.
-----------------------------------------------------------------------------
  I.Installing database.
    # cd /usr/local; mysql_install_db
    # chown -R mysql:mysql /var/db/mysql
    # /usr/local/etc/rc.d/mysql-server start

 II.For the first time set a root password.
    A.  Install only the password.
        # mysqladmin -u root password '[PASSWORD]'

    B.  Set a password and host name.
        # mysqladmin -u root -h '[HOSTNAME]' password '[PASSWORD]'

III.Starting the server console.
    A.  Quick start.
        ** No spaces between the parameters and data.
        # mysql -u[USERNAME] -p[PASSWORD] mysql

    B.  Standard launch.
        # mysql -u [USERNAME] -p
        Enter password:

 IV.Remove others localhost users.
    > delete from user where not (user='root' and host='localhost');
    > select user, host from user;

    +------+-----------+
    | user | host      |
    +------+-----------+
    | root | localhost |
    +------+-----------+
    1 row in set (0.00 sec)

  V.Exit from the server console.
    A.  Use 'quit' sql query.
        > quit

    B.  Use 'exit' sql query.
        > exit

-----------------------------------------------------------------------------
Change the root password.
-----------------------------------------------------------------------------
  A.Change the root password.
    **  If you know the root password.
    1.  Start the MySQL console.
        # mysql -u root -p
        Password:

    2.  Create a MySQL query:
        > set password for 'root'@'localhost' = password('[NEWPASSWORD]');

  B.Reset the administrator password.
    **  If you forget the root password.
    **  If mysql-server has been turned off/on several times:
        Using the top or htop - kill processes: mysql, mysqd_safe etc., and
        # /usr/local/etc/rc.d/mysql-server stop
        # /usr/local/etc/rc.d/mysql-server start

    1.  Edit /usr/local/etc/rc.d/mysql-server file.
        **  Add to the beginning of the file.
        # vi /usr/local/etc/rc.d/mysql-server

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
mysql_args="--init-file=/root/mysql-pass-reset"
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    2.  Create a script change the password.
        **  Password must be replaced twice in the [NEWPASSWORD].
        # vi /root/mysql-pass-reset

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
update mysql.user set password = password('[NEWPASSWORD]') where user='root';
grant all privileges on *.* to root@localhost identified by password
password('[NEWPASSWORD]') with grant option;
flush privileges;
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    3.  Restart mysql-server.
        # /usr/local/etc/rc.d/mysql-server restart
  
    4.  Connect to mysql use new password.
        # mysql -u root -p
        Password: [NEWPASSWORD]

    **  If the connection fails - restart mysql server and try again.
    **  Comment out mysql_args="--init-file=/root/mysql-pass-reset" in the 
        file: /usr/local/etc/rc.d/mysql-server
    **  Remove /root/mysql-pass-reset.

-----------------------------------------------------------------------------
Removing the anonymous account.
-----------------------------------------------------------------------------
  I.Start the MySQL console as root and run the query.
    > use mysql;
    > delete from user where User = '';
    > delete from db where User = '';
    > flush privileges;

*****************************************************************************
                             DATABASE OPERATIONS
*****************************************************************************
-----------------------------------------------------------------------------
View databases.
-----------------------------------------------------------------------------
  I.Start the MySQL console as root and run the query.
    > show databases;

    +--------------------+
    | information_schema |
    | mysql              |
    | performance_schema |
    | test               |
    +--------------------+
    4 rows in set (0.00 sec)

-----------------------------------------------------------------------------
Create a new database.
-----------------------------------------------------------------------------
  I.Start the MySQL console as root and run the query.
    A.  Rough method.
        > create database [DATABASE];
        or
        > create database [DATABASE] charset=[CODING];

    B.  Mild method.
        > create database if not exists [DATABASE];
        or
        > create database if not exists [DATABASE] charset=[CODING];

 II.Example.
    **  Creating a database with encoding utf-8.
    **  Attention! The server mysql must be configured properly. 
    > create database if not exists my_site_database charset=utf8;

-----------------------------------------------------------------------------
Remove database.
-----------------------------------------------------------------------------
  I.Start the MySQL console as root and run the query.
    A.  Rough method.
        > drop database [DATABASE];

    B.  Mild method.
        > drop database if exists [DATABASE];

-----------------------------------------------------------------------------
Select database.
-----------------------------------------------------------------------------
  I.Start the MySQL console as root and run the query.
    > use [DATABASE];
 
1.1.1. Short MySQL FAQ (Part 2).

To view the complete contents of the HOWTO/FAQ: Back to content.
Go to 1.1.1. Short MySQL FAQ (Part 1).

P.S. Sorry for my bad English.
P.P.S. If you find something of interest, tell me: "thank you man" - I will be pleased. If you think that this is useless, do not scold me - I will be unpleasant. If you know a better solution - I'll be glad to see your adjustments.

Code:
*****************************************************************************
                              TABLES OPERATIONS
*****************************************************************************
-----------------------------------------------------------------------------
View tables.
-----------------------------------------------------------------------------
  I.Start the MySQL console.
    1.  Select database.
        > use [DATABASE];

    2.  View tables.
        > show tables;

    3.  View table status.
        > show table status;

-----------------------------------------------------------------------------
Create tables.
-----------------------------------------------------------------------------
  I.Start the MySQL console.
    1.  Select database.
        > use [DATABASE];

    2.  Create query.
        > create table [TABLENAME] (
        -> id int not null auto_increment primary key,
        -> [ARGNAME] [ARGTYPE],
        ...
        -> [ARGNAME] [ARGTYPE]
        ) type = [TABLETYPE];

    Example:
        > drop database if exists helloworld;
        > create database helloworld;
        > use helloworld;

        > create table messages (
        -> id int not null auto_increment primary key,
        -> message varchar(77));

        > show tables;

        +----------------------+
        | Tables_in_helloworld |
        +----------------------+
        | messages             |
        +----------------------+
        1 row in set (0.00 sec)

-----------------------------------------------------------------------------
Delete tables.
-----------------------------------------------------------------------------
  I.Start the MySQL console.
    1.  Select database.
        > use [DATABASE];

    2.  Create query.
        > drop table if exists [TABLENAME];

-----------------------------------------------------------------------------
Show table data.
-----------------------------------------------------------------------------
  I.Start the MySQL console.
    1.  Select database.
        > use [DATABASE];

    2. Create query.
        > select [FIELD_1],[FIELD_ ...],[FIELD_N] from [TABLENAME];

    Example:
        > use mysql;
        > select user,password,host from user;

*****************************************************************************
                             ACCOUNTS OPERATIONS
*****************************************************************************
-----------------------------------------------------------------------------
View users.
-----------------------------------------------------------------------------
  I.Start the MySQL console as root and run the query.
    > use mysql;
    > select user,password,host from user;

    +-------------+-------------------------------------------+-----------+
    | user        | password                                  | host      |
    +-------------+-------------------------------------------+-----------+
    | root        | *CDC006E5FCB22B379747AF6E75DF97FB503F11B3 | localhost |
    +-------------+-------------------------------------------+-----------+
    1 rows in set (0.01 sec)

-----------------------------------------------------------------------------
Create an new account.
-----------------------------------------------------------------------------
  I.Start the MySQL console as root and run the query.
    **  Database [DATABASE] must already be created.
    > grant all privileges on [DATABASE].* to '[USERNAME]'@'[HOSTNAME]'
    -> identified by '[PASSWORD]' with grant option;
    > flush privileges;

-----------------------------------------------------------------------------
Remove users.
-----------------------------------------------------------------------------
  I.Start the MySQL console as root and run the query.
    A.  Use drop query.
        > drop user '[USERNAME]'@'[HOSTNAME]';

=============================================================================
                                                             Author: valsorym
 
2.1.1.1 Devel Ruby-Gems.

To view the complete contents of the HOWTO/FAQ: Back to content.

P.S. Sorry for my bad English.
P.P.S. If you find something of interest, tell me: "thank you man" - I will be pleased. If you think that this is useless, do not scold me - I will be unpleasant. If you know a better solution - I'll be glad to see your adjustments.

Code:
=============================================================================
                             FAQ DEVEL RUBY-GEMS
=============================================================================
CREATED:
    Author: valsorym
    E-mail: valsorym.e@gmail.com
    
DATE:
    2013.03.23

DESCRIPTION:
    Install Ruby-Gems.
=============================================================================
-----------------------------------------------------------------------------
Settings.
-----------------------------------------------------------------------------
  I.Configure config files.
    **  We use ruby 1.9.
    In /etc/make.conf add:
    # vi /etc/make.conf

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
RUBY_VERSION=1.9.3
RUBY_DEFAULT_VER=1.9
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

-----------------------------------------------------------------------------
Installation.
-----------------------------------------------------------------------------
  I.Installation Ruby 1.9.3.
    A.  From ports collections.
        # /usr/ports/devel/ruby-gems
        # make && make install clean
  
=============================================================================
                                                             Author: valsorym
 
Back
Top