Saturday, 13 September 2014

Setup a CentOS IPSEC VPN Server

Install the Nikoforge Repository


rpm -ivH http://repo.nikoforge.org/redhat/el6/nikoforge-release-latest


Install EPEL Repo


yum -y install http://vesta.informatik.rwth-aachen.de/ftp/pub/Linux/fedora-epel/6/i386/epel-release-6-8.noarch.rpm


Install IPSEC Tools


yum -y install ipsec-tools


The ipsec-tools package from the nikoforge repo is a patched version that allow the use of a wildcard ‘’ as the IPSec identifier [1]. Not needed for Android, but iOS.*


Install Layer 2 Tunneling Protocol Daemon


yum -y install xl2tpd


Create script ”/etc/racoon/init.sh”


Insert the following:


    #!/bin/sh
# set security policies
echo -e “flush;n
spdflush;n
spdadd 0.0.0.0/0[0] 0.0.0.0/0[1701] udp -P in ipsec esp/transport//require;n
spdadd 0.0.0.0/0[1701] 0.0.0.0/0[0] udp -P out ipsec esp/transport//require;n”
| setkey -c
# enable IP forwarding
echo 1 > /proc/sys/net/ipv4/ip_forward


Then set the correct permissions


chmod 750 /etc/racoon/init.sh


Add a call of the script to rc.local


sed –in-place ‘//etc/racoon/init.sh/d’ /etc/rc.d/rc.local
echo /etc/racoon/init.sh >> /etc/rc.d/rc.local


IPSEC CONFIGURATION


Racoon Config ”/etc/racoon/racoon.conf” (If there is one already there, bcack it up to .old)


path include “/etc/racoon”;
path pre_shared_key “/etc/racoon/psk.txt”;
path certificate “/etc/racoon/certs”;
path script “/etc/racoon/scripts”;
remote anonymous
{
exchange_mode aggressive,main;
passive on;
proposal_check obey;
support_proxy on;
nat_traversal on;
ike_frag on;
dpd_delay 20;
proposal
{
encryption_algorithm aes;
hash_algorithm sha1;
authentication_method pre_shared_key;
dh_group modp1024;
}
proposal
{
encryption_algorithm 3des;
hash_algorithm sha1;
authentication_method pre_shared_key;
dh_group modp1024;
}
}
sainfo anonymous
{
encryption_algorithm aes,3des;
authentication_algorithm hmac_sha1;
compression_algorithm deflate;
pfs_group modp1024;
}


Set the relevant permissions


chmod 600 /etc/racoon/racoon.conf


Racoon Pre shared Keys


Create the pre-shared keys file for IKE authentication. The 1st column the IPSec Identifier, the 2nd column is the IPSec preshared key.


”/etc/racoon/psk.txt”


ANDROID


myhomelan d41d8cd98f00b204e980


IOS



* d41d8cd98f00b204e980




Set the correct permissions



chmod 600 /etc/racoon/psk.txt



CONFIGURING L2TP DAEMON


Create file ”/etc/xl2tpd/xl2tpd.conf




[global]
ipsec saref = yes
force userspace = yes
[lns default]
local ip = 10.203.123.200
ip range = 10.203.123.201-10.203.123.210
refuse pap = yes
require authentication = yes
ppp debug = yes
length bit = yes
pppoptfile = /etc/ppp/options.xl2tpd



CONFIGURING PPP


Create PPP option file ”/etc/ppp/options.xl2tpd



    ms-dns 10.203.120.41
ms-dns 8.8.8.8
require-mschap-v2
asyncmap 0
auth
crtscts
lock
hide-password
modem
debug
name l2tpd
proxyarp
lcp-echo-interval 10
lcp-echo-failure 100



Create the CHAP Secrets file ”/etc/ppp/chap-secrets”



    # client server secret IP addresses
janedoe * jd480227 *



Set the Correct permissions


 


chmod 600 /etc/ppp/chap-secrets


START THE SERVICES


    chkconfig racoon on
chkconfig xl2tpd on
service racoon start
service xl2tpd start
/etc/racoon/init.sh


ANDROID CLIENT SETUP


    NAME – ANYTHING
