Backup using /scripts/pkgacct and Restoring


Log-in to the Server as root


Grep Domain to get the username
--------------------------------------------
[root@server ~]$ grep domainname /etc/userdomains
example

[root@server ~]$ /scripts/pkgacct example



After Full Backup move it to user's public_html so that user can download it
-----------------------------------------------------------------------------------------------
[root@server ~]$ cp cpmove-example.tar.gz /home/example/www/



Give Appropriate Permissions and Assign Ownership
-------------------------------------------------------------------
[root@server ~]$ cd /home/example/www
[root@server www]$ chmod 755 cpmove-example.tar.gz
[root@server www]$ chown example.example cpmove-example.tar.gz



RESTORING PACKAGE
---------------------------
[root@server ~]$ /scripts/restorepkg example

DONE !

.htaccess redirect rules


.htaccess redirect rules


Use below mentioned .htaccess rules as per your requirment.

#// This allows you to redirect your entire website to any other domain
Redirect 301 / http://example.com



#// This allows you to redirect your entire website to any other domain
Redirect 302 / http://mt-example.com/


#//  This allows you to redirect index.html to a specific subfolder
Redirect /index.html http://example.com/newdirectory/



#//  Redirect old file path to new file path
Redirect /olddirectory/oldfile.html http://example.com/newdirectory/newfile.html


#//  Provide Specific Index Page (Set the default handler)
DirectoryIndex index.html

Hpe this will help you lot :)

Change main domain to subfolder


Change main domain to subfolder

Use below mentiond .htaccess rule in your document root in order to redirect your main domain to subdomain without changing the url.

=============================================================
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?main\-domain.com$ [NC]
RewriteCond %{REQUEST_URI} !^/sub\-folder/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /sub-folder/$1
RewriteCond %{HTTP_HOST} ^(www.)?main\-domain.com$ [NC]
RewriteRule ^(/)?$ sub-folder/index.php [L]
============================================================

WEBSERVER

PACKAGES NEEDED FOR CONFIGURATION

httpd

IF THE PACKAGES ARE NOT AVAILABLE INSTALL THROUGH YUM INSTALLER

yum install httpd

THE MAIN CONFIGURATION CAN BE EDITED AS FOLLOWS

vim /etc/httpd/conf/httpd.conf

shift+g==>

<VirtualHost 192.168.0.X:80>
DocumentRoot /var/www/html
ServerName stationX.example.com
</VirtualHost>

PHP handlers for Apache


In this article, I'll explain about the PHP Handlers on Apache Web server which are widely discussed in the context of Hosting Industry. There are two ways to configure Apache to use PHP :

(1) Configure Apache to load the PHP interpreter as an Apache module (DSO)
(2) Configure Apache to run the PHP interpreter as a CGI binary (CGI)


PHP Handlers

A handler is a piece of code built into Apache that performs certain actions when a file with a particular MIME or handler type is called. PHP handlers are the programs that interpret the PHP code in your web application and process it to be sent as HTML (or another static format which the web browser understands) by your web server. None of the major web servers available today can handle PHP by themselves which is why they need another program to do it for them. This program, known as a PHP handler takes all the PHP code and generates the output which is then sent to the web server which forwards it on to the user upon request. Currently there are Four major PHP handlers available on Apache. They are CGI, DSO, suPHP, & FastCGI. Each handler delivers the libraries through different files and implementations. Each file and implementation affects Apache’s performance, because it determines how Apache serves PHP. I will be explaining these handlers one by one from here.

Addon Domain

Addon domain?

The addon domain option within cPanel allows you to host multiple websites/domains under a single cPanel account. You can give e-mail accounts and forwarders for domains added. All analytics are calculated separately.

To create a second domain in your hosting account, please do the following:

Login to your cPanel account and click Addon Domains, under Domains tab. There are Four fields cPanel asks for when creating an Addon Domain.

1. New Domain name

2. Subdomain/FTP username.

3. Document root.

4. Password.

How to Remove an Addon Domain from cPanel

If you have an Addon Domain set up and would like delete it, please do the following:
  1. Login to your cPanel and click Addon Domains.
  2. At the bottom, under Actions, click Remove.
Please note removing the addon domain only removes the domain from the DNS and server configuration. Your files and databases are not deleted or affected by removing the addon domain.


I hope this post will help you lot.

.htaccess error reporting (PHP)

Ihave added below mentioned line in .htaccess file inorder to display PHP error.

php_flag display_startup_errors on
php_flag display_errors on
php_flag html_errors on


In some case you may face some errors like "Internal server error" while adding above lines. In such cases use below mentioned lines in your .htaccess file.

php_flag display_startup_errors on
php_flag display_errors on
php_flag html_errors on
php_flag  log_errors on
php_value error_log  /home/path/public_html/domain/PHP_errors.log


Hope this will help you  :)

List of services and corresponding runlevels


Run levels
================
On the console, you use the chkconfig tool list and specify which services to run at different
runlevels.

List of services and corresponding runlevels

[root@server ~]# chkconfig --list
acpi-support              0:off  1:off  2:on   3:on   4:on   5:on   6:off
acpid                     0:off  1:off  2:off  3:off  4:off  5:off  6:off
alsa-restore              0:off  1:off  2:off  3:off  4:off  5:off  6:off
alsa-store                0:off  1:off  2:off  3:off  4:off  5:off  6:off
anacron                   0:off  1:off  2:off  3:off  4:off  5:off  6:off
apparmor                  0:off  1:off  2:off  3:off  4:off  5:off  6:off  S:on
apport                    0:off  1:off  2:off  3:off  4:off  5:off  6:off
atd                       0:off  1:off  2:off  3:off  4:off  5:off  6:off
autofs                    0:off  1:off  2:off  3:off  4:off  5:off  6:off
avahi-daemon              0:off  1:off  2:off  3:off  4:off  5:off  6:off
bind9                     0:off  1:off  2:on   3:on   4:on   5:on   6:off
binfmt-support            0:off  1:off  2:off  3:off  4:off  5:off  6:off
bluetooth                 0:off  1:off  2:off  3:off  4:off  5:off  6:off
bootlogd                  0:off  1:off  2:off  3:off  4:off  5:off  6:off
brltty                    0:off  1:off  2:off  3:off  4:off  5:off  6:off  S:on

Apache Semaphore issue


Semaphore issues
This is one of the rarest conditions which I came across. The webserver failed to load with following error messages in the server log file. The server had fairly good uptime and was a busy server.

