Webmin

[codesyntax lang=”bash” lines=”no” container=”pre” tab_width=”4″]

$ su
$ vi /etc/apt/sources.list
deb http://download.webmin.com/download/repository sarge contrib

$ cd /root
$ wget http://www.webmin.com/jcameron-key.asc
$ apt-key add jcameron-key.asc
$ apt-get update
$ apt-get install webmin
$ firefox https://ubuntu:10000/

[/codesyntax]

Posted in Ubuntu | Tagged | Leave a comment

Nginx and PHP for Windows

1. Environment
Window XP
Nginx 0.8.50
PHP 5.2.14


2. Download Nginx
Unzip to D:\nginx-0.8.50


3. Download PHP
Unzip to D:\nginx-0.8.50\php-5.2.14


4. Create D:\nginx-0.8.50\php-5.2.14\php.ini
cgi.fix_pathinfo = 1
extension_dir = “D:/nginx-0.8.50/php-5.2.14/ext”


5. start-php-cgi.bat :

set PHP_FCGI_MAX_REQUESTS=1000

D:/nginx-0.8.50/php-5.2.14/php-cgi.exe -b 127.0.0.1:9000 -c D:/nginx-0.8.50/php-5.2.14/php.ini


6. start-nginx.bat

D:/nginx-0.8.50/nginx.exe


7. stop-all.bat:

taskkill /F /IM nginx.exe > nul

taskkill /F /IM php-cgi.exe > nul


8. modify D:\nginx-0.8.50\conf\nginx.conf :

[codesyntax lang=”apache” lines=”no” container=”pre” tab_width=”4″]

error_log  logs/error.log;
events {
    worker_connections  64;
}
location ~ \.php$ {
            root                         D:/www;
            fastcgi_pass                 127.0.0.1:9000;
            fastcgi_index                index.php;
            fastcgi_param                SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            fastcgi_split_path_info      ^(.+\.php)(.*)$;
            fastcgi_param PATH_INFO      $fastcgi_path_info;
            include                      fastcgi_params;
}

[/codesyntax]


9. to test it with http://localhost


10. virtual host:

[codesyntax lang=”apache” lines=”no” container=”pre” tab_width=”4″]

server {
    listen 80;
    server_name  kimbs-local.com;
    root  D:/www/kimbs;
    location / {
        index index.php index.html index.htm ;
    }
    location ~ \.php$ {
        fastcgi_pass                   127.0.0.1:9000;
        fastcgi_index                  index.php;
        fastcgi_param                  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        fastcgi_split_path_info        ^(.+\.php)(.*)$;
        fastcgi_param PATH_INFO        $fastcgi_path_info;
        include                        fastcgi_params;
    }
}
server {
    listen 80;
    server_name  static.kimbs.local;
    root  D:/www/static;
}

[/codesyntax]


11. hosts
# nginx
127.0.0.1       kimbs-local.com
127.0.0.1       static.kimbs.local


12. Test it :
http://kimbs-local.com

Posted in Nginx | Tagged , , | 1 Comment

Awstats for Apache

1. Environment

Ubuntu Server 10.10
Awstats 6.95


2. Install Awstats

[codesyntax lang=”bash” lines=”no” container=”pre” tab_width=”4″]

$ su
$ apt-get install awstats

[/codesyntax]


3. Apache Configuration

[codesyntax lang=”bash” lines=”no” container=”pre” tab_width=”4″]

$ cd /etc/apache2/
$ vi awstats.conf

[/codesyntax]

Alias /awstats-classes “/usr/share/awstats/lib/”
Alias /awstats-icon “/usr/share/awstats/icon/”
Alias /awstats-css “/usr/share/doc/awstats/examples/css”
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
ScriptAlias /awstats/ /usr/lib/cgi-bin/
Options ExecCGI -MultiViews +SymLinksIfOwnerMatch

[codesyntax lang=”bash” lines=”no” container=”pre” tab_width=”4″]

$ vi apache2.conf

[/codesyntax]

Include /etc/apache2/awstats.conf

[codesyntax lang=”bash” lines=”no” container=”pre” tab_width=”4″]

$ /etc/init.d/apache2 restart

[/codesyntax]


4. Awstats Configuration

[codesyntax lang=”bash” lines=”no” container=”pre” tab_width=”4″]

$ cd /etc/awstats
$ cp awstats.conf awstats.192.168.0.129.conf
$ vi awstats.192.168.0.129.conf

[/codesyntax]

SiteDomain = “192.168.0.129”

[codesyntax lang=”bash” lines=”no” container=”pre” tab_width=”4″]

$ perl /usr/lib/cgi-bin/awstats.pl -update -config=192.168.0.129
$ firefox http://localhost/awstats/awstats.pl

[/codesyntax]

Posted in Project Management | Tagged , , | Leave a comment

The TCP/IP and OSI Network Models


The OSI Network Model


The OSI (Open System Interconnection) 7-layer reference model defines a concept of moving information between networked computers. It describes how information flows from one end-user application through a network into another application. This model is considered the primary architectural model for inter-computer communication. Each of the 7 OSI layers are reasonably self-contained, and handle a separate group of tasks.


Layer 1 – Physical
The Physical layer defines the electrical, mechanical, and all physical hardware means of sending and receiving data itself. It includes cables, cards, and all physical aspects. It conveys the bit stream through the network at the electrical and mechanical level. The physical layer specifications also define characteristics, such as voltage levels, timing of impulses, physical data rates, max transmission distance, and physical connectors. Physical layer implementations can be categorized as either WAN or LAN specifications.


Layer 2 – Data Link
The data link layer defines the format of data, and provides its reliable transit across the physical network link. At this layer, bits are encoded/decoded into data packets (with protocol-specific headers, including checksums, source/destination addresses, etc.). The layer facilitates transmission protocol management, flow control, frame synchronization, and handles any errors in the physical layer. It contains two sublayers – MAC (Media Access Control), and LLC (Logical Link Control).
The IEEE MAC specification defines MAC addresses, which enable multiple devices to uniquely identify each other at the data link layer. The MAC sublayer manages protocol access to the physical network medium. It controls how a network device gains access to, and permission to transmit data.
LLC manages communications between devices over a single link of a network. It controls frame synchronization, flow control and error checking.


Layer 3 – Network
The Network layer provides netwok addressing (which differs from the data link layer MAC address). It also facilitates switching, routing, error handling, congestion contol, and packet sequencing. It allows for defining the logical network layout, and virual logical paths for transmitting data between network nodes. The Internetwork Protocol (IP) operates at this layer. IP defines network addresses in a way that route selection can be determined systematically by comparing the source network address with the destination address, and applying the subnet mask. Routers operate at this layer to determine how to forward packets. Most of the design and configuration of netwok layout is at the networking layer.


Layer 4 – Transport
The Transport layer segments data (into packets) for transport across the network. It ensures complete data transfer by providing flow control, multiplexing, error checking and error recovery (retransmissions). Flow control manages data transmission between devices, so that the transmitting device does not send more data than the receiving device can process. Multiplexing allows for data from different applications to be transmitted through a single physical link. Such virtual “circuits” are established, maintained and terminated by the transport layer.
The most common transport layer protocols are TCP (Transmission Control Protocol) and UDP (User Datagram Protocol), with reliability and speed being the main difference between them.


Layer 5 – Session
The Session layer generally deals with session and connection coordination. It establishes, manages and terminates communications sessions. Sessions consist of service requests and responses that occur between applications in different network devices. Session protocol implementations include RPC (Remote Procedure Call), ZIP (Zone Information Protocol), AppleTalk, SCP (Session Control Protocol).


Layer 6 – Presentation
The Presentaion layer deals with conversion and coding of data from application to network format. It ensures the application layer data can be readable by other systems’ application layer. This layer formats and encrypts data, providing compatability between systems. It is sometimes called the “syntax layer”.


Layer 7 – Application

The Application layer supports and interacts directly with software applications. Its functions include identifying communication partners, determining resource availability and syncronizing communication. Some examples of application layer implementations include FTP (File Transfer Protocol), Telnet, SMTP (Simple Mail Transfer Protocol).




The TCP/IP Network Model


The TCP/IP protocol suite forms the basis of the Internet. It is the most widely used form of networking between coputers. TCP/IP is a combination of protocols at different layers that is designed around simple 4-layer scheme. It combines/splits some adjacent OSI layers, and omits some features. The 4-layer TCP/IP model is also known as the DARPA model, named after the U.S. government agency that initially defeloped TCP/IP.  The 4 layers are as follows:


