Ubuntu iTOps Tube

advertisement center

Tuesday, February 14, 2012

Instruction Guide to Install PHP5 from Source on Linux


 

All Linux distributions comes with PHP. However, it is recommended to download latest PHP source code, compile and install on Linux. This will make it easier to upgrade PHP on an ongoing basis immediately after a new patch or release is available for download from PHP. This article explains how to install PHP5 from source on Linux.

1. Prerequisites

Apache web server should already be installed. Refer to my previous post on How to install Apache 2 on Linux. If you are planning to use PHP with MySQL, you should have My SQL already installed. I wrote about How to install MySQL on Linux.

2. Download PHP

Download the latest source code from PHP Download page. Current stable release is 5.2.6. Move the source to /usr/local/src and extract is as shown below.

# bzip2 -d php-5.2.6.tar.bz2
# tar xvf php-5.2.6.tar

3. Install PHP

View all configuration options available for PHP using ./configure –-help (two hyphen in front of help). The most commonly used option is –-prefix={install-dir-name} to install PHP on a user defined directory.

# cd php-5.2.6
# ./configure --help

In the following example, PHP will be compiled and installed under the default location /usr/local/lib with Apache configuration and MySQL support.

# ./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql
# make
# make install
# cp php.ini-dist /usr/local/lib/php.ini

4. Configure httpd.conf for PHP

Modify the /usr/local/apache2/conf/httpd.conf to add the following:

<FilesMatch "\.ph(p[2-6]?|tml)$">
SetHandler application/x-httpd-php
</FilesMatch>

Make sure the httpd.conf has the following line that will get automatically inserted during the PHP installation process.

 

LoadModule php5_module modules/libphp5.so

Restart the apache as shown below:

# /usr/local/bin/apache2/apachectl restart

5. Verify PHP Installation

Create a test.php under /usr/local/apache2/htdocs with the following content

# vi test.php
<?php phpinfo(); ?>

Go to http://local-host/test.php , which will show a detailed information about all the PHP configuration options and PHP modules installed on the system.

6. Trouble shooting during installation

Error 1: configure: error: xml2-config not found:
While performing the ./configure during PHP installation, you may get the following error:

# ./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql
Configuring extensions
checking whether to enable LIBXML support... yes
checking libxml2 install dir... no
checking for xml2-config path...
configure: error: xml2-config not found. Please check your libxml2 installation.

Install thelibxml2-devel and zlib-devel as shown below to the fix this issue.

# rpm -ivh /home/downloads/linux-iso/libxml2-devel-2.6.26-2.1.2.0.1.i386.rpm /home/downloads/linux-iso/zlib-devel-1.2.3-3.i386.rpm
Preparing...                ########################################### [100%]
1:zlib-devel             ########################################### [ 50%]
2:libxml2-devel          ########################################### [100%]

Error 2: configure: error: Cannot find MySQL header files.
While performing the ./configure during PHP installation, you may get the following error:

# ./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql
checking for MySQL UNIX socket location... /var/lib/mysql/mysql.sock
configure: error: Cannot find MySQL header files under yes.
Note that the MySQL client library is not bundled anymore!

Install the MySQL-devel-community package as shown below to fix this issue.

# rpm -ivh /home/downloads/MySQL-devel-community-5.1.25-0.rhel5.i386.rpm
Preparing...                ########################################### [100%]
1:MySQL-devel-community  ########################################### [100%]

 

Step-by-Step Guide to Configure Hardware RAID on DELL servers with Screenshots


 

Expanding the capacity of a server by adding new disk drives is a typical activity for administrator. In this article, let us review how to add two new disk drives to the DELL server and create RAID 1 using “Dell PowerEdge Expandable RAID Controller – PERC” configuration utility. This tool is also called as “PERC/CERC Bios Configuration Utility”.
 
If you are using the latest DELL Servers, please refer to the article that explains
 how to create RAID on PERC 6/i Integrated BIOS Configuration Utility.

1. Launch PERC/CERC BIOS Configuration Utility.

Insert the two new disk drives onto the empty slots available on the server and reboot.  During the system startup, press Ctrl+M to launch the PowerEdge Expandable RAID Controller BIOS Configuration Utility.

2. Go to Configure -> View/Add Configuration

Using the arrow keys, select the Configure option from the main menu and “View/Add Configuration” option from the Configure menu as shown below.

3. Status of the new disk drives

