Friday, September 9, 2016

SVN Installation in Cpanel

In order to install SVN in server, we need mod_dav module in cpanel. Run the following command and check if the below modules are present:

httpd -M | grep dav
 dav_module (static)
 dav_fs_module (static)
 dav_lock_module (static)
 dav_svn_module (shared)

If dav_module is not installed in the server, you can enable it by running easyapache in the server. Enable DAV, DAVfs, DAVLock from the apache modules and build apache.

Next step is to install subversion in the server. For that, perform the following steps:

cd /usr/local/src/
wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.1-1.el5.rf.x86_64.rpm
rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt
rpm -K rpmforge-release-0.5.1-1.el5.rf.x86_64.rpm
rpm -i rpmforge-release-0.5.1-1.el5.rf.x86_64.rpm

Once the repository is installed, install subversion using the following command:

yum --enablerepo=rpmforge install subversion

Now to build dav_svn_module, perform the following steps:

cd /usr/local/src
wget http://subversion.tigris.org/downloads/subversion-1.6.3.tar.bz2
tar xfj subversion-1.6.3.tar.bz2
cd subversion-1.6.3
./configure --with-apxs=/usr/local/apache/bin/apxs --with-apr=/home/cpeasyapache/src/httpd-2.2.21/srclib/apr --with-apr-util=/home/cpeasyapache/src/httpd-2.2.21/srclib/apr-util
make
make install

If you get an error that sqlite-amalgamation needs to be installed, perform the following steps:

cd /usr/local/src
wget http://www.sqlite.org/sqlite-amalgamation-3.6.13.tar.gz
tar -zxvf sqlite-amalgamation-3.6.13.tar.gz
cd subversion-1.6.3
mkdir sqlite-amalgamation
cp ../sqlite-3.6.13/sqlite3.c ./sqlite-amalgamation/

Then build it again using the following commands:

./configure --with-apxs=/usr/local/apache/bin/apxs --with-apr=/home/cpeasyapache/src/httpd-2.2.21/srclib/apr --with-apr-util=/home/cpeasyapache/src/httpd-2.2.21/srclib/apr-util
make
make install

Now we need to configure apache and subversion.

mkdir -p /usr/local/apache/conf/userdata/std/2/<user>/<domain>/

vi svn.conf

Add the following lines to the file svn.conf

<IfModule mod_dav_svn.c>
 <location name_of_svn>
  DAV svn
  SVNPath /home/<username>/public_html/name_of_svn
  AuthType Basic
  AuthName "SVN Repo"
  AuthUserFile /home/<username>/.svn.htpasswd
  Require valid-user
 </location>
</IfModule>

Add the username and password in the file /home/<username>/.svn.htpasswd
using htpasswd command

htpasswd -cm /home/<username>/.svn.htpasswd username

In the file /usr/local/apache/conf/includes/pre_main_2.conf, add the following:

LoadModule dav_svn_module /etc/httpd/modules/mod_dav_svn.so
LoadModule authz_svn_module /etc/httpd/modules/mod_authz_svn.so

Now we need to create the SVn repository.

cd /home/<username>/public_html/
svnadmin create name_of_svn
chown -R user:user name_of_svn
chmod -R 775 name_of_svn

Now rebuild apache config and restart apache using the following commands:

/scripts/ensure_vhost_includes --user=username
/scripts/rebuildhttpdconf
/scripts/restartsrv_httpd

That's all.

SolusVM installation steps

Please don't install and compile Mysql,PHP,APACHE manually on the node before installing SolumVM panel. (Mysql,PHP will get installed automatically during the SolumVM installation )

If any of these modules already exist on the server. The panel will not work properly. The PHP/Mysql may conflict/mess with the PHP and MYSQL installed by the panel during its installation time and will loose php.ini file.

So in a fresh server after setting up OVZ kernel, start install the panel directly (manual installation of apache/php and mysql is not recommended on the NODE.)


Steps used to install SolumVM in an openVZ node

***************

*wget http://soluslabs.com/installers/solusvm/install

* chmod 755 install

* ./install

Get a configuration window

Here choose '1' >>master privileged panel will be installed.

On next step also choose '1'>> to install the panel with privilege for doing virtualisation.

*******************

Access the panel from the url::http://server_IP:5353/admincp/login.php

username:vpsadmin
password:vpsadmin
**********************

Ref url:http://wiki.solusvm.com/index.php/Install
Ref url:http://aparnam.wordpress.com/2010/07/25/installing-master-openvz-solusvm-vps-management-control-panel-on-linux-server/




