Tuesday, 4 February 2014

Advantages of using Ubuntu instead of Windows

"Do what you want, but don't restrict for others the freedoms you have received."

I am Ubuntu User from last 6 years, I have very good experience with Ubuntu. I was handy with Windows OS. When i shifted to ubuntu i was facing very few issues and i resolved within a week. After that i am using ubuntu non stop.

I never try again windows and not even feel to use it again. I feel freedom from license software and enjoy the good world of freedom.

Runs very smoothly even on my Atom n450/2GB netbook; Genuine Windows 7 home basic (pre-loaded) is very sluggish, and nearly unusable at times.

Extremely capable and extremely powerful for those who are not command-line phobic. It's powerful anyway, but you can reach new realms of possibilities with the command line.

Pro: Its faster, its free, it has 1000s of free software, easy to customize, a lot of different Ubuntu biased Operating systems to choose from, Ubuntu, Kubuntu, Xubuntu, Lubuntu, Edubuntu.
 
Cons: Not great for gaming, can run Windows software under "Wine" but some programs might not work, or might have problems. (But Linux has an alternative software).

So i will suggest every one to use the freedom world.

Good Luck.

Friday, 29 June 2012

error: Directory index forbidden by Options directive:

#[root@localhost ]# tail -f /var/log/httpd/error_log
In apache error log I got following error.
[Wed Oct 07 15:59:50 2008] [error] [client 127.0.0.1] Directory index forbidden by Options directive: /var/www/html/testfolder/
I changed the AllowOverride option but nothing is happend. Then I read the welcome page text
“To prevent this page from ever being used, follow the instructions in the file /etc/httpd/conf.d/welcome.conf.”
I opend the welcome.conf file.
I found following lines in welcome.conf file.
<LocationMatch “^/+$”>
Options -Indexes
ErrorDocument 403 /error/noindex.html
</LocationMatch>

I changed that to as follows:
<LocationMatch “^/+$”>
Options Indexes
ErrorDocument 403 /error/noindex.html
</LocationMatch>

That solve my problem. Some time your selinux will cause the issue so you need to deactivate the selinux.
Some time File permission will also cause the issue.
You can change the file permission using following command, go to that directory and run following command.
#chmod 777 *

Saturday, 16 June 2012

Verifying Which Ports Are Listening centos

1: access your server and type the commands

nmap -sT -O localhost
 
 
if nmap is not installed then first installed the nmap utility and then run the command again
 
yum install nmap


2: cat /etc/services | grep 834
 
3: netstat -anp | grep 4444
 
4: lsof -i | grep 834
 
hope this will help some one. 


regards:
imran 
CTO www.wdnec.com

Friday, 8 June 2012

Update an old debian: 404 Not Found; Err http://us.archive.ubuntu.com; Failed to fetch

Today I stumbled into a weird problem. My debian server 5 couldn't update anymore. My /etc/apt/sources.list looked like this:
  deb-src http://archive.ubuntu.com/ubuntu/  main restricted universe multiverse
Running apt-get update gave all sorts of problems as it couldn't find repository servers anymore:
  $ sudo apt-get update
  Ign http://us.archive.ubuntu.com  Release.gpg
  Ign http://us.archive.ubuntu.com  Release
  Ign http://us.archive.ubuntu.com /main Packages
  Ign http://us.archive.ubuntu.com /universe Packages
  Ign http://us.archive.ubuntu.com /main Packages
  Ign http://us.archive.ubuntu.com /universe Packages
  Err http://us.archive.ubuntu.com /main Packages
    404 Not Found [IP: 91.189.92.180 80]
  Err http://us.archive.ubuntu.com jaunty/universe Packages
    404 Not Found [IP: 91.189.92.180 80]
  W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/main/
    404 Not Found [IP: 91.189.92.180 80]

  W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/jaunty/universe/Packages
    404 Not Found [IP: 91.189.92.180 80]

  E: Some index files failed to download, they have been ignored, or old ones used instead.
To upgrade a really old Debian release, we first need to edit our sources.list and change all (xx.)archive.ubuntu.com to old-releases.ubuntu.com.
   $ sudo emacs /etc/apt/sources.list
So your lines should instead of
   deb http://archive.ubuntu.com/ubuntu jaunty main restricted universe
look like
   deb http://old-releases.ubuntu.com/ubuntu main restricted universe
it works the same on other releases.
Now update the repos
   $ sudo apt-get update
Thanks to Matjaž Kljun for guiding to the solution.

Regards:
Imran shahmeer

Monday, 4 June 2012

Wired Vs Wireless LAN Pro & Cons.


Computer networks for the home and small business can be built using either wired or wireless technology.
Wired Ethernet has been the traditional choice in homes, but Wi-Fi wireless technologies are gaining ground fast.
Below we compare wired and wireless networking in five key areas:

ease of installation
total cost
reliability
performance
security

About Wired LANs:
Wired LANs use Ethernet cables and network adapters. Although two computers can be directly wired to each other using an Ethernet crossover cable, wired LANs generally also require central devices like hubs, switches, or routers to accommodate more computers.

Installation

Ethernet cables must be run from each computer to another computer or to the central device. It can be time-consuming and difficult to run cables under the floor or through walls, especially when computers sit in different rooms. Some newer homes are pre-wired with CAT5 cable, greatly simplifying the cabling process and minimizing unsightly cable runs.
The correct cabling configuration for a wired LAN varies depending on the mix of devices, the type of Internet connection, and whether internal or external modems are used. However, none of these options pose any more difficulty than, for example, wiring a home theater system.

