Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Saturday, 30 April 2016

How to Install & Configure LAMP Server On Ubuntu 14.04


How to Install & Configure LAMP Server On Ubuntu 14.04
Step: 1. Bind Hosts File :

# vi /etc/hosts

192.168.1.250 ser1.domain.com    ser1

-- Save & Quit (:wq)

Step: 2. Install Apache2 Server :

# apt-get update
# apt-get -y install apache2 apache2-utils

<<<<<<How to Find your Server’s IP address>>>>>

# ifconfig eth0 | grep inet | awk '{ print $2 }'

Step: 3. Install MySQL Server :

# apt-get -y install mysql-server libapache2-mod-auth-mysql

Note: Once you have installed MySQL, we should activate it with this command :

# mysql_install_db

Step: 4. Set MySQL Root Password :

# mysql_secure_installation

# service mysql restart

Step: 5. Install PHP 5.5 :

# apt-get -y install php5 php5-dev libapache2-mod-php5 php5-mcrypt php5-mysql php5-cli \
   php5-common php5-curl php5-gd php5-imap php5-imagick php5-intl php5-ldap  \
   php5-memcache php5-memcached  php5-snmp php5-xcache php5-xmlrpc

# vi /etc/apache2/mods-enabled/dir.conf

<IfModule mod_dir.c>
          DirectoryIndex index.php index.html index.cgi index.pl index.php index.xhtml index.htm
</IfModule>

-- Save & Quit (:wq)

Step: 6. Search PHP Modules (Optional) :

# apt-cache search php5-
# apt-get -y install php5-json

Step: 7. See PHP on your Server :

# vi /var/www/html/info.php

<?php
phpinfo();
?>

-- Save & Quit (:wq)

http://ip_address/info.php

Or

# php -v

Step: 8. Download & Install phpMyAdmin (To Access MySQL Server Graphically) :

# cd /var/www/html
# wget http://jaist.dl.sourceforge.net/project/phpmyadmin/phpMyAdmin/4.0.10/phpMyAdmin-4.0.10-english.tar.gz
# tar -zxvf phpMyAdmin-4.0.10-english.tar.gz
# mv phpMyAdmin-4.0.10-english pma
# rm -rf phpMyAdmin-4.0.10-english.tar.gz
# cd pma/
# mv config.sample.inc.php config.inc.php

# service apache2 restart
# service mysql restart

Step: 9. Configure phpMyAdmin with MD5 Password Protected :

# vi /etc/apache2/sites-available/pma.domain.com.conf

<VirtualHost *:80>
  DocumentRoot /var/www/html/pma
  ServerName pma.anything.com
  # ServerAlias www.pma.domain.com

# Authorize for setup
<Directory /var/www/html/pma/setup>
    <IfModule mod_authn_file.c>
    AuthType Basic
    AuthName "phpMyAdmin Setup"
    AuthUserFile /home/secure/.htpasswd
    </IfModule>
    Require valid-user
</Directory>

<Directory /var/www/html/pma>
   Options All Indexes FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>
</VirtualHost>

-- Save & Quit (:wq)

# mkdir /home/secure/
# htpasswd -c /home/secure/.htpasswd pmaadmin

# cd /etc/apache2/sites-enabled/
# ln -s /etc/apache2/sites-available/pma.domain.com.conf pma.domain.com.conf
Or
# a2ensite  pma.domain.com

# service apache2 restart

http://pma.domain.com

Thanks For Visiting on My Blog, For More Tutorials Keep Visiting My Blog

Friday, 29 April 2016

Linux Tmux Vs Screen Command

Linux Tmux Vs Screen Command


Q. What is tmux ?

-- tmux is a software application that can be used to multiplex several virtual consoles, allowing a user to access multiple separate terminal sessions inside a single terminal window or remote terminal session.

Q. What is Screen ?

-- Screen is a full-screen software program that can be used to multiplexes a physical console between several processes (typically interactive shells). It offers a user to open several separate terminal instances inside a one single terminal window.

Step: 1. Install tmux :

# yum -y install epel-release
# yum -y install tmux

Step: 2. Install Screen :

# yum -y install screen

Tmux Vs Screen
Tmux Vs Screen
Tmux Vs Screen

Thanks For Visiting on My Blog, For More Tutorials Keep Visiting My Blog

Saturday, 23 April 2016

Easy Way to Install the MongoDB PHP Driver on CentOS/RHEL 6x & Ubuntu 14.04

Install the MongoDB PHP Driver on CentOS/RHEL 6x & Ubuntu 14.04

Step: 1. Install Apache Server :

For CentOS Users :

# yum -y install httpd httpd-devel

For Ubuntu Users :

# apt-get -y install apache2

Step: 2. Install PHP :

For CentOS Users :