Errors after trial installation.

****************

*IF we manually install and compile the main modules ( apache/php and mysql), we will be facing the following errors.

When we access the solusvm url: http://ip:5353/admincp/login.php on the browser we will get an error

-----
error:There seems to have been a slight problem with our database, please try again later
-----

This usually occurs when the SolusVM MySQL installation conflict with an existing MySQL instance.

To fix this problem run the following on the node:

#yum remove mysql*

Now run the SolusVM installer again.

* After installation When try to create a new VPS via panel. We will get an ''connection error''.

Now please uninstall all phpmodules and mysql again then move the /usr/local/solusvm. Then try a fresh installation.

**************



 ****************
While trying to login http://Ip:5353/admin roll back to same login page
****************
Issue is because solusvm is unable to create sessions. So you need to create directory:"sessions" under /usr/local/solusvm/ with user and group solusvm
[root@test /]# cd /usr/local/solusvm/
[root@test solusvm]# mkdir sessions
[root@test solusvm]#chown solusvm:solusvm sessions



*****************
If you are getting acl error "Error:You don't have permission to perform this action"
*****************
This issue may because of missing solusvm db tables. Issue commonly occurs in 64 bit os. A solusvm database from a successfull installation contains following tables
-------------------------------

mysql> show tables;
+-------------------------+
| Tables_in_SolusVMmrd1GI |
+-------------------------+
| adminacl                |
| administrators          |
| adminlog                |
| adminnotes              |
| adminwhitelist          |
| api                     |
| apilog                  |
| authenticationlog       |
| backupservers           |
| bandwidthstatistics     |
| buycpanel               |
| centralbackup           |
| clientapi               |
| clientlog               |
| clients                 |
| configuration           |
| crontab                 |
| customemailtemplates    |
| dnsplans                |
| dnsservergroups         |
| dnsservers              |
| emailtemplates          |
| ftpservers              |
| hvmtemplates            |
| internalips             |
| ipaddresses             |
| ipblocknodes            |
| ipblocks                |
| ipv6                    |
| isos                    |
| keymaps                 |
| kvmdata                 |
| license                 |
| links                   |
| mediagroups             |
| nodegroups              |
| nodes                   |
| pdns                    |
| plans                   |
| s_bandwidth             |
| smslog                  |
| syscheck                |
| systemmessages          |
| templates               |
| version                 |
| vservers                |
| vzdata                  |
| xendata                 |
+-------------------------+

If some of these tables are not there then you need to perform installation again. For that remove all mysql & php packes from previous installations:

check for mysql packages using rpm -qa | grep mysql and using " yum remove " remove all those packages. Do the same for php too.
After that remove /var/lib/mysql directory and /root/.my.cnf file

Once this is done start installation using legacy solusvm installer because latest installer may not work on few centos releases. For the legacy (old one)  instaler to work, you need /lib/ld-linux.so.2. This is provided by glibc 32 bit rpm installed. If server is 64 bit and that package was not installed then check for a line "exclude=*.i?86" in /etc/yum.conf and comment it so that 32 bit rpm can be installed. Once this is done issue command " yum install glibc "

After this do a fresh installation with legacy installer version 1 and issue should be fixed.

Tuesday, September 6, 2016

Custom PHP in CGI

For creating custom php.ini you will need to create a file called php5.cgi
under the public_html directory of the user. The php5.cgi must contain the
following code in it.

#############
#!/bin/sh
exec /usr/local/cpanel/cgi-sys/php5 -c /home/username/public_html/php.ini
#############

The php4.cgi must have execute permissions and correct ownership.

chmod 755 /home/username/public_html/php5.cgi

chown username.username /home/username/public_html/php5.cgi

Once this is done, create a .htaccess in the directory you need custom
php4 and add the following code in it.

###########
AddHandler application/x-httpd-php .php
Action application/x-httpd-php /php5.cgi
###########

Once the is done, you can create a custom php.ini in public_html.

Thats all!!

Sunday, September 4, 2016

The TCP/IP Reference Model



The TCP/IP Reference Model  is the advanced model of communication. This reference model is used current Internet architecture. TCP/IP model is based on standard protocols around which the Internet has developed. It is a communication protocol, which allows connection of hosts over a network.


Diagrammatic Comparison between OSI Reference Model and TCP/IP Reference Model

 ******************************************************************************


Layer 1: Host-to-network Layer: Network Access Layer is the first layer of the four layer TCP/IP model. Network Access Layer defines details of how data is physically sent through the network, including how bits are electrically or optically signaled by hardware devices that interface directly with a network medium, such as coaxial cable, optical fiber, or twisted pair copper wire.

 