Cost:
Ethernet cables, hubs and switches are very inexpensive. Some connection sharing software packages, like ICS, are free; some cost a nominal fee. Broadband routers cost more, but these are optional components of a wired LAN, and their higher cost is offset by the benefit of easier installation and built-in security features.

Reliability:
Ethernet cables, hubs and switches are extremely reliable, mainly because manufacturers have been continually improving Ethernet technology over several decades. Loose cables likely remain the single most common and annoying source of failure in a wired network. When installing a wired LAN or moving any of the components later, be sure to carefully check the cable connections.

Performance:
Wired LANs offer superior performance. Traditional Ethernet connections offer only 10 Mbps bandwidth, but 100 Mbps Fast Ethernet technology costs little more and is readily available. Although 100 Mbps represents a theoretical maximum performance never really achieved in practice, Fast Ethernet should be sufficient for home file sharing, gaming, and high-speed Internet access for many years into the future.

Security

For any wired LAN connected to the Internet, firewalls are the primary security consideration. Wired Ethernet hubs and switches do not support firewalls. However, firewall software products like ZoneAlarm can be installed on the computers themselves. Broadband routers offer equivalent firewall capability built into the device, configurable through its own software.

Wireless LANs

Popular WLAN technologies all follow one of the three main Wi-Fi communication standards. The benefits of wireless networking depend on the standard employed:

Installation

Wi-Fi networks can be configured in two different ways:
"Ad hoc" mode allows wireless devices to communicate in peer-to-peer mode with each other.
"Infrastructure" mode allows wireless devices to communicate with a central node that in turn can communicate with wired nodes on that LAN.
Most LANs require infrastructure mode to access the Internet, a local printer, or other wired services, whereas ad hoc mode supports only basic file sharing between wireless devices.

Both Wi-Fi modes require wireless network adapters, sometimes called WLAN cards. Infrastructure mode WLANs additionally require a central device called the access point. The access point must be installed in a central location where wireless radio signals can reach it with minimal interference. Although Wi-Fi signals typically reach 100 feet (30 m) or more, obstructions like walls can greatly reduce their range.

Cost:

Wireless gear costs somewhat more than the equivalent wired Ethernet products. At full retail prices, wireless adapters and access points may cost three or four times as much as Ethernet cable adapters and hubs/switches, respectively. 802.11b products have dropped in price considerably with the release of 802.11g, and obviously, bargain sales can be found if shoppers are persistent.

Reliability

Wireless LANs suffer a few more reliability problems than wired LANs, though perhaps not enough to be a significant concern. 802.11b and 802.11g wireless signals are subject to interference from other home applicances including microwave ovens, cordless telephones, and garage door openers. With careful installation, the likelihood of interference can be minimized.

Performance

Wireless LANs using 802.11b support a maximum theoretical bandwidth of 11 Mbps, roughly the same as that of old, traditional Ethernet. 802.11a and 802.11g WLANs support 54 Mbps, that is approximately one-half the bandwidth of Fast Ethernet. Furthermore, Wi-Fi performance is distance sensitive, meaning that maximum performance will degrade on computers farther away from the access point or other communication endpoint. As more wireless devices utilize the WLAN more heavily, performance degrades even further.
Overall, the performance of 802.11a and 802.11g is sufficient for home Internet connection sharing and file sharing, but generally not sufficient for home LAN gaming.

Security

In theory, wireless LANs are less secure than wired LANs, because wireless communication signals travel through the air and can easily be intercepted.
WLANs protect their data through the Wired Equivalent Privacy (WEP) encryption standard, that makes wireless communications reasonably as safe as wired ones in homes.
No computer network is completely secure and homeowners should research this topic to ensure they are aware of and comfortable with the risks. Important security considerations for homeowners tend to not be related to whether the network is wired or wireless but rather ensuring:

the home's Internet firewall is properly configured
the family is familiar with the danger of Internet "spoof emails" and how to recognize them
the family is familiar with the concept of "spyware" and how to avoid it.
babysitters, housekeepers and other visitors do not have unwanted access to the network

Thanks & Regards:
Imran Shahmeer
skype : shahmeer07

Wednesday, 30 May 2012

To password protect your website make it private



To password protect your website, please follow these steps:

Log into your Linux web server via Secure Shell (SSH).
Change into the directory you wish to password protect.
Note: If you wish to protect your entire website us the following command:
1:cd /vservers/username/htdocs
2:Create a file called .htaccess using the following command:
pico .htaccess
3:Enter the following information:
AuthType Basic
AuthName "Please enter your Username and Password"
AuthUserFile /vservers/username/htdocs/.htpasswd
AuthGroupFile /dev/null
Require valid-user

4:Press ctrl+o to save the file.
5:Press ctrl+x to exit the file.
6:Create the .htpasswd file using the following command:
/usr/bin/htpasswd -c /vservers/username/htdocs/.htpasswd username
7:Enter the password you wish to use.
8:Re-enter the password.
9:Grant read access to each file using the following commands:
chmod a+r .htaccess
chmod a+r .htpasswd


Password protection by a single login:
Password files:

Create the directory you want to password protect (example: membersonly)
Create a file /home/domain/public_html/membersonly/.htaccess in that director that looks something like this:

     AuthName "Add your login message here."
     AuthType Basic
     AuthUserFile /home/domain/public_html/membersonly/.htpasswd
     AuthGroupFile /dev/null
     require user name-of-user
                   
In this case the "name-of-user" is the login name you wish to use for accessing the web site.
One can use Apache directives to specify access and restriction:
AuthName "Add your login message here."
     AuthType Basic
     AuthUserFile /home/domain/public_html/membersonly/.htpasswd
     AuthGroupFile /dev/null
     <Limit GET POST>
     require user name-of-user
     </Limit>

The name of the access file .htaccess is specified by the httpd.conf directive AccessFileName.
Create (or clobber if it already exists) the password file /home/domain/public_html/membersonly/.htpasswd using the program htpasswd:
         htpasswd -c .htpasswd name-of-user
         
Add a new user to the existing password file:
         htpasswd .htpasswd name-of-user
         
Man page: htpasswd
Example file: .htpasswd

user1:KgvCSeExtS4kM
USER1:KgvCSeExtS4kM
User1:KgvCSeExtS4kM

Placing Authentication directives in httpd.conf exclusively instead of using .htaccess:
The purpose of using the "distributed configuration file" .htaccess is so that users may control authentication. It can also be set in the Apache configuration file httpd.conf WITHOUT using the .htaccess file. This can improve server performance as the server will not have to look for the .htaccess file in each subdirectory.
File: httpd.conf (portion)
..
    ...

     <Directory /home/domain/public_html/membersonly>
     AllowOverride AuthConfig
     AuthName "Add your login message here."
     AuthType Basic
     AuthUserFile /home/domain/public_html/membersonly/.htpasswd
     AuthGroupFile /dev/null
     require user name-of-user
     </Directory>

    ...
    ..
</VirtualHost>

how to access through ssh amazon instance from ubuntu machine.


how to ssh amazon instance from ubuntu.

if you have the private key file of your amazon instance then its very easy to connect through ssh.

if you don't have the keys then login to your amazon interface instance and create the key instance.pem and instance.ppk

when you creat these both keys then download it you system. and saved it.

One key .pem is used for linux connectivity and .ppk is used for windows putty connectivity.

In ubuntu OS open your terminal and get the sudo rights.

Alt+Ctrl+T then type the command
sudo -s
your password:

go to your donwload folder and copy the keys to /home/yourname/.shh/ folder

cd /home/myname/Download/

cp instance.pem instance.ppk /home/myname/.shh

trach out your amazon host name like bitnami and type the command in terminal

shh -i instance.pem user@your.instance.amzon.com

you will get connected.

if you get the error

permission denied due to the public key is onpen to others. then change the permission of .pem file

chmod 600 instance.pem and again try to connect to server instance.

this time you will connected if you have right usernam and .pem key.

That's all
if you have any other question feel free to ask me

Regards:
imran 
shahmeer07 @skype

protect your directory with .htaccess and .htpasswd username and password


Do you want to password protect a directory on your website?

Lets suppose you want to protect the folder ‘secretfolder’ located on this path on your server:  home/user/domain/secretfolder

Password Protect Directory with htaccess
Step 1 – Create .htpasswd file with your desired username and password in any text editor (like Notepad) and save.
within the .htpasswd you will have the following info

abc:9476nIHW7Esgw

encrypt you password through some tool and put that here with username you can that from from here
http://www.4webhelp.net/us/password.php

Step 2 – Create .htaccess file with the code below. It can be created using any text editor (like Notepad) and saved without the .txt extension.

vim .htaccess

AuthUserFile /home/user/domain/secretfolder/.htpasswd # please the location of .htpasswd file should be known to you. if not don't wast your time.
AuthType Basic
AuthName "Login Details"
Require valid-user

Step 3 – Upload both these files in the same folder which you want to protect
Now whenever anyone accesses that directory or any files in it, they will be asked for login details. You web directory is now secure.


That's it

Enjoy your Security at layer 1.

Regards:
imran
skype: shahmeer07

daily used command in linux server maintenance


pwd
Print working directory, i.e., display the name of my current directory on the screen.
hostname
Print the name of the local host (the machine on which I am working). Use netconf (as root) to change the name of the machine.

whoami
Print my login name.

id username
Print user id (uid) and his/her group id (gid), effective id (if different than the real id) and the supplementary groups.

date
Print the operating system current date, time and timezone. For an ISO standard format, I have to use: date -Iseconds
I can change the date and time to 2000-12-31 23:57 using this command: date 123123572000
or using these two commands (easier to remember):
date --set 2000-12-31
date --set 23:57:00
To set the hardware (BIOS) clock from the system (Linux) clock, I can use the command (as root): setclock

The international (ISO 8601) standard format for all-numeric date/time has the form: 2001-01-31 (as in Linux default "C" localization). You can be more precise if you wish using, for example: 2001-01-31 23:59:59.999-05:00 (representing I milisecond before February 2001, in a timezone which is 5 hours behind the Universal Coordinated Time (UTC)) . The most "kosher" representation of the same point in time could be: 20010131T235959,999-0500. See the standard at ftp://ftp.qsl.net/pub/g1smd/8601v03.pdf.
time
Determine the amount of time that it takes for a process to complete + other process accounting. Don't confuse it with the date command (see previous entry). E.g. I can find out how long it takes to display a directory content using: time ls. Or I can test the time function with time sleep 10 (time the commands the does nothing for 10 seconds).
clock
hwclock
(two commands, use either). Obtain date/time from the computer hardware (real time, battery-powered) clock. You can also use one of this commands to set the hardware clock, but setclock may be simplier (see 2 commands above). Example: hwclock --systohc --utc sets the hardware clock (in UTC) from the system clock.

who
Determine the users logged on the machine.

w
Determine who is logged on the system, find out what they are doing, their processor ussage, etc. Handy security command.

rwho -a
(=remote who) Determine users logged on other computers on your network. The rwho service must be enabled for this command to run. If it isn't, run setup (RedHat specific) as root to enable "rwho".

finger user_name
System info about a user. Try: finger root . One can use finger with any networked computer that exposes the finger service to the world, e.g., I can do (try): finger @finger.kernel.org

