1:cat /etc/redhat-release
Red Hat Enterprise Linux Server release 5.6 (Tikanga)
2: psql --version
psql (PostgreSQL) 8.4.7
3:whereis pg_config
pg_config
4:yum install postgresql84-devel
install compltely.
again check whereis pg_config
pg_config: /usr/bin/pg_config /usr/include/pg_config.h /usr/share/man/man1/pg_config.1.gz
5:cd /usr/local/
wget http://http://sphinxsearch.com/downloads/accept.php?file=sphinx-2.0.2-beta.tar.gz
6:tar -zxvf sphinx-2.tar.gz
7:cd sphinx-2
8:mkdir /usr/local/sphinx
9:./configure --without-mysql --with-pgsql /usr/bin/pg_config --prefix=/usr/local/sphinx
10: make
11: make install
12: cd /usr/local/sphinx/etc
cp sphinx-min.conf sphinx.conf
13: do the required changes in sphinx.conf
database pgsql
database user
database name
database password
port: 5432
14:run the sphinx searchd
/usr/local/etc/bin/indexer --all
searchd start
Friday, 23 December 2011
Thursday, 15 December 2011
How to block users through MAC Address IPTABLES Ubuntu 10.10
I have installed a squid 2.7 transparently and also implemented sarg for reports. but i am facing a problem here. i have configure my network users in dhcp.conf. but there are some other users appears in my sarg reports with a heavy downloads.
now i have to do some thing specials for these guys.
i am going to invite them on lunch.
i just open terminal on my server, and run the command
arp -a
i found all the MAC Address and IP Address. i do have a MAC table of my network users.
then i copy all the MAC address that are not listed in my MAC table and create another file for them, past all with in a file.
After that i tab the terminal run the following commands to:
To check my iptables Rules:
iptables-save
ok
Then Run the command to block each MAC user that i have in newly created file. by running the following two commands repeatedly for each user.
iptables -A INPUT -m mac --mac-source 00:xx:6b:xx:05:xx -j DROP
iptables -A FORWARD -m mac --mac-source 00:xx:6b:xx:05:xx -j DROP
then check out the command
iptables-save
and then
iptables-apply
All the unauthorized users are blocked now.
if i want to give access to some one later on i have to follow the simple steps.
iptables -D INPUT -m mac --mac-source 00:xx:6b:xx:05:xx -j DROP
iptables -D FORWARD -m mac --mac-source 00:xx:6b:xx:05:xx -j DROP
iptables-save to check the specific entry is deleted from IPTABLES-RULES.
now he can access the internet.
now who is going to pay for lunch. don't worry i am going to pay.
Enjoy the fruits
do comments if you like it.
now i have to do some thing specials for these guys.
i am going to invite them on lunch.
i just open terminal on my server, and run the command
arp -a
i found all the MAC Address and IP Address. i do have a MAC table of my network users.
then i copy all the MAC address that are not listed in my MAC table and create another file for them, past all with in a file.
After that i tab the terminal run the following commands to:
To check my iptables Rules:
iptables-save
ok
Then Run the command to block each MAC user that i have in newly created file. by running the following two commands repeatedly for each user.
iptables -A INPUT -m mac --mac-source 00:xx:6b:xx:05:xx -j DROP
iptables -A FORWARD -m mac --mac-source 00:xx:6b:xx:05:xx -j DROP
then check out the command
iptables-save
and then
iptables-apply
All the unauthorized users are blocked now.
if i want to give access to some one later on i have to follow the simple steps.
iptables -D INPUT -m mac --mac-source 00:xx:6b:xx:05:xx -j DROP
iptables -D FORWARD -m mac --mac-source 00:xx:6b:xx:05:xx -j DROP
iptables-save to check the specific entry is deleted from IPTABLES-RULES.
now he can access the internet.
now who is going to pay for lunch. don't worry i am going to pay.
Enjoy the fruits
do comments if you like it.
Labels:
arp -a,
block,
IPTABLES,
MAC Address
Wednesday, 14 December 2011
How to Create Redmine Plugin (Custom Menus) and integrate on HostGator Server VPS.
How to Create Redmine Plugin to Add Custom Menus to Project Menu on HostGator Server VPS:
The name of Plugin is CMenu and tittle is workplans.
steps are below:
first i have taken the backup of the redmine application database.
host: localhost
username: user_redmine
password: password
encoding: utf8
Then start creating the new plugin:
ssh user@hostgator.com -p 2222
password:
mysqldump -u user database > databasebakup
Creating a new Plugin
To set the RAILS_ENV variable in order to use the command below:
export RAILS_ENV="production"
Creating a new plugin can be done using the Redmine plugin generator.
Syntax for this generator is:
So open up a command prompt and "cd" to your redmine directory, then execute the following command:
ruby script/generate redmine_plugin CMenu
The plugin structure is created in vendor/plugins/redmine_C_Menu:
Edit vendor/plugins/redmine_C_Menu/init.rb to adjust plugin information (name, author, description and version):
.............................................
require 'redmine'
Redmine::Plugin.register :redmine_C_Menu do
name 'CMenu plugin'
author 'sysadmin'
description 'A plugin for adding custum menu'
version '0.0.1'
end
.............................................
Then restart the application and point your browser to http://redmin.domain/admin/plugins.
After logging in, you should see your new plugin in the plugins list:
Generating a model
For now plugin doesn't store anything. Let's create a simple Workplans model for our plugin. Syntax is:
ruby script/generate redmine_plugin_model CMenu workplans tabmenu:string Click:string
This creates the workplans model and the corresponding migration file.
Please note you may have to rename your migration. Timestamped migrations are not supported by the actual Redmine plugin engine (Engines). If your migrations are named with a timestamp, rename it using "001", "002", etc. instead.
mv vendor/plugins/redmine_c_menu/db/migrate/20111214133141_create_workplans.rb vendor/plugins/redmine_c_menu/db/migrate/001_create_workplans.rb
If you have already created a database table record in plugin_schema_info with the timestamp version number, you will have to change it to reflect your new version number, or the migration will hang.
Migrate the database using the following command:
rake db:migrate_plugins
Generating a controller
Warning: starting from 1.4.0, Redmine won't provide anymore the default wildcard route (':controller/:action/:id'). Plugins will have to declare the routes they need in their proper config/routes.rb file.
For now, the plugin doesn't do anything. So let's create a controller for our plugin.
We can use the plugin controller generator for that. Syntax is:
ruby script/generate redmine_plugin_controller CMenu workplans index
A controller workplansController with 1 action (#index) is created.
Edit vendor/plugins/redmine_c_menu/app/controllers/workplans_controller.rb redmine_C_menu directory to implement the actions.
vim vendor/plugins/redmine_c_menu/app/controllers/workplans_controller.rb
.........................................................
class WorkplansController < ApplicationController
unloadable
............................................................
Then edit vendor/plugins/redmine_c_menu/app/views/workplans/index.html.erb that will display existing polls:
...........................................................
<h2>Workplans</h2>
............................................................
Extending the project menu
Now, let's consider that the CMenu are defined at project level (even if it's not the case in our example poll model). So we would like to add the CMenu tab to the project menu instead.
Open init.rb and replace the line that was added just before with these 2 lines:
................................................................
permission :workplans, { :workplans => [:index] }, :public => true
menu :project_menu, :workplans, { :controller => 'workplans', :action => 'index' }, :caption => 'CMenu', :after => :activity, :param => :project_id
.................................................................
The second line adds our Polls tab to the project menu, just after the activity tab.
The first line is required and declares that our 1 action from workplansController are public
To make it private add the permission:
permission :view_workplans, :workplans => :index and remove the :public => true from 1st line.
Restart the application again and go to one of your projects:
If you click the CMenu tab, you should notice that the project menu is no longer displayed.
To make the project menu visible, you have to initialize the controller's instance variable @project.
Edit your workplansController to do so:
................................................................
class WorkplansController < ApplicationController
unloadable
................................................................
The project id is available in the :project_id param because of the :param => :project_id option in the menu item declaration above.
Now, you should see the project menu when viewing the CMenu:
Adding stylesheets
Let's start by adding a stylesheet to our plugin views.
Create a file named workplans.css in the vendor/plugins/redmine_C_Menu/assets/stylesheets directory:
a.workplans { font-size: 120%; color: blue }
When starting the application, plugin assets are automatically copied to public/plugin_assets/redmine_C_Menu/ by Rails Engines to make them available through your web server. So any change to your plugin stylesheets or javascripts needs an application restart.
Then, append the following lines at the end of vendor/plugins/redmine__C_Menu/app/views/polls/index.html.erb so that your stylesheet get included in the page header by Redmine:
..................................................................
<% html_title "Workplans" >
< content_for :header_tags do >
<= stylesheet_link_tag 'workplans', :plugin => 'redmine_C_Menu' >
< end %>
..................................................................
Restart your application and view the Plugin:
Thats it
Regards:
Imran Ullah
The name of Plugin is CMenu and tittle is workplans.
steps are below:
first i have taken the backup of the redmine application database.
host: localhost
username: user_redmine
password: password
encoding: utf8
Then start creating the new plugin:
ssh user@hostgator.com -p 2222
password:
mysqldump -u user database > databasebakup
Creating a new Plugin
To set the RAILS_ENV variable in order to use the command below:
export RAILS_ENV="production"
Creating a new plugin can be done using the Redmine plugin generator.
Syntax for this generator is:
So open up a command prompt and "cd" to your redmine directory, then execute the following command:
ruby script/generate redmine_plugin CMenu
The plugin structure is created in vendor/plugins/redmine_C_Menu:
Edit vendor/plugins/redmine_C_Menu/init.rb to adjust plugin information (name, author, description and version):
.............................................
require 'redmine'
Redmine::Plugin.register :redmine_C_Menu do
name 'CMenu plugin'
author 'sysadmin'
description 'A plugin for adding custum menu'
version '0.0.1'
end
.............................................
Then restart the application and point your browser to http://redmin.domain/admin/plugins.
After logging in, you should see your new plugin in the plugins list:
Generating a model
For now plugin doesn't store anything. Let's create a simple Workplans model for our plugin. Syntax is:
ruby script/generate redmine_plugin_model CMenu workplans tabmenu:string Click:string
This creates the workplans model and the corresponding migration file.
Please note you may have to rename your migration. Timestamped migrations are not supported by the actual Redmine plugin engine (Engines). If your migrations are named with a timestamp, rename it using "001", "002", etc. instead.
mv vendor/plugins/redmine_c_menu/db/migrate/20111214133141_create_workplans.rb vendor/plugins/redmine_c_menu/db/migrate/001_create_workplans.rb
If you have already created a database table record in plugin_schema_info with the timestamp version number, you will have to change it to reflect your new version number, or the migration will hang.
Migrate the database using the following command:
rake db:migrate_plugins
Generating a controller
Warning: starting from 1.4.0, Redmine won't provide anymore the default wildcard route (':controller/:action/:id'). Plugins will have to declare the routes they need in their proper config/routes.rb file.
For now, the plugin doesn't do anything. So let's create a controller for our plugin.
We can use the plugin controller generator for that. Syntax is:
ruby script/generate redmine_plugin_controller CMenu workplans index
A controller workplansController with 1 action (#index) is created.
Edit vendor/plugins/redmine_c_menu/app/controllers/workplans_controller.rb redmine_C_menu directory to implement the actions.
vim vendor/plugins/redmine_c_menu/app/controllers/workplans_controller.rb
.........................................................
class WorkplansController < ApplicationController
unloadable
before_filter :find_project, :authorize, :only => :indexdef index
@workplans = CMenu.find(:all)
end
def find_project
@project = Project.find(params[:project_id])
endend............................................................
Then edit vendor/plugins/redmine_c_menu/app/views/workplans/index.html.erb that will display existing polls:
...........................................................
<h2>Workplans</h2>
............................................................
Extending the project menu
Now, let's consider that the CMenu are defined at project level (even if it's not the case in our example poll model). So we would like to add the CMenu tab to the project menu instead.
Open init.rb and replace the line that was added just before with these 2 lines:
................................................................
permission :workplans, { :workplans => [:index] }, :public => true
menu :project_menu, :workplans, { :controller => 'workplans', :action => 'index' }, :caption => 'CMenu', :after => :activity, :param => :project_id
.................................................................
The second line adds our Polls tab to the project menu, just after the activity tab.
The first line is required and declares that our 1 action from workplansController are public
To make it private add the permission:
permission :view_workplans, :workplans => :index and remove the :public => true from 1st line.
Restart the application again and go to one of your projects:
If you click the CMenu tab, you should notice that the project menu is no longer displayed.
To make the project menu visible, you have to initialize the controller's instance variable @project.
Edit your workplansController to do so:
................................................................
class WorkplansController < ApplicationController
unloadable
before_filter :find_project, :authorize, :only => :indexdef index
@CMenu = CMenu.find(:all)
end
def find_project
@project = Project.find(params[:project_id])
endend................................................................
The project id is available in the :project_id param because of the :param => :project_id option in the menu item declaration above.
Now, you should see the project menu when viewing the CMenu:
Adding stylesheets
Let's start by adding a stylesheet to our plugin views.
Create a file named workplans.css in the vendor/plugins/redmine_C_Menu/assets/stylesheets directory:
a.workplans { font-size: 120%; color: blue }
When starting the application, plugin assets are automatically copied to public/plugin_assets/redmine_C_Menu/ by Rails Engines to make them available through your web server. So any change to your plugin stylesheets or javascripts needs an application restart.
Then, append the following lines at the end of vendor/plugins/redmine__C_Menu/app/views/polls/index.html.erb so that your stylesheet get included in the page header by Redmine:
..................................................................
<% html_title "Workplans" >
< content_for :header_tags do >
<= stylesheet_link_tag 'workplans', :plugin => 'redmine_C_Menu' >
< end %>
..................................................................
Restart your application and view the Plugin:
Thats it
Regards:
Imran Ullah
Tuesday, 13 December 2011
How to install Redmine 1.1.2 on Ubuntu Server 10.XX
How to install Redmine 1.1.2 on Ubuntu Server 10.XX
follow the steps bellow and see how easly and step by step you are going to install and configure redmine on your local machine:
1 : sudo apt-get update
2 : sudo apt-get upgrade
3 : sudo apt-get install ruby1.8-dev rubygems1.8 libmysql-ruby libmysqlclient-dev rake libopenssl-ruby libapache2-mod-passenger imagemagick libmagickcore-dev libmagickwand-dev
4 : sudo gem install rails -v=2.3.5
if it requires the Ruby version v >= 1.3.1
Then follow the steps:
4.a: Install the following packages for ruby
sudo aptitude install ruby1.8-dev ruby1.8 ri1.8 rdoc1.8 irb1.8 libreadline-ruby1.8 libruby1.8 libopenssl-ruby sqlite3 libsqlite3-ruby1.8
We need to create some symlinks from the install to locations every programme would look for
sudo ln -s /usr/bin/ruby1.8 /usr/bin/ruby
sudo ln -s /usr/bin/ri1.8 /usr/bin/ri
sudo ln -s /usr/bin/rdoc1.8 /usr/bin/rdoc
sudo ln -s /usr/bin/irb1.8 /usr/bin/irb
Check Ruby Version
4.b: If you want to check ruby version use the following command
ruby -v
####################### Rubygems ###################
RubyGems is a package manager for the Ruby programming language that provides a standard format for distributing Ruby programs and libraries , a tool designed to easily manage the installation of gems, and a server for distributing them.
RubyGems Features
Easy Installation and removal of RubyGems packages and their dependents.
Management and control of local packages
Package dependency management
Query, search and list local and remote packages
Multiple version support for installed packages
Web-based interface to view the documentation for your installed gems
Easy to use interface for building gem packages
Simple server for distributing your own gem packages
you can download latest rubygems
4.c: wget http://rubyforge.org/frs/download.php/45905/rubygems-1.3.1.tgz
4.d: tar xzvf rubygems-1.3.1.tgz
cd rubygems-1.3.1
Install rubygem using the following command
sudo ruby setup.rb
This will complete the rubygem installation.
Now create a symbolic link using the following command
sudo ln -s /usr/bin/gem1.8 /usr/bin/gem
Check gem version using the following command
gem -v
Update gem packages using the following command
sudo gem update --system
4.e: now repeat the step 4
gem install rails -v=3.2.5
you will see some warnings like No definition for X. Ignore those, they mean that some documentation was not installed, and we can live with that.
5 : sudo gem install mysql
6 : sudo gem install ruby-openid
7 : sudo gem install i18n -v=0.4.2
8 : sudo gem install passenger
9 : sudo gem install rmagick
you will see some warnings like No definition for X. Ignore those, they mean that some documentation was not installed, and we can live with that.
10 : Enter the MySQL console as root:
mysql -u root -p
password:
11 : inside the MySQL console, execute these commands:
11.a) create database redmine character set utf8;
11.b) create user 'redmine'@'localhost' identified by 'redmine@123';
11.c) grant all privileges on redmine.* to 'redmine'@'localhost';
exit from mysql.
Remember to change myPassword with your actual password. This is the one that will be used for the user redmine in the database redmine at localhost.
12 : Execute the following commands to get redmine 1.1.2.
server@root# wget http://rubyforge.org/frs/download.php/74419/redmine-1.1.2.tar.gz
download completed
then
13 : tar -xvzf redmine-1.1.2.tar.gz
14 : cd redmine-1.1.2
15 : Now setup the database configuration file to match our current environment:
cp config/database.yml.example config/database.yml
vim config/database.yml
production:
adapter: mysql
database: redmine
host: localhost
username: redmine
password: redmine@123
encoding: utf8
development:
adapter: mysql
database: redmine_development
host: localhost
username: redmine
password: redmine@123
encoding: utf8
save and exit!
16 : generate session and db migration:
rake generate_session_store
If you have a problem by installing Redmine 1.2.2:
rake aborted!
uninitialized constant Gem::SyckDefaultKey
then run the following command:
sudo gem update --system 1.3.7
rake generate_session_store
sudo mkdir /opt/redmine
cd /opt/redmine
sudo cp -r ~/redmine-1.1.2 .
cd redmine-1.1.2
sudo RAILS_ENV=production rake db:migrate
sudo RAILS_ENV=production rake redmine:load_default_data
Note: Press enter to accept the default language (English) and then execute the following:
17 : Now do the following
sudo chown -R www-data:www-data files log tmp public/plugin_assets
sudo chmod -R 755 files log tmp public/plugin_assets
sudo nano /etc/apache2/mods-available/passenger.conf
Add this line inside the <IfModule mod_passenger.c> tag:
18 : PassengerDefaultUser www-data
19 : Now let’s configure apache:
sudo nano /etc/apache2/sites-available/default
20 : Just before the closing tag, </VirtualHost>, add the following:
RailsEnv production
RailsBaseURI /redmine
21 : Now we put a link to our application to be accessible from apache and restart it:
sudo ln -s /opt/redmine/redmine-1.1.2/public /var/www/redmine
sudo /etc/init.d/apache2 restart
22 : now open your browser and type:
http://localhost/redmine
username: admin
password: admin
Thats it!
Labels:
dbmigrate,
gem,
libapache2,
localhost,
passenger,
rails 1.0.1,
rails v=2.3.5,
redmine,
Ruby
Monday, 12 December 2011
Error: Can not connect to posgersql, Limit Exceeded for non super users resolved
As we have copy the same contents on form old DB-Server to new Managed Cloud Server, having the same username and passwords for all the databases and same setting.
Due to which by name accessing the server1.com give us the error of limit exceeded for non super users.I Google this issue and find most of the article to increase the number of connections in postgresql.conf file. i checkout my total connection by the time of connectivity that was less than the defined limit. after that search out some other solution but find nothing about this issue to resolve this. at last i applied the procedure, to access the database through server IP rather than name. and i log-in to PostgreSQL successfully. so the reason was the duplication of same name on two different server with same username and password. and we have finally resolve this issue.
Due to which by name accessing the server1.com give us the error of limit exceeded for non super users.I Google this issue and find most of the article to increase the number of connections in postgresql.conf file. i checkout my total connection by the time of connectivity that was less than the defined limit. after that search out some other solution but find nothing about this issue to resolve this. at last i applied the procedure, to access the database through server IP rather than name. and i log-in to PostgreSQL successfully. so the reason was the duplication of same name on two different server with same username and password. and we have finally resolve this issue.
Subscribe to:
Posts (Atom)