# yum -y install epel-release
# yum -y install php php-cli php-mysql php-common php-gd php-mbstring php-mcrypt php-devel \
php-xml php-imap php-ldap php-mbstring php-odbc php-pear php-xmlrpc php-soap php-intl mod_ssl
 
For Ubuntu Users :

# apt-get -y install php5 php5-cli libapache2-mod-php5 php-pear php5-dev

Step: 3. Install Mongo Driver :

For CentOS Users :

# yum -y install openssl-devel
# pecl install mongo

For Ubuntu Users :

# pecl install mongo

Step: 4. Add the Extension in php.ini File :

For CentOS Users :

# vi /etc/php.d/mongo.ini

extension=mongo.so

-- Save & Quit (:wq)

For Ubuntu Users :

# vi /etc/php5/conf.d/mongo.ini

extension=mongo.so

-- Save & Quit (:wq)

Step: 5. Finally Restart the Apache Service :

For CentOS Users :

# service httpd restart

For Ubuntu Users :

# service apache2 restart

Step: 6. Now Create a info.php File Under /var/www/html & Check the Mongo Driver :

# vi /var/www/html/info.php

<?php
    phpinfo ();
?>

-- Save & Quit (:wq)

http://ip_address/info.php

Thanks For Visiting on My Blog, For More Tutorials Keep Visiting My Blog

Saturday, 16 April 2016

How To Use Iptables Rules For Linux

Iptables Rules For Linux

Q. What is iptables?

 -- It’s the basics of Firewall for Linux. Iptables is a rule based firewall system and it is normally pre-installed on a Unix operating system which is controlling the incoming and outgoing packets. By-default the iptables is running without any rules, we can create, add, edit rules into it.

Rule: 1. Block Specific IP Address in IPtables Firewall :

# iptables -A INPUT -s xxx.xxx.xxx.xxx -j DROP

Note: In case you only want to block TCP traffic from that IP address:

# iptables -A INPUT -p tcp -s xxx.xxx.xxx.xxx -j DROP

Rule: 2. Unblock IP Address in IPtables Firewall :

# iptables -D INPUT -s xxx.xxx.xxx.xxx -j DROP

Rule: 3. Block Specific Port on IPtables Firewall :

# iptables -A OUTPUT -p tcp --dport xxx -j DROP

Rule: 4. To Allow Incoming Connections use :

# iptables -A INPUT -p tcp --dport xxx -j ACCEPT

Rule: 5. Allow Multiple Ports on IPtables using Multiport :

# iptables -A INPUT  -p tcp -m multiport --dports 22,80,443 -j ACCEPT
# iptables -A OUTPUT -p tcp -m multiport --sports 22,80,443 -j ACCEPT

Rule: 6. Allow Specific Network Range on Particular Port on IPtables :

# iptables -A OUTPUT -p tcp -d 192.168.100.0/24 --dport 22 -j ACCEPT

Rule: 7. Block Facebook on IPtables Firewall :

# host facebook.com
facebook.com has address 66.220.156.68

# whois 66.220.156.68 | grep CIDR
CIDR: 66.220.144.0/20

# iptables -A OUTPUT -p tcp -d 66.220.144.0/20 -j DROP

Rule: 8. Setup Port Forwarding in IPtables :

# iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 25 -j REDIRECT --to-port 2525

Rule: 9. Block Network Flood on Apache Port with IPtables :

# iptables -A INPUT -p tcp --dport 80 -m limit --limit 100/minute --limit-burst 200 -j ACCEPT

Rule: 10. Block Incoming Ping Requests on IPtables :

# iptables -A INPUT -p icmp -i eth0 -j DROP

Rule: 11. Allow loopback (127.0.0.1) Access :

# iptables -A INPUT -i lo -j ACCEPT
# iptables -A OUTPUT -o lo -j ACCEPT

Rule: 12. Block Access to Specific MAC Address on IPtables :

# iptables -A INPUT -m mac --mac-source 00:00:00:00:00:00 -j DROP

Rule: 13. Limit the Number of Concurrent Connections per IP Address :

# iptables -A INPUT -p tcp --syn --dport 22 -m connlimit --connlimit-above 3 -j REJECT

Rule: 14. Setup IPtables Rules for PCI Compliance :

# iptables -I INPUT -d SITE -p tcp -m multiport --dports 21,25,110,143,465,587,993,995 -j DROP

If you use cPanel or similar control panel, you may need to block it’s’ ports as well. Here is an example:

# iptables -I in_sg -d DEDI_IP -p tcp -m multiport --dports  2082,2083,2095,2096,2525,2086,2087 -j DROP

Rule: 15. Block Connection on Network Interface :

# iptables -A INPUT -i eth0 -s xxx.xxx.xxx.xxx -j DROP

Rule: 16. Disable Outgoing Mails through IPTables :