TYPE – L2TP/IPSec PSK
SERVER ADDRESS – IP or hostname of server
L2TP SECRET – NOT USED
IPSec IDENTIFIER – what was set in first colum of racoon psk file
PRE-SHARED KEY – What was in the second column of racoon psk file


For my VPS to pass traffic through i had to execute the following


iptables –table nat –append POSTROUTING –jump MASQUERADE


echo “net.ipv4.ip_forward = 1? | tee -a /etc/sysctl.conf
echo “net.ipv4.conf.all.accept_redirects = 0? | tee -a /etc/sysctl.conf
echo “net.ipv4.conf.all.send_redirects = 0? | tee -a /etc/sysctl.conf
for vpn in /proc/sys/net/ipv4/conf/*; do echo 0 > $vpn/accept_redirects; echo 0 > $vpn/send_redirects; done
sysctl -p


for vpn in /proc/sys/net/ipv4/conf/*; do echo 0 > $vpn/accept_redirects; echo 0 > $vpn/send_redirects; done
iptables –table nat –append POSTROUTING –jump MASQUERADE


 

What is PHP Composer?

If you have ever written anything in PHP before, you have probably found that it feels like you have to keep re-inventing the wheel anytime you want to do a common task such as User Authentication, Database Management or Request Routing. PHP now has a handful of mature frameworks that have already solved all of these problems, so wouldn’t it be easier to cherry pick the bits that you needed from each framework?


If you were to start manually picking the bits you wanted from Zend, or Laravel or Symfony, then it would become very difficult to manage. Each library might also have dependencies, and so you would end up in a mess, particularly if you required other people to work on your project.


This is where Composer comes in. Composer is a dependency manager for PHP. Composer will manage the dependencies you require on a project by project basis. This means that Composer will pull in all the required libraries, dependencies and manage them all in one place.


This kind of management for dependencies in a project is not a new concept, and in fact, much of Composer is actually inspired from npm from Node.js and Bundler from Ruby.


You might also be aware of PEAR. PEAR is an established PHP package manager that has been around for years. PEAR however, has been abandoned by many PHP developers for a number of reasons. Firstly, much of the code in PEAR is out-of-date. Secondly, PEAR forces you to install packages system wide, rather than on a project-by-project basis. This means that if you already have a project that relies on a slightly older package, you are screwed. For an excellent history of PHP packages, read Packages: The Way Forward for PHP by Phil Sturgeon.


Installing Composer


Installing Composer is really easy as it can all be done through the command line. I’m using OS X, but the following should be the same for any *nix operating system.


So fire up Terminal and run the following commands:


$ curl -s https://getcomposer.org/installer | php
$ sudo mv composer.phar /usr/local/bin/composer


The first command downloads the composer.phar file to your computer. The second line moves the composer.phar file in to your bin so that is accessible globally on your computer.


Now run the following command:


$ composer


If you have installed Composer successfully, you should be given a list of available commands and descriptions.
Installing on Windows?


If you are looking to install Composer on a Windows machine, take a look at the guide on the Composer website.
Using Composer


Now that you have Composer installed, you can use it to require some packages into your project. To make a Composer configuration file, we just need to make a JSON file in the root of the project.


For example, if you wanted to use Slim Framework you could create the following composer.json file.


{
"require": {
"slim/slim": "2.*"
}
}


To install Slim via Composer, you can simply run the following command through Terminal.


$ composer install


This will automatically download Slim into your project under the directory vendor/slim/slim.


See, how easy was that?
Autoloading


Now that you have all of these different packages, you need the ability to autoload them into your project. Fortunately Composer also comes with an autoload file, which is capable of autoloading any of the files in the projects that you download.


To use the Composer autoloader, simply include the following line in your project’s index or bootstrap file.


require 'vendor/autoload.php';


Now you can start using the new libraries without having to worry about loading them up.


For example:


// Autoload
require 'vendor/autoload.php';


// Instantiate a Slim application
$app = new SlimSlim();


// Define a HTTP GET route
$app->get('/hello/:name', function ($name) {
echo "Hello, $name";
});


// Run the Slim application
$app->run();
Conclusion


Package management is clearly the right route forward for PHP. Languages such as Ruby have shown how incredibly easy it is to use packages within projects so common problems can be solved once, and you can stop wasting time as a developer by constantly reinventing the wheel.


Many of the most popular frameworks have already positioned themselves to use Composer, and many more individual developers are releasing code that is Composer ready from the get go.


As a PHP developer, Composer will become your best friend, and as it’s usage increases, it will become an essential part of writing PHP on a day-to-day basis.


By following conventions, PHP can become a much better language to use. Composer has already solved a big problem in the PHP community, so there’s really no reason why you shouldn’t start using it today.

How to install htop

To install htop with yum, the EPEL repository must be installed.

Redhat / CentOS 5 (most likely version in use)


32bit: rpm -Uvh http://download.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
64bit: rpm -Uvh http://download.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm

Redhat / CentOS 6


32bit: rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
64bit: rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

Now that the repository is installed to the server, we can install htop
yum install htop

 

Tuesday, 9 September 2014

Install NixTree PHP Selector in CloudLinux cPanel server

NixTree PHP Selector plugin allows a domain user to select preferred PHP version per directory on the same domain.
Note :This plugin requires SuPHP on the system; it will not work with any other PHP handlers for now.

To install ntPHPselector, run the following commands:

cd /usr/local/src
wget -N http://nixtree.com/download/free/ntphpselector_manage.sh
sh ntphpselector_manage.sh install


To recompile php in ntPHPselector, run the following command:

sh ntphpselector_manage.sh recompile <option>


– option
2 for 5.2
3 for 5.3
4 for 5.4
5 for 5.5

eg: recompile php5.2

sh ntphpselector_manage.sh recompile 2


For uninstalling the plugin:

sh ntphpselector_manage.sh uninstall

Tuesday, 19 August 2014

Block an Email in Plesk

Although Plesk has a built-in spam filter that blocks most spam messages from reaching your email account, some unwanted messages may slip past it unhindered. To rectify this issue, you must make use of the spam filter’s blacklist function to stop receiving messages from a particular email address in the future. In addition to blocking email addresses individually, you can also configure the Plesk spam filter to block all email addresses related to a particular domain.



1 ). Sign in to your Plesk Control Panel.



2). Click the “Mail” tab, and then select an email account from the list under “Email Address.”



3). Click the “Spam Filter” tab. If unchecked, check the box next to “Switch on Spam Filtering for This Email Address,” and then click the “Show Advanced Settings” option below.



4). Enter the email address that you want blocked into the vacant text box next to “Black List.” To block multiple email addresses, press “Enter” after inserting each address into the text box. To block all incoming email from addresses related to a particular domain, enter "*@domain_name.com” (without quotes), replacing "domain_name.com" with the name of the domain.



5). Click “OK” to save the changes.

Monday, 30 June 2014

How to Install htop

To install htop with yum, the EPEL repository must be installed.

Redhat / CentOS 5 (most likely version in use)



32bit: rpm -Uvh http://download.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
64bit: rpm -Uvh http://download.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm


Redhat / CentOS 6



32bit: rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
64bit: rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm


Now that the repository is installed to the server, we can install htop

yum install htop


 

Thursday, 26 June 2014

How to Disable magic quotes Joomla on Linux Server

Error while accessing modsec control from WHM :Software error

Can’t locate JSON/XS.pm in @INC (@INC contains: /usr/local/cpanel /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl /usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/5.8.8 .) at /usr/local/cpanel/Cpanel/JSON.pm line 15.


You can disable magic quotes in joomla by adding the following line to the php.ini file.

magic_quotes_gpc = Off


If it did’t solver the issue you need to add the following lines to the php5.ini in the document-root.

magic_quotes_gpc = Off
magic_quotes_runtime = Off
magic_quotes_sybase = Off
extension=pdo.so
extension=pdo_mysql.so


If the file php5.ini is not there in the document root, then you can rename the php.ini as php.ini.

Also after adding this you need to add the following lines on the .htaccess file. If there is no .htaccess then you can create a new file and add the following codes to it,

SetEnv PHPRC /home/$username/public_html/

Note : Replace the path “/home/$username/public_html/” properly with your path.