============================================================
[emerg] (28)No space left on device: Couldn't create accept lock
[notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[notice] Digest: generating secret for digest authentication ...
[notice] Digest: done
[warn] pid file /etc/httpd/run/httpd.pid overwritten -- Unclean shutdown of previous Apache run?
[emerg] (28)No space left on device: Couldn't create accept lock
 ===========================================================

Apache service issue - Module issues

Module issues


Apache may experience issues  to load apache modules configured . The error log will contain the information indicating the issue. In such cases, make sure the  .so file of the module is present in the correct location and it is accessible. If the location is correct check whether the module has any issues. You can check it using the command “ldd
A sample output would look like this


root@redhat003 [/usr/local/apache/modules]# ls
 
./   httpd.exp   ../   mod_hostinglimits.so* mod_security2.so

Apache service issue - Unable to bind to port

Unable to bind to port

The webserver will fail to bind to the concerned port i.e. 80 if it is open by another process. In such cases, we need to identify the process which occupies the port and need to terminate it.The following command will show the existing connections to port 80

#netstat -an | grep \\.80


or
You can identify the apache process using the command as well

# pgrep httpd

or
The process associated with the port number using the following command:

#lsof -i tcp:80


Apache service issue Log file size


Log file size

Older kernal versions may not be capable of handling files more than 2 GB.  This creates issue for apache if the size of error_log exceeds 2 GB. In such cases, simply clearing the log file alone fix the issue.

# : > /usr/local/apache/logs/error_log

Whitelist Mod_security rules for a CPanel account


Preface:
Sometimes you may arise an issue like this. When a client tries to install IFrames he gots the following error

"you don't have permission to access /e107_admin/cpage.php on this server"


This issue arises due to this installtion is blocked by a mod_security rule

Recover the issue
First  you’ll need to get the Rule ID number. You can find these either in the apache error log (grep for your IP) or if you have CSF installed and keep getting your IP blocked, check /etc/csf/csf.deny to see if its listing the mod_security rule that you were blocked from.

ie

#grep <ip> /usr/local/apache/logs/error_log
or
#grep <ip> /etc/csf/csf.deny

From here you will get the application ID

Once you have the rule’s id number, you will need to create the following file

vi /usr/local/apache/conf/userdata/std/2/USER/<domain.com>/<anything>.conf

For example
vi /usr/local/apache/conf/userdata/std/2/USER/example.com/modsec.conf

Now open the .conf file and add the below mentioned lines in it.


<IfModule mod_security2.c>
SecRuleRemoveById <NUMBER>
</IfModule>


Be sure to replace <NUMBER> with the Rule ID number of the mod_security rule you need to whitelist. Save the file, and then run the following commands, replacing <CPANEL USER> with the actual cpanel user name.

/scripts/ensure_vhost_includes --user=<CPANEL USER>
/usr/local/cpanel/bin/apache_conf_distiller --update
/usr/local/cpanel/bin/build_apache_conf

:)

cPanel Shell commands


Restart chkservd:
/etc/init.d/chkservd restart

Tail Apache log:
tail -f /usr/local/apache/logs/error_log

Updates the cpanel server software:
/scripts/upcp

Reinstalls exim:
/scripts/exim4

View traffic or if you think a site is being DDoS:
cd /usr/local/apache/domlogs
tail -f targetsite.com

Correct bandwidth issues
/scripts/cleanbw

Useful commands


Useful Commands for checking the domains

1:#traceroute domain.com
2:#whois domain.com
3:#dig domain.com
4:#ping domain.com

File permissions in cPanel accounts


Please use below mentioned files for your account

Permissions

/home/user               711
/home/user/public_html   750
public_html/directory    755
public_html/file         644

Command to find the hacked files



You can search the hacked files using the below mentioned command


#grep -ril <hack content> ./*

For example
#grep -ril 'Hacked By Sizzling Soul' ./*

Wordpress Blank page occuring when clicking on Permalinks


Officially, Permalinks are the permanent URLs to your individual weblog posts, as well as categories and other lists of weblog postings. A permalink is what another weblogger will use to link to your article (or section), or how you might send a link to your story in an e-mail message. The URL to each post should be permanent, and never change — hence permalink.

Permalinks would help us to retrieve an article from a huge collection and its the most important significance of it.

In this article, I'm going to describe how an issue with the Blank Permalinks page can be resolved


Issue

The Permalinks page in Wordpress Administration panel appears to be Blank

Whereas it should be show more options

Mysql Connection

The below mentioned command is used for the mysql connection test.

1. Touch a php file for example
    connection.php

2. Coppy paste below mentioned code in that file


Traceroute


You can use below steps to take the traceroute results from different operating systems.

In Windows,
Start > Programs > Accessories > Command Prompt.
c:\> tracert <domain.com>

Linux:
get into a terminal and execute the command as given below
$traceroute <domain.com>

MAC
These steps were created using Mac OS X. For earlier operating systems, you will need to download and use a third party program.
1. From your hard-drive, open the Applications folder, and click to open the Utilities folder.
2. Double-click Terminal.
3.Type traceroute followed by your domain name, and hit Enter.