Step by Step method to install Media Wiki

Step-By-Step Installation Procedure of Mediawiki on Ubuntu Server 9.04 or Other Distribution as well (If it is rpm distribution replace aptitude/apt-get to yum)

Ubuntu installation using these commands:
aptitude Update
aptitude install apache2 mysql-server php5 php5-mysql mediawiki php5-gd -y

After installation Make sure that Apache is up and running

gedit /etc/apache2/apache2.conf 

(Note that it’s a good idea to back up any system configuration file before editing it. You can do so quickly by using sudo cp /etc/apache2/apache2.conf ~/Desktop to save a copy to your Desktop. You can of course use vi or emacs or the editor of your choice, but most new users seem to prefer gedit’s GUI.)

Once you are in gedit, add the following line to the end of the file:

AddType application/x-httpd-php .html 

Save the file and exit gedit.
Now we’ll need to prepare MySQL for use with MediaWiki. First, you’ll need to run MySQL’s install script:
sudo mysql_install_db
Once this is completed, log into the MySQL command-line client:
mysql -u root –p
Enter your MySQL root user password from above, and you’ll find yourself at the MySQL> local client prompt. First, create a database for MediaWiki to use:
CREATE DATABASE mediawiki;
(Note that all commands entered in the MySQL local client must end with a semicolon to denote the end of the statement.)

Once the database is created, you’ll need to create a database user so MediaWiki can access your newly created database. While still in the MySQL command line client, type this:

CREATE USER mediawikiuser; 

Then create a password for your new user (note that your password will actually go within the quotation marks, and is case-sensitive):

SET PASSWORD FOR mediawikiuser = PASSWORD(“password”); 

Now that you’ve got your MediaWiki database and your MediaWiki database user, you’ll need to grant the user all permissions on the database (again, the password goes within the quotation marks, and is case sensitive):

GRANT ALL PRIVILEGES ON mediawiki.* TO mediawikiuser@localhost IDENTIFIED BY ‘password’; 

(Make sure to append “@localhost” to mediawikiuser; otherwise you might get a database error later on when MediaWiki tries to run its installation script.)
Configure MediaWiki
gedit /etc/mediawiki/apache.conf
Remove the '#' on the third line so that line reads:

Alias /mediawiki /var/lib/mediawiki
/etc/init.d/apache2 restart 
http://localhost/mediawiki ( Follow up the Index page Configuration U need to give the database username and password etc)
Note: makesure user the username, password and Database should be correct

Step by step Method to install OpenNMS

Note: Make sure snmp is already installed on the Server. If not run

apt-get install snmpd -y 

Add the OpenNMS Repository to Your sources.list


deb http://debian.opennms.org stable main
deb-src http://debian.opennms.org stable main 

Add the OpenNMS PGP Key to APT

wget -O - http://debian.opennms.org/OPENNMS-GPG-KEY | sudo apt-key add - 
apt-get update 

(or)

apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 4C4CBBD9
apt-get update
Installing PostgreSQL


apt-get install postgresql-8.3  
Modify pg_hba.conf file in /etc/postgresql/8.3/main/ 
comment all other lines in this file.

local   all         all                               trust
# IPv4 local connections:
host    all         all         127.0.0.1/32          trust
# IPv6 local connections:
host    all         all         ::1/128               trust
host    all         all         192.168.1.0           255.255.255.0 trust     <=== Double check 192.168.1.0 it can be 10.10.20.0

Edit postgresql.conf to Allow TCP/IP Connections

vi /etc/postgresql/8.3/main/postgresql.conf 
Uncomment following line 
listen_addresses = 'localhost' 

Restart the Postgresql Database

/etc/init.d/postgresql-8.3 restart 

Installing OpenNMS

apt-get install opennms 
we need to set opennms home in /etc/environment

add the following line
OPENNMS_HOME=/usr/share/opennms 
execute the following command for setting OPENNMS_HOME for existing session 
export OPENNMS_HOME=/usr/share/opennms 
Before you can run the post-install, OpenNMS needs to be configured  to use an appropriate Java Runtime Environment (JRE). The OpenNMS tool  runjava is used to set this up, and it can either search for a suitable  JRE or you can tell it exactly which JRE to use.

# /usr/share/opennms/bin/runjava -s 

This tool will setup the opennms database within PostgreSQL among other things.

# /usr/share/opennms/bin/install -l /usr/local/lib -dis 

you should see similar output after executing above command