Layer 1 – Link

The Link layer defines the device driver and network hardware (network interface card).


Layer 2 – Network

The Network layer handles basic communication, addressing and routing. IP, ICMP, ARP and IGMP protocols are at the network layer.


Layer 3 – Transport

The Transport layer handles flow of data among applications. It segments data into packets for transport over the network. TCP and UDP operate at the transport layer.


Layer 4 – Application

The Application layer handles details of the particular end-user applications. Commonly used TCP/IP applications include Telnet, FTP, SMTP, SNMP, DNS, RIP, NFS, NTP, Traceroute.
Posted in Network Protocol | Tagged , | 2 Comments

Subversion on Ubuntu Server

1. Environment
Ubuntu Server 10.10
Subversion 1.6.6


2. Install Subversion
[codesyntax lang=”bash” lines=”no” container=”pre” tab_width=”4″]

$ su root
$ apt-get install subversion

[/codesyntax]


3. Local Checkout
[codesyntax lang=”bash” lines=”no” container=”pre” tab_width=”4″]

$ mkdir /home/svn
$ cd /home/svn
$ mkdir myproject
$ svnadmin create /home/svn/myproject
$ cd /var/www
$ svn co file://localhost/home/svn/myproject

[/codesyntax]


4. Local Commit and Update
[codesyntax lang=”bash” lines=”no” container=”pre” tab_width=”4″]

$ cd /var/www/myproject
$ touch index.php
$ svn add index.php
$ svn ci index.php
$ rm index.php
$ svn up

[/codesyntax]


5. Http Checkout (based on apache)
[codesyntax lang=”bash” lines=”no” container=”pre” tab_width=”4″]

$ su root
$ apt-get install apache2
$ apt-get install libapache2-svn
$ /usr/local/apache2/bin/httpd -l

$ groupadd svn
$ usermod -G subversion -a www-data;
$ usermod -G subversion -a kim;
$ usermod -G subversion -a root;
$ cd /home/svn
$ chown -R root:svn myproject
$ chmod -R g+rws myproject

[/codesyntax]


[codesyntax lang=”bash” lines=”no” container=”pre” tab_width=”4″]

$ vi /etc/apache2/mods-available/dav_svn.conf

[/codesyntax]

<Location /svn/myproject>

DAV svn
SVNPath /home/svn/myproject
AuthType Basic
AuthName “myproject subversion repository”
AuthUserFile /etc/apache2/dav_svn.passwd

<LimitExcept GET PROPFIND OPTIONS REPORT>

Require valid-user

</LimitExcept>

</Location>


[codesyntax lang=”bash” lines=”no” container=”pre” tab_width=”4″]

$ htpasswd -c /etc/apache2/dav_svn.passwd kim
$ htpasswd /etc/apache2/dav_svn.passwd mypassword

[/codesyntax]


Checkout myproject with : http://yourhost/svn/myproject
Commit using kim/mypassword


6. Https Checkout (based on apache and openssl)


(a) Install OpenSSL

[codesyntax lang=”bash” lines=”no” container=”pre” tab_width=”4″]

$ su
$ apt-get install openssl
$ a2ensite default-ssl
$ a2enmod ssl
$ ls /etc/ssl

[/codesyntax]


(b) Create the RSA Key

[codesyntax lang=”bash” lines=”no” container=”pre” tab_width=”4″]

$ cd /etc/ssl
$ openssl req -x509 -newkey rsa:1024 -keyout private/kim.key -out certs/kim.pem -nodes -days 3650 -subj "/C=CN/ST=BJ/L=BJ/O=zlex/OU=zlex/CN=192.168.0.129"
$ ls private/; ls certs/kim.pem
$ vi /etc/apache2/sites-available/default-ssl

[/codesyntax]

SSLCertificateFile /etc/ssl/certs/kim.pem
SSLCertificateKeyFile /etc/ssl/private/kim.key


(c) Access from Outside (perhaps the ip address is 192.168.0.129)

[codesyntax lang=”bash” lines=”no” container=”pre” tab_width=”4″]

$ /etc/init.d/apache2 restart
$ firefox https://192.168.0.129/

[/codesyntax]


7. Links

Posted in SVN | Tagged , | Leave a comment