The “View/Add Configuration” menu item,  will display all disk drives on the system along with status. In the following example, 4 disk drives are online and already configured. The 2 new drives display the READY status as shown below. The text next to ONLINE indicates the logical volume number and the disk# inside the logical drive. For e.g.  A01-00 indicates logical volume 1 and disk#0. A01-01 indicates logical volume 2 and disk#1.

 

4. Make the disk drives online

§  Use arrow key and select the first drive with READY status and press space bar, which will change the status from READY to ONLINE and add A02-00 next to it.  A02-00 will be blinking at this stage.

§  The cursor will automatically move to the next available drive with READY status.  Press space bar, which will change the status from READY to ONLINE and add A02-01 next to it. Both A02-00 and A02-01 will be blinking at this stage.

§  Press Enter to indicate the array selection is complete. Both A02-00 and A02-01 will stop blinking.

5. Configure the disk drives

Press F10 to continue the configuration of two selected disk drives. This will display the Array configuration screen as shown below.  The array number A02 number that got assigned for the new disk drives from the previous step, is displayed here.

§  Press space bar which will display the Span-1 message in the A02 text area as shown below.

§  Press F10 to continue the configuration to the next step.

6. Select RAID Level.

Pressing F10 from the above screen, will display the RAID configuration screen as shown below.

§  Use the arrow keys to select RAID 1 and press enter.

§  Use arrow keys to scroll down, select Accept and press enter to save the configurations.

The advanced menu in the above screen has the following options. I suggest that you don’t change this and leave it to the default values.

§  Stripe Size: 2KB, 4KB, 8KB, 16KB, 32KB, 64KB (default value) or 128 KB.

§  Write Policy: WRBACK (default value) or WRTHRU

§  Read Policy: NO_READAHEAD, READAHEAD or ADAPTIVE (default value)

§  Cache Policy: Cached IO or Direct IO (default value)

After saving the configuration, reboot the system. Logical Volume 02 is now configured as RAID1 using the two new disk drives and ready for use.

 

SSH Key based authentication setup from openSSH to SSH2


 

The previous articles (openSSH to openSSH setup, SSH2 to SSH2 setup) explains about how to setup key based authentication on the same version of ssh to perform ssh and scp without entering password. This article explains how to setup SSH key based authentication between different version of SSH (from openSSH to SSH2) to perform ssh and scp without entering password.

1. Verify the local-host and remote-host SSH version.

In this example, local-host is running on openSSH and remote-host is running on SSH2.

[local-host]$ ssh -V
OpenSSH_5.0p1, OpenSSL 0.9.8g 19 Oct 2007
 
[remote-host]$ ssh -V
ssh: SSH Secure Shell 3.2.9.1 (non-commercial version) on i686-pc-linux-gnu
[remote-host]$ ls -l /usr/local/bin/ssh
lrwxrwxrwx  1 root root 4 Mar 10 22:04 /usr/local/bin/ssh -> ssh2

2. Generate key-pair on the local-host using ssh-keygen

[local-host]$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/jsmith/.ssh/id_rsa):<Hit enter>
Enter passphrase (empty for no passphrase): <Enter your passphrase here>
Enter same passphrase again:<Enter your passphrase again>
Your identification has been saved in /home/jsmith/.ssh/id_rsa.
Your public key has been saved in /home/jsmith/.ssh/id_rsa.pub.
The key fingerprint is:
3b:2a:d2:ac:8c:71:81:7e:b7:31:21:11:b8:e8:31:ad jsmith@local-host

The public key and private key are typically stored in .ssh folder under your home directory. In this example, it is under /home/jsmith/.sshd. You should not share the private key with anybody.

By default the ssh-keygen on openSSH generates RSA key pair. You can also generate DSA key pair using: ssh-keygen -t dsa command.

3.  Convert openSSH public key to SSH2 public key.

On local-host that is running openSSH, convert the openSSH public key to SSH2 public key using ssh-keygen as shown below.

[local-host]$ ssh-keygen -e -f ~/.ssh/id_rsa.pub > ~/.ssh/id_rsa_ssh2.pub

4. Install the public-key on the remote-host that is running SSH2.

Create a new public key file on remote-host and copy paste the converted SSH2 key from the local-host.