- checking table "qrtz_fired_triggers"...
- checking table "qrtz_fired_triggers"... CREATED
- granting access to 'qrtz_fired_triggers' for user 'opennms'... DONE
- checking table "qrtz_scheduler_state"...
- checking table "qrtz_scheduler_state"... CREATED
- granting access to 'qrtz_scheduler_state' for user 'opennms'... DONE
- checking table "qrtz_locks"...
- checking table "qrtz_locks"... CREATED
- granting access to 'qrtz_locks' for user 'opennms'... DONE
- creating tables... DONE
- inserting initial table data for "categories"... OK
- inserting initial table data for "qrtz_locks"... OK
- inserting initial table data for "distPoller"... OK
- checking if iplike is usable... YES
- checking for stale eventtime.so references... OK 
Installer completed successfully! 
Start opennms using the following command

/etc/init.d/opennms start 
OpenNMS will take some time to start, you can check the status of opennms using the following command
root@server1:/usr/local/lib# /etc/init.d/opennms status
OpenNMS.Eventd         : running
OpenNMS.Trapd          : running 
OpenNMS.Queued         : running
OpenNMS.Actiond        : running
OpenNMS.Capsd          : running
OpenNMS.Notifd         : running
OpenNMS.Scriptd        : running
OpenNMS.Rtcd           : running
OpenNMS.Pollerd        : running
OpenNMS.PollerBackEnd  : running
OpenNMS.Ticketer       : running
OpenNMS.Collectd       : running
OpenNMS.Threshd        : running
OpenNMS.Discovery      : running
OpenNMS.Vacuumd        : running
OpenNMS.EventTranslator: running
OpenNMS.PassiveStatusd : running
OpenNMS.Statsd         : running
OpenNMS.Importer       : running
OpenNMS.JettyServer    : running
opennms is running 
if you are able to see like above your opennms is running without any problems.
If you don't see the above output and get at error asking you to look at a log file.. /var/log/opennms/daemon/output.log and the log file mentions the following error..
An error occurred while attempting to start the "OpenNMS:Name=Dhcpd"
service (class org.opennms.netmgt.dhcpd.jmx.Dhcpd).  Shutting down and exiting.
Edit the file $OPENNMS_HOME/etc/service-configuration.xml and comment out the following portion as follows; and restart the opennms service.

<service>
               <name>OpenNMS:Name=Dhcpd</name>
               <class-name>org.opennms.netmgt.dhcpd.jmx.Dhcpd</class-name>
               <invoke at="start" pass="1" method="start"/>
               <invoke at="status" pass="0" method="status"/>
               <invoke at="stop" pass="0" method="stop"/>
</service>

Finally you can access web UI using the following URL ( replace yourhost to the IP of the opennms server)
http://yourhost:8980/opennms
Configuration of OpenNMS
Login in to the web interface  with  login / pass  admin/admin
Configure Discovery - Select  Home  /  Admin  /  Discovery  / Add New    -- Include Range.
Configure SNMP  - Select Home  / Admin  / Configure SNMP by IP

Database Login Details
opennms/postgres ( test user and password i have given )
 
Add Alert sound to the OpenNMS webUI 
In /usr/share/opennms/jetty-webapps/opennms/includes/servicesdown-box.jsp 
Find below tags should be at the end of the file
 
  
<c:otherwise>
  <embed src="tngchime.wav" type="audio/x-pn-realaudio-plugin" hidden="true" autostart="true" loop="false" height="0"  width="0">
  <ul class="plain">
  <c:forEach var="summary" items="${summaries}">
  <c:url var="nodeLink" value="element/node.jsp">
  <c:param name="node" value="${summary.nodeId}"/>
  </c:url>
  <li><a href="${nodeLink}">${summary.nodeLabel}</a> (${summary.fuzzyTimeDown})</li>
  </c:forEach>
  </ul>
  <c:if test="${moreCount > 0}">
  <p class="noBottomMargin" align="right">
  <c:url var="moreLink" value="outage/current.jsp"/>
  <a href="${moreLink}">${moreCount} more...</a>
  </p>
  </c:if>
  </c:otherwise>
The line with the  tag is new, the rest is stock 
Download the following .wav file and pleace it in /usr/share/opennms/jetty-webapps/
wget http://www.nirvani.net/misc/trek_sounds/tngchime.wav

You don't need to restart OpenNMS to effect
Once you are done with above settings please install QuickTimeInstaller.exe in your windows system and restart the browser if opennms find any outages as soon as you login to OpenNMS webGUI you will hear alert sound ( check your sound volume)

Step by step method to create a SSL certificate for your websites

cd  /etc/apache2/ssl/client

Run following commands

openssl genrsa -des3 -out client.key 1024
openssl req -new -key client.key -out client.crs
openssl ca -in client.crs -cert ../ca/ca.crt -keyfile ../ca/ca.key -out client.crt
openssl pkcs12 -export -clcerts -in client.crt -inkey client.key -out client.p12