Layer 2: Internet layer: Internet Layer is the second layer of the four layer TCP/IP model. The position of Internet layer is between Network Access Layer and Transport layer. Internet layer pack data into data packets known as IP datagrams, which contain source and destination address (logical address or IP address) information that is used to forward the datagrams between hosts and across networks. The Internet layer is also responsible for routing of IP datagrams.

 

Layer 3: Transport Layer: Transport Layer is the third layer of the four layer TCP/IP model. The position of the Transport layer is between Application layer and Internet layer. The purpose of Transport layer is to permit devices on the source and destination hosts to carry on a conversation. Transport layer defines the level of service and status of the connection used when transporting data.

 


Layer 4: Application Layer: Application layer is the top most layer of four layer TCP/IP model. Application layer is present on the top of the Transport layer. Application layer defines TCP/IP application protocols and how host programs interface with Transport layer services to use the network.

 

Thursday, September 1, 2016

The Securetmp Script


This is a well known script in cPanel. This script can be used for two purpose. One is for prevents users from the use of malicious code in the /tmp and the /var/tmp directories. All users can write to the /tmp directory (with the securetmp in place) with noshell, normal, and jailshell accounts. The other use is to increase the /tmp partion.



Following detail would help to increase /tmp partition on cPanel.



Steps:



Login to server by SSH.



Stop the services using /tmp partition, those usually are cpanel, mysql and httpd.



/etc/init.d/cpanel stop

/etc/init.d/httpd stop

/etc/init.d/mysql stop





Make sure that no other processes are running using /tmp partion. This can be checked by following command.



lsof | grep /tmp





If you find any proceess, stop them by the PID.



Now, umount /tmp and /var/tmp, run this commands



umount -l /tmp

umount -l /var/tmp



Backup your current /usr/tmpDKS directory



mv /usr/tmpDSK /usr/tmpDSK.bkp



Edit the file /scripts/securetmp



In the file /scripts/securetmp you can find a section called #Global Variables with this line:



my $tmpdsksize = 512000;


You should be able to edit the file and increase the size as your wish.



Save the file



Re-create the /tmp partition by running by following command



/scripts/securetmp



Start cPanel, httpd and mysql service



Check the /tmp partion now.





Thats all



How to Prevent Apache graceful restart


Introduction



If we check the Apache error logs, we could see httpd getting restarted gracefully every two hours. During this time some users experinces a slight slowness of their website. The reason the restarts occur is that Apache must be restarted to grab the new logs file handles. If Apache were not restarted, bandwidth/stats would fail to log and that data be lost.





# grep Graceful /usr/local/apache/logs/error_log

[Tue Aug 25 14:14:22 2015] [notice] Graceful restart requested, doing restart

[Tue Aug 25 19:15:03 2015] [notice] Graceful restart requested, doing restart

[Wed Aug 26 00:57:45 2015] [notice] Graceful restart requested, doing restart

[Wed Aug 26 01:47:50 2015] [notice] Graceful restart requested, doing restart

[Wed Aug 26 02:37:54 2015] [notice] Graceful restart requested, doing restart

[Wed Aug 26 11:07:03 2015] [notice] Graceful restart requested, doing restart



This can be fixed by enabling piped Apache logs. Piped Apache logs reduce the number of open file handles on a server and eliminate the need for Apache to be restarted during stats/bandwidth logging



Requirment



We require root access to the server in order to implement piped logging.



Steps.



There are two possibel methods to enable piped logging. This can be done either by command line terminal or from WHM interface.



Step1: Command line


Login as root via SSH


Make a backup of the Apache configuration file


cp -rp /usr/local/apache/conf/httpd.conf /usr/local/apache/conf/httpd.conf_backpiped



Edit /var/cpanel/cpanel.config:





vi /var/cpanel/cpanel.config



Make effect the changes in cpanel configuration. Run following command





/usr/local/cpanel/whostmgr/bin/whostmgr2 --updatetweaksettings



Rebuild the Apache config:



/scripts/rebuildhttpdconf



Stop and Start Apache:



/etc/init.d/httpd stop



/etc/init.d/httpd start





Step2: From WHM interface



Make a backup of the Apache configuration file


cp -rp /usr/local/apache/conf/httpd.conf /usr/local/apache/conf/httpd.conf_backpiped



Login to WHM



Go to WHM » Service Configuration » Apache Configuration » Piped Log Configuration