[remote-host]$ vi ~/.ssh2/local-host_ssh2_key.pub 
---- BEGIN SSH2 PUBLIC KEY ----
Comment: "2048-bit RSA, converted from OpenSSH by jsmith@local-host"
DDDDB3NzaC1yc2EAAAABDmbrdomPh9rWfjZ1+7Q369zsBEa7wS1RxzWRQ0Bmr9FSplI
3ADBEBC/6cbdf/v0r6Cp5y5kusP07AOzo2F7MBDSZBtS/MbYJiIxvocoaxG2bQyz3yYjU
YcpzGMD182bnA8kRxmGg+R5pVXM34lx3iSSgd8r3RzZKnDpEvEInnI7pQvUBoEbYCXPUeZ
LQvQAkz6+Pb6SsNp-dop/qgv9qyfbyMz1iKUZGadG146GtanL5QtRwyAeD187gMzzrGzMFP
LWjdzWpGILdZ5gq7wwRpbcXFUskVrS2ZjDe676XlTN1k5QSZmSYUuttDdrjB5SFiMpsre8
a7cQuMS178i9eDBEC==
---- END SSH2 PUBLIC KEY ----

Add the above public key file name to the authorization file on the remote-host as shown below.

[remote-host]$ vi ~/.ssh2/authorization
Key local-host_ssh2_key.pub

5. Verify the Login from the local-host to remote-host using the SSH2 key authentication.

[local-host]$ ssh -l jsmith remote-host <You are on local-host here>

The authenticity of host 'local-host' can't be established.

DSA key fingerprint is a5:f6:2e:e6:a9:b2:7b:0e:e7:ae:cb:6c:7b:f5:6d:06.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added 'local-host' (DSA) to the list of known hosts.

Enter passphrase for key '/home/jsmith/.ssh/id_rsa': <Enter your passphrase here>

Last login: Sat Jun 21 2008 23:13:00 -0700 from 192.168.1.102

No mail.

[remote-host]$ <You are on remote-host here>

There are two ways to perform ssh and scp without entering the password:

1.    No passphrase. While creating key pair, leave the passphrase empty. Use this option for the automated batch processing. for e.g. if you are running a cron job to copy files between machines this is suitable option. You can skip the next step steps for this method.

2.    Use passphrase and SSH Agent. If you are using ssh and scp interactively from the command-line and you don’t want to use the password everytime you perform ssh or scp, I don’t recommend the previous option (no passphrase), as you’ve eliminated one level of security in the ssh key based authentication. Instead, use the passphrase while creating the key pair and use SSH Agent to perform ssh and scp without having to enter the password everytime as explained in the steps below.

6. Start the SSH Agent on local-host

The SSH Agent will be running in the background to hold the private keys and perform ssh and scp without having to enter the passphrase several times.

[local-host]$ ssh-agent $SHELL

7. Load the private key to the SSH agent on the local-host.

[local-host]$ ssh-add

Enter passphrase for /home/jsmith/.ssh/id_rsa:<Enter your passphrase here>

Identity added: /home/jsmith/.ssh/id_rsa (/home/jsmith/.ssh/id_rsa)

8. Perform SSH or SCP to remote-home from local-host without entering the password.

[local-host]$<You are on local-host here>

 

[local-host]$ ssh -l jsmith remote-host

Last login: Sat Jun 07 2008 23:03:04 -0700 from 192.168.1.102

No mail.

<ssh did not ask for passphrase this time>

[remote-host]$ <You are on remote-host here>

 

Install Apache 2 from Source on Linux


All Linux distributions comes with Apache. However, it is recommended to download latest Apache source code, compile and install on Linux. This will make it easier to upgrade Apache on a ongoing basis immediately after a new patch or release is available for download from Apache. This article explains how to install Apache2 from source on Linux.

1. Download Apache

Download the latest version from Apache HTTP Server Project . Current stable release of Apache is 2.2.9. Move the source to /usr/local/src and extract it as shown below.

# cd /usr/local/src
# gzip -d httpd-2.2.9.tar.gz
# tar xvf httpd-2.2.9.tar

2. Install Apache

View all configuration options available for Apache using ./configure –help (two hyphen in front of help). The most commonly used option is –prefix={install-dir-name} to install Apache on a user defined directory.

# cd httpd-2.2.9
# ./configure --help

In the following example, Apache will be compiled and installed to the default location /usr/local/apache2 with the DSO capability. Using the –enable-so option, you can load modules to Apache at runtime via the Dynamic Shared Object (DSO) mechanism, rather than requiring a recompilation.

# ./configure --enable-so
# make
# make install

Note: During the ./configure, you may get the following error message.

# ./configure --enable-so
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details.
configure failed for srclib/apr

Install the gcc and the dependent modules as shown below and try ./configure again to fix the above issue.

# rpm -ivh gcc-4.1.2-14.el5.i386.rpm glibc-devel-2.5-18.i386.rpm glibc-headers-2.5-18.i38
6.rpm kernel-headers-2.6.18-53.el5.i386.rpm
Preparing...                ########################################### [100%]
1:kernel-headers         ########################################### [ 25%]
2:glibc-headers          ########################################### [ 50%]
3:glibc-devel            ########################################### [ 75%]
4:gcc                    ########################################### [100%]