Importing Certs in Browser

Make sure to enter the password which was assigned during cert creation.

FireFox

1) Remove your current Certificates.
Firefox : Preferences > Advanced > Encryption > View Certificates > Your Certificates > Select Certificates and Delete.
2) Import : select client.p12 password: test123

Chrome

1) Remove your current Certificates.
   Chrome > Preferences > Under the Hood > Manage Certificates > Remove current one..and import the new one.
2) Import  select 
Import : select client.p12 password: test123
 

How to troubleshoot IP conflicts between Servers / Systems

when we have ip conflicts between two Systems/Servers and you dont know what server ping is responding. Just give below command it requires nmap to be installed

nmap -sV -O -v ipaddress

From the below i found that the response is coming from Server1.demo.com and more to it we
can also see what operating system it is running and what are the open ports of that server.

root@naresh:/home/cp# nmap -sV -O -v 192.168.1.12


Starting Nmap 5.00 ( http://nmap.org ) at 2011-11-14 15:27 IST
NSE: Loaded 3 scripts for scanning.
Initiating ARP Ping Scan at 15:27
Scanning 192.168.1.12 [1 port]

Completed ARP Ping Scan at 15:27, 0.02s elapsed (1 total hosts)
Initiating Parallel DNS resolution of 1 host. at 15:27
Completed Parallel DNS resolution of 1 host. at 15:27, 0.03s elapsed
Initiating SYN Stealth Scan at 15:27
Scanning 192.168.1.12 [1000 ports]
Discovered open port 3306/tcp on 192.168.1.12
Discovered open port 111/tcp on 192.168.1.12
Discovered open port 80/tcp on 192.168.1.12
Discovered open port 25/tcp on 192.168.1.12
Discovered open port 8080/tcp on 192.168.1.12
Discovered open port 53/tcp on 192.168.1.12
Discovered open port 443/tcp on 192.168.1.12
Discovered open port 8009/tcp on 192.168.1.12
Discovered open port 2049/tcp on 192.168.1.12

Completed SYN Stealth Scan at 15:27, 0.04s elapsed (1000 total ports)
Initiating Service scan at 15:27
Scanning 9 services on 192.168.1.12

Completed Service scan at 15:28, 46.06s elapsed (9 services on 1 host)
Initiating OS detection (try #1) against 192.168.1.12
NSE: Script scanning 192.168.1.12.
NSE: Script Scanning completed.
Host 192.168.1.12 is up (0.000088s latency).
Interesting ports on 192.168.1.12:

Not shown: 991 closed ports
PORT     STATE SERVICE    VERSION
25/tcp   open  smtp       Postfix smtpd
53/tcp   open  tcpwrapped
80/tcp   open  http       Apache httpd 2.2.12 ((Ubuntu))
111/tcp  open  rpcbind
443/tcp  open  ssl/http   Apache httpd 2.2.12 ((Ubuntu))
2049/tcp open  rpcbind
3306/tcp open  mysql      MySQL 5.1.37-1ubuntu5.5
8009/tcp open  ajp13?
8080/tcp open  http       Apache Tomcat/Coyote JSP engine 1.1
MAC Address: 00:25:90:62:4B:62 (Super Micro Computer)
Device type: general purpose
Running: Linux 2.6.X
OS details: Linux 2.6.24 - 2.6.28
Uptime guess: 0.113 days (since Mon Nov 14 12:45:28 2011)
Network Distance: 1 hop
TCP Sequence Prediction: Difficulty=197 (Good luck!)
IP ID Sequence Generation: All zeros
Service Info: Host:  Server1.demo.com

Bash script to add some line to a file at specific line number

I wrote this example to show how to append JAVA_OPTS parameters to startup.sh of tomcat



#!/bin/bash

NLINE=2
s=" export JAVA_OPTS=\"$JAVA_OPTS -Xms1024m -Xmx1024m -XX:MaxPermSize=256m\""
sp=" "
awk -vn="$NLINE" -vs="$s" -vsp="$sp" 'NR==n{$0=$0 sp s}1' startup.sh >temp
mv temp startup.sh



Sp is space given so that if something exists in that line it will give some space and
append our command or string

I just ran 'chmod -x /bin/chmod'. What did I do? How do I recover?

( or )

What to do if you cannot execute CHMOD?

This is a tricky question.. you have just removed execute permission on chmod.
Result of that is you cannot modify file permissions . Not even for chmod itself .
chmod remains usless on your system.

Here is the solution for the problem

sudo /lib/ld-linux.so.2 /bin/chmod 755 /bin/chmod

or

perl -e 'chmod(0755, "/bin/chmod")'