last
Show listing of users last logged-in on your system. Really good idea to check it from time to time as a security measure on your system.

lastb
("=last bad") Show the last bad (unsuccessful) login attempts on my system. It did not work on my system, so got it started with: touch /var/log/btmp

"There's a good reason why /var/log/btmp isn't available on any sane set-up - it's a world-readable file containing login mistakes. Since one of the most common login mistakes is to type the password instead of the username, /var/log/btmp is a gift to crackers." (Thanks to Bruce Richardson). It appears the problem can be solved by changing the file permissions so only root can use "lastb":
chmod o-r /var/log/btmp
history | more
Show the last (1000 or so) commands executed from the command line on the current account. The "| more" causes the display to stop after each screenful. To see what another user was doing on your system, login as "root" and inspect his/her "history". The history is kept in the file .bash_history in the user home directory (so yes, it can be modified or erased).
uptime
Show the amount of time since the last reboot.

ps
(="print status" or "process status") List the processes currently run by the current user.

ps axu | more
List all the processes currently running, even those without the controlling terminal, together with the name of the user that owns each process.

top
Keep listing the currently running processes on my computer, sorted by cpu usage (top processes first). Press c when done.

PID = process identification.
USER=name of the user who owns (started?) the process.
PRI=priority of the process (the higher the number, the lower the priority, normal 0, highest priority is -20, lowest 20.
NI=niceness level (i.e., if the process tries to be nice by adjusting the priority by the number given). The higher the number, the higher the niceness of the process (i.e., its priority is lower).
SIZE=kilobytes of code+data+stack taken by the process in memory.
RSS=kilobytes of physical (silicon) memory taken.
SHARE=kilobytes of memory shared with other processes.
STAT=state of the process: S-sleeping, R-running, T-stopped or traced, D-uniterruptable sleep, Z=zombie.
%CPU=share of the CPU usage (since last screen update).
%MEM=share of physical memory.
TIME=total CPU time used by the process (since it was started).
COMMAND=command line used to start the task (careful with passwords, etc., on command line, all permitted to run "top" may see them!
gtop
ktop
(in X terminal) Two GUI choices for top. My favourite is gtop (comes with gnome). In KDE, ktop is also available from the "K"menu under "System"-"Task Manager".
uname -a
(= "Unix name" with option "all") Info on your (local) server. I can also use guname (in X-window terminal) to display the info more nicely.

XFree86 -version
Show me the version of X windows I have on my system.

cat /etc/issue
Check what distribution you are using. You can put your own message in this text file--it's displayed on login. It is more common to put your site-specific login message to the file /etc/motd ("motd"="message of the day").

free
Memory info (in kilobytes). "Shared" memory is the memory that can be shared between processes (e.g., executable code is "shared"). "Buffered" and "cashed" memory is the part that keeps parts of recently accessed files--it can be shrunk if more memory is needed by processes.

df -h
(=disk free) Print disk info about all the filesystems (in human-readable form).

du / -bh | more
(=disk usage) Print detailed disk usage for each subdirectory starting at the "/" (root) directory (in human legible form).

cat /proc/cpuinfo
Cpu info--it shows the content of the file cpuinfo. Note that the files in the /proc directory are not real files--they are hooks to look at information available to the kernel.

cat /proc/interrupts
List the interrupts in use. May need to find out before setting up new hardware.

cat /proc/version
Linux version and other info.

cat /proc/filesystems
Show the types of filesystems currently in use.

cat /etc/printcap |more
Show the setup of printers.

lsmod
(= "list modules". As root. Use /sbin/lsmod to execute this command when you are a non-root user.) Show the kernel modules currently loaded.

set|more
Show the current user environment (in full). Normally too much to bother.

echo $PATH
Show the content of the environment variable "PATH". This command can be used to show other environment variables as well. Use set to see the full environment (see the previous command).

dmesg | less
Print kernel messages (the content of the so-called kernel ring buffer). Press "q" to quit "less". Use less /var/log/dmesg to see what "dmesg" dumped into this file right after the last system bootup.

chage -l my_login_name
See my password expiry information.

quota
See my disk quota (the limits of disk usage).

sysctl -a |more
Display all the configurable Linux kernel parameters.

runlevel
Print the previous and current runlevel. The output "N5" means: "no previous runlevel" and "5 is the current runlevel". To change the runlevel, use "init", e.g., init 1 switches the system to a single user mode.

Runlevel is the mode of operation of Linux. Runlevel can be switched "on the fly" using the command init. For example, init 3 (as root) will switch me to runlevel 3. The following runlevels are standard:
0 - halt (Do NOT set initdefault to this)
1 - Single user mode
2 - Multiuser, without NFS (The same as 3, if you do not have networking)
3 - Full multiuser mode
4 - unused
5 - X11
6 - reboot (Do NOT set initdefault to this)
The system default runlevel is set in the file: /etc/inittab .
sar
View information extracted the system activity log file (/var/log/sarxx where xx is the current day number). sar can extract many kinds of system statistics including CPU load averages, i/o statistics, and network trafic statistics for the current day and (usually) several days backs.


Enjoy! 
comment if you have some good commands.

Regards:
imran shahmeer

custom commands linux centos

Find How Much Disk Space Is Being Used Show Display

#cd /var/
#du -hc --max-depth=1
#du -sh

how to show all repos
yum repolist all

how to clear cache of the server::
yum clean all

shwo installed version of the.

yum list installed | grep gd


how to install ftp server vsftpd and configure on centos


 yum list installed | grep ftp
 1083  yum install vsftpd
 1084  chkconfig vsftpd on
 1085  service vsftpd start

creat group
   groupadd ftp-users
   chown root:ftp-users /var/www/html/

adduser to ftp group 
  useradd -g ftp-users -d /var/www/html/ imran
create password for user.

 passwd imran

how to change password of ftp user.
  passwd imran
 enter new password;
 retype password: 

how to restrict and lock ftp user when not needed

passwd -l username{ftp user}

how to unlock the ftp user when needed

passwd +l username {ftp user}

Tuesday, 24 April 2012

how to install php53-mcrypt on centos

To install manually php53-mcrypt on your server follow the steps below,

when you are facing the issue of conflict then these steps will help you to resolve the issue.


First install some required packages:
yum install php53-devel libmcrypt-devel gcc gcc-c++
Then download the php 5.3.6 source code from php.net and unpack it:
wget http://mx2.php.net/get/php-5.3.6.tar.bz2/from/us3.php.net/mirror
tar xvjf php-5.3.6.tar.bz2
(Please note that the download link will change with every subsequent PHP release.)
Go to the directory with the mcrypt extension source code and compile:
cd php-5.3.6/ext/mcrypt/
phpize
aclocal
./configure
make
Then install:
make install
Create the configuration file for PHP /etc/php.d/mcrypt.ini containing:
extension=mcrypt.so
Restart apache:
/etc/init.d/httpd restart
Create a file with phpinfo just to check if the extension was loaded:
<?php
phpinfo();
?>
postgresql: Error connections  limit exceeded for nonsuper users.
to check how much connections are there.

try netstat -an|grep 5432

Wednesday, 4 April 2012

installing Mysql-server mysql Table 'mysql.servers' doesn't exist

This should solve the problem. Not sure how this problem started for me but I have used the below query and its eliminated the error.

CREATE TABLE `servers` (
`Server_name` char(64) NOT NULL,
`Host` char(64) NOT NULL,
`Db` char(64) NOT NULL,
`Username` char(64) NOT NULL,
`Password` char(64) NOT NULL,
`Port` int(4) DEFAULT NULL,
`Socket` char(64) DEFAULT NULL,
`Wrapper` char(64) NOT NULL,
`Owner` char(64) NOT NULL,
PRIMARY KEY (`Server_name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='MySQL Foreign Servers table';

Regards:
Imran

Friday, 30 March 2012

How to install php-5.2.17 on CentOS-6.2 and configure Zend optimizer-3.3

To install php-5.2.17 on CentOS-6.2 and configure Zend optimizer.
Follow the procedure carefully.
ssh user@sever
password:


Cd /usr/src
wget http://
php-5.2.17-1.el6.art.x86_64.rpm
php-bcmath-5.2.17-1.el6.art.x86_64.rpm
php-cli-5.2.17-1.el6.art.x86_64.rpm
php-common-5.2.17-1.el6.art.x86_64.rpm
php-dba-5.2.17-1.el6.art.x86_64.rpm
php-devel-5.2.17-1.el6.art.x86_64.rpm
php-embedded-5.2.17-1.el6.art.x86_64.rpm
php-gd-5.2.17-1.el6.art.x86_64.rpm
php-imap-5.2.17-1.el6.art.x86_64.rpm
php-ldap-5.2.17-1.el6.art.x86_64.rpm
php-mbstring-5.2.17-1.el6.art.x86_64.rpm
php-mcrypt-5.2.17-1.el6.art.x86_64.rpm
php-mhash-5.2.17-1.el6.art.x86_64.rpm
php-mssql-5.2.17-1.el6.art.x86_64.rpm
php-mysql-5.2.17-1.el6.art.x86_64.rpm
php-pdo-5.2.17-1.el6.art.x86_64.rpm
php-soap-5.2.17-1.el6.art.x86_64.rpm

................................................
rpm -ivh --nodeps php-5.2.17-1.el6.art.x86_64.rpm
php-bcmath-5.2.17-1.el6.art.x86_64.rpm
php-cli-5.2.17-1.el6.art.x86_64.rpm
php-common-5.2.17-1.el6.art.x86_64.rpm
php-dba-5.2.17-1.el6.art.x86_64.rpm
php-devel-5.2.17-1.el6.art.x86_64.rpm
php-embedded-5.2.17-1.el6.art.x86_64.rpm
php-gd-5.2.17-1.el6.art.x86_64.rpm
php-imap-5.2.17-1.el6.art.x86_64.rpm
php-ldap-5.2.17-1.el6.art.x86_64.rpm
php-mbstring-5.2.17-1.el6.art.x86_64.rpm
php-mcrypt-5.2.17-1.el6.art.x86_64.rpm
php-mhash-5.2.17-1.el6.art.x86_64.rpm
php-mssql-5.2.17-1.el6.art.x86_64.rpm
php-mysql-5.2.17-1.el6.art.x86_64.rpm
php-pdo-5.2.17-1.el6.art.x86_64.rpm
php-soap-5.2.17-1.el6.art.x86_64.rpm
....................................................
/etc/init.d/httpd restart
stoping httpd ok
starting httpd ok

....................................................
cat /etc/yum.conf|grep php
exclude=php*
....................................................

Zendoptimizer
....................................................
wget http://www.zend.com/products/guard/downloads
zindoptimizer 3.3(php-2.5.x linux)
tar -zxvf zedoptimizer-3.3-tar.gz
1. Extract the Zend Optimizer package.

2. Locate the ZendOptimizer.so (Unix) or ZendOptimizer.dll (Windows) file in the directory which
corresponds to your version of PHP (4.3.x, 4.4.x, 5.0.x, 5.1.x, 5.2.x).

2. Add the following line to your php.ini file:
Linux and Mac OS X: zend_extension=
Windows: zend_extension_ts=
Windows non-thread safe: zend_extension=
(*) The Windows non-thread safe binary is only used with Zend Core 2.0.

3. Restart your Web server.

vim /etc/php.ini
zend_extension=

4.php -v

reboot the server.

enjoy

Wednesday, 14 March 2012

Recover MySQL root Password

Recover MySQL root Password


You can recover MySQL database server password with following five easy steps.


Step # 1: Stop the MySQL server process.

Step # 2: Start the MySQL (mysqld) server/daemon process with the --skip-grant-tables option so that it will not prompt for password.

Step # 3: Connect to mysql server as the root user.

Step # 4: Setup new mysql root account password i.e. reset mysql password.

Step # 5: Exit and restart the MySQL server.

Here are commands you need to type for each step (login as the root user):

Step # 1 : Stop mysql service

# /etc/init.d/mysql stop

Output:

Stopping MySQL database server: mysqld.
Step # 2: Start to MySQL server w/o password:

# mysqld_safe --skip-grant-tables &

Output:

[1] 5988
Starting mysqld daemon with databases from /var/lib/mysql
mysqld_safe[6025]: started
Step # 3: Connect to mysql server using mysql client:

# mysql -u root

Output:

Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 4.1.15-Debian_1-log
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>
Step # 4: Setup new MySQL root user password

mysql> use mysql;
mysql> update user set password=PASSWORD("NEW-ROOT-PASSWORD") where User='root';
mysql> flush privileges;
mysql> quit

Step # 5: Stop MySQL Server:

# /etc/init.d/mysql stop

Output:

Stopping MySQL database server: mysqld
STOPPING server from pid file /var/run/mysqld/mysqld.pid
mysqld_safe[6186]: ended
[1]+ Done mysqld_safe --skip-grant-tables
Step # 6: Start MySQL server and test it

# /etc/init.d/mysql start
# mysql -u root -p

Wednesday, 7 March 2012

Apache: Could not bind address to port (make_sock)

Apache: Could not bind address to port (make_sock)
If you’re upgrading server software, or changing your port config, you may accidentally Funk your Wagnalls. You’ll know the error when you try to restart apache.

1:ps -e | grep httpd
21415 ? 00:00:00 httpd
21417 ? 00:00:00 httpd
21418 ? 00:00:00 httpd
21419 ? 00:00:00 httpd
21420 ? 00:00:00 httpd
21421 ? 00:00:00 httpd
21422 ? 00:00:00 httpd
21423 ? 00:00:00 httpd
21424 ? 00:00:00 httpd
21425 ? 00:00:00 httpd


[root@it ~]# kill 21415
[root@it ~]# kill 21415
-bash: kill: (21415) - No such process
[root@it ~]# ps -e | grep httpd
[root@it ~]# service httpd restart
Stopping httpd: [FAILED]
Starting httpd: [ OK ]



2:- ~: sudo /etc/init.d/apache2 start
* Starting web server apache2
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:8080
no listening sockets available, shutting down
Unable to open logs
...fail!

Apache is attempting to listen on port 8080, but cannot because it’s already in use. There are a few reasons why this might be happening.

Port configuration problem
If you have have duplicate Listen entries, Apache will yell at you. Make sure that your apache.conf & ports.conf don’t both include this directive. If it’s only being listed once (see the example ports.conf below), then make sure you didn’t accidentally duplicate your ports.conf somewhere apache would notice.

Listen 8080

#
# Listen 443
#

Another service could be using the port
When I ran into this error, it was because another instance of apache was already running. This next example uses netstat, grep, and kill to root out & fix the problem.

# try to start apache, receive error

~: sudo /etc/init.d/apache2 start
* Starting web server apache2
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:8080
no listening sockets available, shutting down
Unable to open logs
...fail!

# see what's using the port (note that I'm searching for :80, I could also use :8080)

~: sudo netstat -tulpn| grep :80

tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 29004/apache2
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 28964/nginx

# I see that apache2 is using 8080! Kill it!

~: killall -9 apache2

# Let's try again, with success

~: sudo /etc/init.d/apache2 start
* Starting web server apache2
...done.

Remember to dig in and evaluate server problems instead of just rebooting. I rebooted four times before I decided that I must have screwed something up.

Friday, 20 January 2012

how to Install and configure Munin on linux server

The Installation and configuration are listed below
...................................................

Server Monitoring With munin

Munin produces nifty little graphics about nearly every aspect of the server (load average, memory usage, CPU usage, MySQL throughput, eth0 traffic, etc.) without much configuration, whereas monit checks the availability of services like Apache, MySQL, Postfix, Postgresql and takes the appropriate action such as a restart if it finds a service is not behaving as expected. The combination of the two gives you full monitoring: graphics that lets you recognize current or upcoming problems (like "We need a bigger server soon, our load average is increasing rapidly."), and a watchdog that ensures the availability of the monitored services.

Although munin lets you monitor more than one server, we will only discuss the monitoring of the system where it is installed here.

This tutorial is written for RHEL-4, but the configuration should apply to other distributions with little changes as well.

1:Enable The RPMforge Repository

wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm
rpm -Uvh rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm

2:Install And Configure munin

To install munin on RHEL-4, we do this:

yum install munin munin-node

3:Then we create the system startup links for munin and start it:
chkconfig --levels 235 munin-node on
/etc/init.d/munin-node start

Note:if chkconfig is not working from your login then do the following
yourlogin# su -
enter the root password:XXXXXXX
and again apply the chkconfig command you will have that.

4:we must edit the munin configuration file /etc/munin/munin.conf. We want munin to put its output into the directory /var/www/html/domaindirectory(serverweb)/munin, therefore we change the value of htmldir, and we want it to use the name serverweb instead of localhost.localdomain in the HTML output, therefore we replace localhost.localdomain with server1web. Without the comments,

vim /etc/munin/munin.conf

[...]
dbdir /var/lib/munin
htmldir /var/www/html/serverweb/munin
logdir /var/log/munin
rundir /var/run/munin

Where to look for the HTML templates
tmpldir /etc/munin/templates
[...]
a simple host tree
[server1.domain.com] #you domain name
address 127.0.0.1
use_node_name yes
[...]
5:Next we create the directory /var/www/html/serverweb/munin and change its ownership to the user and group munin, otherwise munin cannot place its output in that directory. Then we restart munin:

mkdir -p /var/www/html/serverweb/munin
chown munin:munin /var/www/html/serverweb/munin
/etc/init.d/munin-node restart

6: after a few minuts open your browser and access the link your.domain.com/munin

7: Password-Protect The munin Output Directory (Optional)
Now it is a good idea to password-protect the directory /var/www/html/serverweb/munin unless you want everybody to be able to see every little statistic about your server.

To do this, we create an .htaccess file in /var/www/html/serverweb/munin:

vim /var/www/html/serverweb/munin/.htaccess

AuthType Basic
AuthName "Members Only"
AuthUserFile /var/www/html/serverweb/.htpasswd

require valid-user


8:Then we must create the password file /var/www/html/serverweb/.htpasswd. We want to log in with the username admin, so we do this:
htpasswd -c /var/www/html/serverweb/.htpasswd admin

9:open browser and type http://www.serverweb.com/munin
user name: admin
password: admin

10: Thats all about for x86_64 RHEL-4 server.

Regards & Thanks
Imran Ullah

how to Install and configure Monit on Linux server RHEL

The Installation and configuration details are listed below.
............................................................

Install and Configure Monit on Linux Server for Process Monitoring
Monit is a open source utility for managing and monitoring, processes, files, directories and devices on a Unix system. Monit can perform automatic maintenance and repair and can execute useful actions in error situations.

E.g.
monit can start a process if it does not run,
monit can restart a process if it does not respond,
monit can stop a process if it uses to much resources.

You may use monit to monitor files, directories and devices for changes, such as timestamp changes, checksum changes or size changes.

1. Download the latest monit from rpmforge repository.
For (x86-bit) systems

wget http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/monit-5.2.5-1.el5.rf.x86_64.rpm
rpm -Uvh moit-5.2.5-1.el5.rf.x86_64.rpm

2. Install the monit rpm
rpm -Uvh monit-5.2.5-1.el5.rf.i386.rpm

yum install monit

chkconfig --levels 235 monit on
if chkconfig is unreconizable and installed then enter the command on you terminal and check again it will work.
su - presss enter
chkconfig --levels 235 monit on

3. Configure monit
vi /etc/monit.conf

set daemon 120 # check services at 2-minute intervals
set logfile /var/log/monit/access.log
set mailserver mail.server.local, # primary mailserver
set alert admin@server.local
set httpd port 2812 and
allow localhost # allow localhost to connect to the server and
allow IP.x.x.x # allow client ip address to connect to the server and
allow admin:monit # require user 'admin' with password 'monit'
4. Create /var/monit directory to place id and state
mkdir /var/monit

5. Configure service to be monitor

vim /etc/monit.d/monitrc

check process proftpd with pidfile /var/run/proftpd.pid
start program = "/etc/init.d/proftpd start"
stop program = "/etc/init.d/proftpd stop"
if failed port 21 protocol ftp then restart
if 5 restarts within 5 cycles then timeout

check process sshd with pidfile /var/run/sshd.pid
start program "/etc/init.d/sshd start"
stop program "/etc/init.d/sshd stop"
if failed port 22 protocol ssh then restart
if 5 restarts within 5 cycles then timeout

check process mysql with pidfile /var/run/mysqld/mysqld.pid
group database
start program = "/etc/init.d/mysqld start"
stop program = "/etc/init.d/mysqld stop"
if failed host 127.0.0.1 port 3306 then restart
if 5 restarts within 5 cycles then timeout

check process apache with pidfile /var/run/httpd.pid
group www
start program = "/etc/init.d/httpd start"
stop program = "/etc/init.d/httpd stop"
if failed host www.serverweb.com port 80 protocol http
and request "/monit/token" then restart
if cpu is greater than 60% for 2 cycles then alert
if cpu > 80% for 5 cycles then restart
if totalmem > 500 MB for 5 cycles then restart
if children > 250 then restart
if loadavg(5min) greater than 10 for 8 cycles then stop
if 3 restarts within 5 cycles then timeout

check process postfix with pidfile /var/spool/postfix/pid/master.pid
group mail
start program = "/etc/init.d/postfix start"
stop program = "/etc/init.d/postfix stop"
if failed port 25 protocol smtp then restart
if 5 restarts within 5 cycles then timeout

check process postgresql with pidfile /opt/postgres/data/postmaster.pid
group database
start program = "/etc/init.d/postgresql start"
stop program = "/etc/init.d/postgresql stop"
if failed unixsocket /tmp/.s.PGSQL.5432 protocol pgsql then restart
if failed unixsocket /tmp/.s.PGSQL.5432 protocol pgsql then alert
if failed host localhost port 5432 protocol pgsql then restart
if failed host localhost port 5432 protocol pgsql then alert
if 5 restarts within 5 cycles then timeout

:wq!

6: mkdir /var/www/serverweb/monit
echo "hello" > /var/www/serverweb/monit/token

7:mkdir /var/log/monit

8:Finally, we can start monit:
/etc/init.d/monit start

9: access the web interface www.serverweb.com:2812
username: admin
password: monit

10: you can add the application data to monitor to /etc/monit.d/monitrc
as i have did it in my server.

11: Create a possward for the user to login through web interface root# htpasswd -c /etc/monitpasswd admin

IMPORTANT NOTE
(To configure postgresql server and services you have to follow the steps below).

postgresql support:

Step # 1: Becoming a superuser

You need to login as database super user under postgresql server. Again the simplest way to connect as the postgres user is to change to the postgres unix user on the database server using su command as follows:
su - postgres
Step #3: Now connect to database server

Type the following command
$ psql template1
OR
$ psql -d template1 -U postgres
Output:

Welcome to psql 7.4.16, the PostgreSQL interactive terminal.
Type: \\copyright for distribution terms
\\h for help with SQL commands
\\? for help on internal slash commands
\\g or terminate with semicolon to execute query
\\q to quit
template1=#

Step #4: Add a user called monit

Type the following command to create a user called monit with a password called myPassword

template1=# CREATE USER monit WITH PASSWORD 'myPassword';

Step #5: Add a database called monit

Type the following command

template1=# CREATE DATABASE monit;

Now grant all privileges on database

template1=# GRANT ALL PRIVILEGES ON DATABASE monit to monit;
Type \q to quit:

template1=# \q

Step #6: Test tom user login

In order to login as monit you need to type following commands. Login as monit or use su command:
$ su - monit
$ psql -d monit -U monit

12: 1. Create DB user `root'.
2. Create a database 'root' owned by root. It doesn't need to contain any data.
3. Add these descriptions to pg_hba.conf;

host root root 127.0.0.1/32 trust <= for test via TCP port
local root root ident sameuser <= for test via UNIX socket
now the monit can restart the postgresql if there is any exception occurs in postgresql responding.

13: /etc/ini.d/monit restart

14:open your browser and access the link http://www.severweb.com:2812

That's all about monit installation and configuration

Regards & Thanks
Imran Ullah

How to Install and Configure M/Monit on RHEL X86_64 step by setp

nstallation and configuration procedure are listed below:
..........................................................

M/Monit expand upon Monit's capabilities to provide monitoring and management of all Monit enabled hosts from one easy to use web-interface.
This M/Monit release require Monit 5.2 or later as an agent. Monit can be downloaded from http://mmonit.com/download. See Supported Platforms for the exact OS versions supported by the binaries.

To install M/Monit:

1. First, check that M/Monit is supported on your OS platform

2. Get the latest release from http://mmonit.com/download/

3. Download and unpack the tar.gz file in a directory, any directory will do,
but unpacking in /opt or /usr/local are good choices.

4. Go to the unpacked mmonit- directory

5. Run M/Monit using: ./bin/mmonit

6. Point your Browser to the host where monit is installed (or "localhost"
if running on the same machine), for example: http://localhost:8080/
and login as user "admin" with password "swordfish".

You can run mmonit as any user, including root. It is not necessary to create a standalone account to run mmonit.

7:now do some changes on monit configuration files to connect both the servers.

vim /etc/monit.d/monitrc

add the following entries at the top of every files you want to monitor

set eventqueue basedir /var/monit/ slots 1000
set mmonit http://monit:monit@192.168.1.10:8080/collector
set httpd port 2812 and use address 192.168.1.101
allow localhost
allow 192.168.1.10
allow admin:secret

Assume we have the machines above where M/Monit runs on 192.168.1.10 and listen on port 8080. And Monit runs on 192.168.1.101
and listen on port 2812.

if both are running on the same server then both all the three IP's will be same are you can you can use 127.0.0.1

Note:ISSUE
if you are working on cloud servers they are using private IP addresses, by attempting your server primary live IP you would never going to successfully connect both the servers.

For that you have to ask your service porvider if you don't know your server secondry IP address which is the Private IP. and Put the Private IP Address in line number 2 of the above 6 steps.

In Line 3 put the name of your server serverweb in place of IP address.

Then allow your live IP address to connect through.

8: if you have a firewall then you also have to permit access for port 80 and port 2812 by creating policy, otherwise you will be unable to access your application

9: if you have more than 20 hosts to monitor through M/Monit then you have to change the default sqlite database to Postgresql or Mysql.

setps are listed here but i am using sqlite because i am monitoring not that much hosts.
Setting up M/Monit to use either MySQL or PostgreSQL is a simple two step process:

step-1:Create the M/Monit database. The database schemas can be found in mmonit/db/ Use one of the following recipes:

MySQL:
1) Create the mmonit database: mysqladmin create mmonit -u root -p
2) Create the mmonit user and grant access to the mmonit database:
GRANT ALL ON mmonit.* to mmonit@localhost identified by ''
3) Create the schema: mysql -u mmonit mmonit -p < mmonit-schema.mysql PostgreSQL: 1) Create a mmonit postgres user: createuser -U postgres -P mmonit 2) Create the mmonit database: createdb -U postgres -E utf8 -O mmonit mmonit 3) Create the schema: psql -U mmonit mmonit < mmonit-schema.postgresql step-2:Configure M/Monit; edit the M/Monit configuration file mmonit/conf/server.xml and replace the SQLite element with either.

This one for MySQL:


Or this one for PostgreSQL:


That is it. When you start M/Monit it connects to the configured database system.

10: After Completing this Exercise restart you monit server

/etc/init.d/monit restart

11: Check from log the successful connectivity with MMonit server.

12: open your browser and access the link http://www.serverweb.com:8080

username:admin
password: as listed in M/Monit installation

you will see the dashboard with your host server statistics.

That's all about the M/Monit.

Regards & Thanks
Imran Ullah