Check the box labeled Enable piped Apache logs.



Thats all!!


Disbale custom php.ini for user.


One of the biggest security challenge in server is php exploitation. Attackers can alter php.ini settings in users directory and they can easily deface the files. If you are uing suPHP handler in server, we can prevent this type of exploitation by configuring the server to force the use of the main server wide php.ini file and disable the use of custom php.ini. suPHP forces PHP scripts to run as the cPanel user, and this is a huge advantage over DSO handler and it enhances overall server security.




Requiremet



Require root previlage



PHP handler should be suPHP




Steps



Login as root via SSH.



Edit the file /opt/suphp/etc/suphp.conf



vi /opt/suphp/etc/suphp.conf



Search for [phprc_paths] and then uncomment the following lines:



;application/x-httpd-php=/usr/local/lib/

;application/x-httpd-php4=/usr/local/php4/lib/

;application/x-httpd-php5=/usr/local/lib/



This is to configuring the server to force the use of the main server wide php.ini file and disable the use of custom php.ini



Save the file and restart Apache



service httpd restart



if any client require custom PHP settings, we can do it directly by editing the file /usr/local/lib/php.ini and place user-based configurations at the end of the file.





Vi /usr/local/lib/php.ini



Exapmple:



[PATH=/home/bob/public_html/]

memory_limit = 128M





[PATH=/home/david/public_html/]

display_errors = On

upload_max_filesize = 160M



Save the file and restart httpd:



Thats all!!

Awstats not updating In cpanel server.


Introduction



AWStats is a free powerful and featureful tool that generates advanced web, streaming, ftp or mail server statistics, graphically. Sometimes it may not get updated. We can manually resolve this issue by some methods.



Requiremet



Requires root user privilage




Steps



Step 1: Login to server via SSH



Check permission of /usr/local/cpanel/3rdparty/bin/awstats.pl, it should be 755





Step 2: Execte following cPanel script command





- /scripts/runweblogs username , replace username with cPanel username




If the above command does not fx the issue, you can use another cPanel scripts.



- /scripts/fixwebalizer username



- /scripts/runstatsonce





Step 3: If none of the above steps works, we have to check whether domlog files are getting updated or not. Sometimes domlogs may not be get updated as it disabled in Apache configuration files. If it is disabled Awstat will not show updated informtaion. We can enable this by following method.



Open the apache conf with your favourate editor.



vi /usr/local/apache/conf/httpd.conf



Search for the line "ErrorLog /usr/local/apache/logs/error_log" and just below that add following lines.



LogFormat “%h %l %u %t “%r” %>s %b “%{Referer}i” “%{User-Agent}i”” combined

LogFormat “%{Referer}i -> %U” referer

LogFormat “%h %l %u %t “%r” %>s %b” common

LogFormat “%{User-agent}i” agent





Save the file


Run following command to distll Apache.



/usr/local/cpanel/bin/apache_conf_distiller –update


Restart Apache


/scripts/restartsrv_httpd

Acess webaliazer from URL without login cPanel


Intrdouction



The Webalizer interface displays traffic statistics from the Webalizer statistics program. Usually webaliazer is accessed from cPanel menu, but we can make webaliazer stats accessible from a URL without login cPanel.



Requirement



Requires root user privilage



Steps



- Navigate to the user's public_html directory by following command



cd /home/username/public_html





- Add following line to .htaccess file.





Options +FollowSymLinks





- Create a directory "webstats"



mkdir webstats





chown -R username.username webstats





Next, run the following command to create a symlink between webalizer raw data and newly created directory



ln -s /home/username/tmp/webalizer webstats



Now you can access http://www.domain.com/webstats/ to access your webalizer statistics.



Thats all!!


PHP Extension manager in cPanel server


PHP extensiion manager is a cPanel script to install PHP extensions in cPanel server. This is a easy way to install PHP extension without running EasyApache.



Following command is used to get the list of availabe PHP extension.



#/scripts/phpextensionmgr list

Available Extensions:

EAccelerator

IonCubeLoader

Zendopt

Xcache

SourceGuardian

PHPSuHosin



Following command is used for check the status of the extension module.



/scripts/phpextensionmgr status <extension> ,replace <extension> with the module that you wish to install





Installation of PHP extension is a simple process. Following command is used for installing extension




/scripts/phpextensionmgr install <extension> ,replace <extension> with the module that you wish to install





Following command is used for installing extension



/scripts/phpextensionmgr uninstall <extension> ,replace <extension> with the module that you wish to install




Thats all