Archive

Archive for the ‘Web development’ Category

MongoDb Introduction

April 7, 2016 Leave a comment

MongoDB Databse-
MongoDB is NoSql and document oriented database. MongoDB stores data using a flexible document data model that is similar to JSON.

Create Database-
>use yaju;

Show Database-
>show dbs

Drop Database-
To drop database, first use that database then use following command.
>db.dropDatabase();

Create Collection-
Collections are like table in MySql. We can create collection in two ways.

First, we can create empty collection
>db.createCollection(‘test’);

Second, we can create dynamic collection with insert command. Mongo check that collection if collection is exists then insert data in existing collection otherwise create new collection and insert data. That can be through followning command.
>db.testtable.insert({‘name’:’yajuvendra’},{‘name’:’yaj’});

Show collections-
Show all collection in a database use following command.
>show collections;

Insert document-
We can insert single document and multiple document as well.

Single document
>db.testtable.insert({‘name’:’yajuvendra’},{‘name’:’yaj’});
Multiple document
>db.testtable.insert([{‘name’:’yajuvendra’},{‘name’:’yaj’}, {‘name’:’yaju’},{‘name’:’yajkumar’}]);

Select document-
Select all document
>db.testtable.find();
Select particular document
> db.testtable.find({‘name’:’yaj’});

Remove document-
> db.testtable.remove({‘name’:’yaju’});

Update document-
> db.testtable.update({name:’yaj’},{$set:{name:’yaju_update’}})

Advertisements

How to install xampp/lampp on centos (linux)

June 27, 2013 Leave a comment

How to install xampp/lampp on centos (linux)

The installation procedure here is based on CentOS 6.x workstation default installation. Follow these steps
1. Log in linux terminal

2. Change user to root. Write below command and press enter and enter root user password.

#su

3. The default installation of CentOS lacks some of the libraries that XAMPP needs to run, including 32 bit compatibility libraries.
To get them you su to root then use this yum command.

#yum -y install glibc* libstd* ld-linux.so.2

4. Download and install the latest verions from the XAMPP, from the XAMPP download page. Upload this file to server /opt/ directory.

5. Unpack tar file

#tar zxvf xampp-linux-1.8.1.tar.gz /opt/

6. Change the ownership of all the xampp files to be nobody:root.

#chown nobody:root /opt/lampp/ -R

7. XAMPP was designed to run on 32 bit operating systems. The start up script will prevent xampp from starting up if you are running on a 64 bit system which isn’t necessary since you installed 32 bit compatibility libraries in step 1. To get around this restriction, open /opt/lampp/lampp in an editor and comment out the following lines.

# XAMPP is currently 32 bit only
#case `uname -m` in
# *_64)
# if /opt/lampp/bin/php -v > /dev/null 2>&1
# then
# :
# else
# $de && echo “XAMPP gibt es zur Zeit nur als 32-Bit Applikation.
# Bitte verwende eine 32-Bit Kompatibilitaetsbibliothek fuer Dein
# System.”
#
# $de || echo “XAMPP is currently only availably as 32 bit
# application. Please use a 32 bit compatibility library for
# your system.”
#
# exit
# fi
# ;;
#esac

8. Open /opt/lampp/etc/etc/extra/httpd-xampp.conf in an editor. Replace the “Deny from all” statement with “Require all grant” in the stanza. You can also comment out the “Allow from…” line if you don’t want to accept connections from any external system.

Order deny, allow
# Deny from all
Require all granted
# Allow from ::1 127.0.0.0/8 \
# fc00::/7 10.0.0.0/8 172.16.0.0/12 192.168.0.0/16
# fe80::/10 169.254.0.0/16
ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var

9. Start up xampp
#/opt/lampp/lampp start

10. To fix most of the security weaknesses in xampp simply call the following command

#/opt/lampp/lampp security

It will ask you to change password. Set all pasword.

11. Open http://localhost in a browser. You should a get a browser window with the XAMPP for Linux startup screen.

12. Open /opt/lampp/lampp/phpmyadmin/config.inc.php in your editor of choice

13. Change the authentication type as follows:

$cfg[‘Servers’][$i][‘auth_type’] = ‘cookie’

14. Add the following lines in the config.inc.php file.

$cfg[‘Servers’][$i][‘table_uiprefs’] = ‘pma_table_uiprefs’;
$cfg[‘Servers’][$i][‘recent’] = ‘pma_recent’;

15. Close your browser then restart Apache and MySQL in the XAMPP Control Panel.

#/opt/lampp/lampp restart

17. At this point most of the setup work for XAMPP is done. However, if you plan to use phpyMyAdmin you’ll have to do a little further configuration to get it to work properly. XAMPP does not create all the tables that phpmyadmin needs so you have to do this with an SQL script that is enclosed with the package. To do this click on the Import tab in phpmyadmin. Choose the create_tables.sql script in /opt/lampp/lampp/phpmyadmin/examples directory and press go button.

18. If website is not open. Then check port 80 on centOs. dport port 80 by following command.

# sudo iptables -I INPUT -p tcp –dport 80 -j ACCEPT
# sudo service iptables save

19. For ftp dport 21 port

# sudo iptables -I INPUT -p tcp –dport 80 -j ACCEPT
# sudo service iptables save

20. [optional] Block brute force attack. Please read this http://kvz.io/blog/2007/07/28/block-brute-force-attacks-with-iptables/

Follow me on facebook

Improve website performance

May 24, 2012 3 comments
  1. JavaScript Optimization
    • Place javascript at the bottom of the html.
    • Use Minify JavaScript
    • Alway write JavaScript in external file
    • Try to reduce number of JavaScript files.
  2. CSS Optimization
    • Place CSS at the top of html
    • Use Minify Css
    • Alway write css in external file.
    • Try to reduce number of css files.
  3. SERVER Optimization
    • Alway enable gzip/bzip2 compression.
  4. HTTACCESS
    • Use this code in .htaccess filemod_gzip_on Yesmod_gzip_dechunk Yes
      mod_gzip_item_include file \.(html?|txt|css|js|php|pl)$
      mod_gzip_item_include handler ^cgi-script$
      mod_gzip_item_include mime ^text/.*
      mod_gzip_item_include mime ^application/x-javascript.*
      mod_gzip_item_exclude mime ^image/.*
      mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
%d bloggers like this: