How to enable allow_url_fopen for a single domain on a cPanel server?

March 26, 2011    |   Posted by admin   |    Category: cPanel Management

The way to enable allow_url_fopen on a phpsuexec and a non-phpsuexec server is different. To enable allow_url_fopen server wide is a security risk, however, you can turn it ON for a single domain incase it is required.

Here how it needs to be done.

  • On a non phpsuexec server:

Goto the /usr/local/apache/conf/ directory,

# cd /usr/local/apache/conf/userdata

create a ‘userdata’ directory if not there and then create a directory with the accounts username inside it. Finally, you have to create a file allowurl.conf in the newly created directory.

The complete path should look like:

# pico /usr/local/apache/conf/userdata/<username>/allowurl.conf

and add the following to the file

<IfModule mod_php5.c>  
php_admin_value allow_url_fopen On 
php_admin_value allow_url_include On 
</IfModule> 

Now, edit the Apache configuration file and scroll down to the VirtualHost entry of the domain. Include the path of the above created file in it, as shown below:

Include "/usr/local/apache/conf/userdata/<username>/allowurl.conf"

Save the file and rebuild the apache configuration

# /usr/local/cpanel/bin/apache_conf_distiller --update 
# /usr/local/cpanel/bin/build_apache_conf 
# /scripts/restartsrv httpd

This will enable allow_url_fopen for that domain.

  • On a PhpSuExec Or SuPHP server:

To enable allow_url_fopen on a SuPHP/PHPSuExec enabled server, copy the server side php.ini OR create a new one under the public_html directory of the domain (OR in the directory where you want to enable allow_url_fopen) i.e.

# cp /usr/local/lib/php.ini /home/<username>/public_html/

and edit the new php.ini to enable allow_url_fopen directive:

allow_url_fopen = On

Save the file and this is it.

BTW, replace “<username>” with the actual username of the domain wherever stated above.

Comments Off on How to enable allow_url_fopen for a single domain on a cPanel server?

How to assign a dedicated IP to a Sub-domain OR Add-on/Park domain?

March 8, 2011    |   Posted by admin   |    Category: cPanel Management

By default, cPanel allows one IP per account, however, in case you wish to assign multiple IPs to an account, say for a sub-domain, you can do so by editing a few files. Follow the below steps:

1) The main configuration file of a domain is stored under the /var/cpanel/userdata/<username>/ directory, so edit the subdomain related file under it

# vi /var/cpanel/userdata/<username>/subdomain.domain.tld

Change the value of “IP” to a dedicated IP and save the file. The add-on and Park domains have their related subdomain files in the same directory.

2) Now, rebuild the Apache configuration for the changes to take affect in the respective VirtualHost entry

# /scripts/rebuildhttpdconf 

3) Restart the Apache webserver

# service httpd restart

4) Add the dedicated IP and sub-domain in the /etc/domainips file to mark the dedicated IP as assigned so WHM won’t be able to assign it to other domains.

dedicatedIP: subdomain.domain.tld

Save the file and rebuild the IP pool

# /scripts/rebuildippool

5) Now, edit the DNS zone file of the main domain (i.e. the domain under which the sub-domain is created) and add an ‘A’ record for the sub-domain to point to the new IP.

# vi /var/named/domain.tld.db

Save the file and restart the ‘named’ service

# service named restart

Allow sometime for the new IP to propagate.

Note: Rebuilding the IP pool will still list the IP as free under the WHM -> IP Function -> ‘Show IP Address Usage’, however WHM wont allow you to assign that IP to another domain.

Comments Off on How to assign a dedicated IP to a Sub-domain OR Add-on/Park domain?

How to add Domainkeys for a domain on a cPanel server?

November 29, 2010    |   Posted by admin   |    Category: cPanel Management

“DomainKeys” is an anti-spam software application that uses a public key, cryptography to authenticate the sender’s domain. cPanel offers a installer script “domain_keys_installer” using which the DomainKeys can be created and added automatically for a domain.

By default the DomainKeys is not added when the account is created on the server, it has to be added manually. SSH to your server and execute:

/usr/local/cpanel/bin/domain_keys_installer <username>

where, <username> is the username of the domain.

The DomainKey is automatically added in the DNS zone file of the domain located at /var/named/domainname.db file. To add DomainKeys for the existing domains, execute the following command as it is:

for i in `cat /etc/trueuserdomains | awk '{print $2}'`
do
/usr/local/cpanel/bin/domain_keys_installer $i;
done;

NOTE: If you are using a 3rd party name servers for your domain, you will have to add the DomainKeys in the DNS zone of your domain created on their servers.

Comments Off on How to add Domainkeys for a domain on a cPanel server?

tailwatchd failed: A restart was attempted automagically

September 24, 2010    |   Posted by admin   |    Category: cPanel Management

An email from a cPanel server with the “tailwatchd failed” warning message indicates that either the cpanel service is offline/down OR the cpanel service was restarted. The complete message looks like the following:

tailwatchd failed @ Tue Jan 1 00:00:00 2010. 
A restart was attempted automagically 
Service Check Method: [check command] tailwatchd is not running

There isn’t anything to worry, however, you can check the tailwatchd logs for the failure reasons:

# tail -f /usr/local/cpanel/logs/tailwatchd_log

To check the status of the ‘tailwatchd’ service and it’s output, execute

# /usr/local/cpanel/libexec/tailwatchd --status 
 Driver (Active: 1) Cpanel::TailWatch::ChkServd
 tailwatchd is enabled
 Running, PID 24463
 Driver (Active: 1) Cpanel::TailWatch::cPBandwd
 Driver (Active: 1) Cpanel::TailWatch::Antirelayd
 Driver (Active: 1) Cpanel::TailWatch::Eximstats

Restart the ‘cpanel’ service once, just to make sure it’s online

# service cpanel restart

and if you still continue to receive the ‘tailwatchd failed’ emails, update “cPanel” on the server

# /scripts/upcp --force

How to monitor and auto restart cron service using cPanel chkservd?

June 29, 2010    |   Posted by admin   |    Category: cPanel Management

Sometimes it is necessary to monitor a crond service itself on a cPanel server. cPanel offers ‘chkservd’ (a monitoring daemon) that monitors the services that are included in it and restarts them if they are found offline.

However, cPanel do not provide an option to include the ‘crond’ service under chkservd. The following method can be used to add crond service under chkservd.

Create a crond file under the chkservd.d directory where the files of all the services are placed:

# pico /etc/chkserv.d/crond

Add the following and save the file:

service[crond]=x,x,x,/etc/init.d/crond restart,crond,root

Now you need to edit the chkservd configuration file and enable the crond service for monitoring

# pico /etc/chkserv.d/chkservd.conf

add the following line at the end of the file

crond:1

Now, save the file and restart the chkservd service for the new changes to take affect:

# /scripts/restartsrv chkservd

In order to verify if chkservd auto-restarts the crond service if it is offline, stop the service manually

# service crond stop

and watch the chkservd logs

# tail -f /var/log/chkservd.log

You will notice that the crond service is restarted automatically within 5 minutes.

Comments Off on How to monitor and auto restart cron service using cPanel chkservd?