3. Start Apache and verify installation

# cd /usr/local/apache2/bin
# ./apachectl start

Go to http://local-host, which should display the default message “It Works!”

4. Start Apache automatically during system startup

Modify the /etc/rc.d/init.d/httpd script and change apachectl and httpd variable to point to the appropriate new location as shown below. Please note that this httpd script was originally installed as part of the default Apache from the Linux distribution.

apachectl=/usr/local/apache2/bin/apachectl
httpd=${HTTPD-/usr/local/apache2/bin/httpd}

Now, you can perform the following to stop and start the Apache

# service httpd stop
# service httpd start

Setup the Apache to automatically startup during reboot as shown below.

# chkconfig --list httpd
httpd           0:off   1:off   2:off   3:off   4:off   5:off   6:off
# chkconfig --level 2345 httpd on
# chkconfig --list httpd
httpd           0:off   1:off   2:on    3:on    4:on    5:on    6:off

 

Reduce Keystrokes using AutoHotKey for Windows- Productivity Tip



For geeks to be more productive, using keyboards as much as possible is a must. AutoHotKey for windows is an excellent tool that can automate repetitive typing. Using scripting in AutoHotKey, you can pretty much perform any activities on Windows. This is a jumpstart guide to get you started on the AutoHotKey.

Install and Configure

1.    Download the AutoHotKey and install using the default options.

2.    Launch the AutoHotKey, which will display a dialog confirming that a sample script file will be created.  Click on “Yes” to create the sample AutoHotkey.ahk in the My Documents folder. Later if you want to create a script file under a different directory, from the Windows Explore menu click on File -> New -> AutoHotKey Script.

3.    Make sure AutoHotKey is running in the windows task bar. You can also open the AutHotKey.ahk script by right-mouse click on the AutoHotKey icon from the system tray and select “Edit this script”.

4.    Anytime you make changes to the AutoHotkey.ahk, you need to Reload the script by right-mouse click on the AutoHotKey icon on the system tray and select “Reload this script”.

Basic Usage of AutoHotKey

(1)  Email Signature. Add the following two lines to the AutoHotKey.ahk and reload the script as explained above. For testing, open notepad and type -rn, which will be automatically replaced with the full name “Ramesh Natarajan” as defined in the *.ahk file.  Comments in the AutoHotkey.ahk begins with semi-colon.

; tip#1 - Type long names quickly
::-rn::Ramesh Natarajan

(2) Email Signature with multiple lines. In this example, typing “rtgs” from my email message will add the multiple-line content located within the parenthesis ( ). It is important to choose a keyword that you can easily remember and not common words that could potentially be replaced automatically by mistake.

; tip#2 - My personal email signature with the URL
::rtgs::
(
Ramesh
<a href="http://www.thegeekstuff.com">The Geek Stuff</a>
)

(3) Current Date and Time: When you are taking notes in a textpad, sometimes it may be a good idea to put the current date and time before you start taking notes. In the following example, when you type “ndate” from the notepad, it will add the current date and time in the format mentioned below.

; tip#3 - Adding the timestamp quickly while taking notes
:*:ndate::
FormatTime, CurrentDateTime,, M/d/yyyy h:mm tt  ; It will look like 6/29/2008 10:35 AM
SendInput %CurrentDateTime%
return

(4) Open a website in a browser: Sometime it may be necessary to open your frequently used website with a single key stroke. In the following example, typing “Windows” key + “t” will open the default web browser and launch www.thegeekstuff.com. Please note that “#” in the following line represents the “Windows” key in the keyboard.

; tip#4 - Open frequently used website
#t::Run www.thegeekstuff.com

(5) Open frequently used folder by pressing “Windows” key + “p”.

; tip#5 - Open frequently used folder
#p::Run "C:\my-project\projectplan"

(6) Open frequently used document by pressing “Windows” key + “c”

; tip#6 - Open frequently used document
#c::Run open "C:\my-project\documents\codedesign.doc"

(7) Advanced scripting. In the following example, you can select any text from any application and press “Control+Alt+w”, which will open the Notepad++ application and paste the selected text.

; tip#7 - Advanced scripting
^!w::
Send, ^c
SetWorkingDir, %ProgramFiles%\WordNet\Notepad++\
Run, notepad++.exe
WinWait, Notepad++
WinActivate
Send, ^v{Enter}
return