# iptables -A OUTPUT -p tcp --dports 25,465,587 -j REJECT

Thanks For Visiting on My Blog, For More Tutorials Keep Visiting My Blog

Thursday, 14 April 2016

How To Install PHP 7 on CentOS/RHEL 6x

Install PHP 7 on CentOS/RHEL 6x


Step: 1. You must add the Webtatic & EPEL yum Repository :

For CentOS/RHEL 7.x :

# rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
# rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

CentOS/RHEL 6.x :

# rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm

Step: 2. Now you can install PHP 7.0 (along with an opcode cache) by doing :

# yum install -y --enablerepo=webtatic-testing php70w php70w-opcache php70w-bcmath php70w-cli php70w-common php70w-dba php70w-devel php70w-embedded php70w-enchant php70w-fpm php70w-gd php70w-imap php70w-interbase php70w-intl php70w-ldap php70w-mbstring php70w-mcrypt php70w-mysql php70w-mysqlnd php70w-odbc php70w-pdo php70w-pdo_dblib php70w-pgsql php70w-process php70w-pspell php70w-recode php70w-snmp php70w-soap php70w-tidy php70w-xml php70w-xmlrpc --skip-broken

Step: 3. Changes on the Module File for Php :

# vi /etc/httpd/conf.d/php.conf

-- Line no. 6 & 10 replace with these Lines.

LoadModule php7_module modules/libphp7.so (replace with line nuber 6)
LoadModule php7_module modules/libphp7-zts.so (replace with line number 10)
AddHandler php7-script .php (replace with line number 16)

-- Save & Quit (:wq)

Step: 4. Create a php info file & Check :

# vi /var/www/html/info.php

<?php
  phpinfo ();
?>

-- Save & Quit (:wq)

# service httpd restart

Check on Browser http://IP-Address/info.php

or Check through CLI :

# php -v

PHP 7.0.0RC2 (cli) (built: Sep  4 2015 21:04:20)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v3.0.0-dev, Copyright (c) 1998-2015 Zend Technologies
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies
   
Thanks For Visiting on My Blog, For More Tutorials Keep Visiting My Blog

Friday, 8 April 2016

MySQL Important Useful Commands

MySQL Important Useful Commands

MySQL Important Useful Commands:

1. MySQL Dump For Single Database :

#
mysqldump --force --opt --single-transaction --lock-tables=false --skip-events --user=root --password=password --routines --databases shockable > /tmp/shockable.sql

2. MySQL Dump For All Databases :

#
mysqldump --force --opt --single-transaction --lock-tables=false --skip-events --user=root --password=password --routines --all-databases > /tmp/all_backups.sql

3. Restore Database from MySQL Dump :

#
mysql -u root -ppassword < /tmp/all_backups.sql

4. Restore a Single Database from All_Databases :

#
mysql -u root -p --one-database destdbname < /tmp/all_databases.sql

5. Backup A Single Table (Table Name: users) :

#
mysqldump -u root -ppassword database_name users > /tmp/users.table.sql

6. Restore that Table :

mysql>
create database database_name;
mysql>
exit

#
mysql -u root -ppassword database_name < /tmp/users.table.sql

7. MySQL Ignore Table :

#
mysqldump -u username -ppasswword --ignore-table=dbname.tablename dbname > /tmp/dbname.sql

8. Show MySQL Database size:

#
mysql -u root -p
Enter the Password:

SELECT table_schema "Data Base Name",
sum( data_length + index_length ) / 1024 /
1024 "Data Base Size in MB",
sum( data_free )/ 1024 / 1024 "Free Space in MB"
FROM information_schema.TABLES
GROUP BY table_schema ;

OR
SELECT 'Total DB Size' SizeInMB,
sum( data_length + index_length ) / 1024 /
1024 "Data Base Size in MB"
FROM information_schema.TABLES
where table_schema not in ('mysql','information_schema');


9. To view individual Database Size in MySQL :

#
mysql -u root -p
Enter the Password:

SELECT table_schema                                        "DB Name",
   Round(Sum(data_length + index_length) / 1024 / 1024, 1) "DB Size in MB"
FROM   information_schema.tables
GROUP  BY table_schema;

OR
SELECT table_schema,
sum( data_length + index_length ) / 1024 /
1024 "Data Base Size in MB"
FROM information_schema.TABLES
where table_schema not in ('mysql','information_schema','performance_schema')
group by table_schema
order by 2 desc;


10. MySQL Cluster Status :

#
mysql -u root -p
Enter the Password:

mysql> show status like 'wsrep%';

11. To Check MySQl Cluster is Synced or Not :
# /usr/bin/clustercheck root root_password

Thanks For Visiting on My Blog, For More Tutorials Keep Visiting My Blog

 
Copyright © 2016 Kousik Chatterjee's Blog