Articles in the ‘cPanel’ Category

Errors in installing PECL extensions through cPanel WHM

Friday, October 22nd, 2010

If you get:

checking for C compiler default output file name... conftest.in
checking whether the C compiler works... configure: error: cannot run C compiled programs.

This happens when /tmp mounted with the ‘noexec’ option


mount -o,remount,rw,exec /var/tmp

And when you’re done, set it back:

mount -o,remount,rw,noexec /var/tmp

NGINX with Domain Access Drupal

Thursday, October 7th, 2010

If you have followed our previous tutorial on NGINX with Apache and cPanel you can use this setup also for Domain Access with Drupal.

To enable NGINX for *.domain.tld setup in Domain Access folow the next step:


nano /usr/local/nginx/conf/vhost.conf

and add after the rest of proxy_redirect.

proxy_redirect http://*.domain.tld:81 http://*.domain.tld;

NGINX with Apache and cPanel

Thursday, October 7th, 2010

In this setup, NGinx will be integrated with Apache (under cPanel) and used to server the static files.

Run SSH console

cd /root
wget http://nginx.org/download/nginx-0.8.52.tar.gz
wget http://stderr.net/apache/rpaf/download/mod_rpaf-0.6.tar.gz
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-7.9.tar.gz
tar xvzf mod_rpaf-0.6.tar.gz
cd mod_rpaf-0.6
/usr/local/apache/bin/apxs -i -c -n mod_rpaf-2.0.so mod_rpaf-2.0.c
cd /root
tar xvzf pcre-7.9.tar.gz
cd pcre-7.9
./configure
make
make install
cd /root
tar xvzf nginx-0.8.52.tar.gz
cd nginx-0.8.52
./configure --with-http_ssl_module --with-http_realip_module --with-http_dav_module --with-http_flv_module --with-http_gzip_static_module
make
make install

-Login to WHM and look for the following route:
Main >> Service Configuration >> Apache Setup > Include Editor > Pre Main Include

- Add the following configuration and save, LIST_OF_YOUR_IPS changing the IP you occupy in your site:

LoadModule rpaf_module modules/mod_rpaf-2.0.so
RPAFenable On
# Enable reverse proxy add forward
RPAFproxy_ips 127.0.0.1 LIST_OF_YOUR_IPS
# which ips are forwarding requests to us
RPAFsethostname On
# let rpaf update vhost settings
# allows to have the same hostnames as in the "real"
# configuration for the forwarding Apache
RPAFheader X-Real-IP
# Allows you to change which header mod_rpaf looks
# for when trying to find the ip the that is forwarding
# our requests

- Change the apache port to 81 (tweak settings)
Open whm – tweak settings and find 0.0.0.0:80 and change it to 0.0.0.0.:81

- Run SSH console

/usr/local/cpanel/whostmgr/bin/whostmgr2 --updatetweaksettings
/scripts/rebuildhttpdconf
httpd restart

create automated nginx virtual host creator

touch nginx.sh
chmod 755 nginx.sh
nano nginx.sh

and add the content from here.

then run it

./nginx.sh

-Check the configuration

/usr/local/nginx/sbin/nginx -t

Until now only the managing nginx connections, but is not serving static content. For the latter you must edit the following file:

nano /usr/local/nginx/conf/vhost.conf

-Remove the 3 # signs of the following lines:

#location ~* \.(gif|jpg|jpeg|png|wmv|avi|mpg|mpeg|mp4|js|css)$ {
# root /home/myweb/public_html;
#}

so the final configuration will looks like

location ~* \.(gif|jpg|jpeg|png|wmv|avi|mpg|mpeg|mp4|js|css)$ {
root /home/myweb/public_html;
}

Configure nginx startup scripts

touch /etc/init.d/nginx
chmod +x /etc/init.d/nginx
nano /etc/init.d/nginx

and add the following content from here.

Now, let’s test the scripts:

/etc/init.d/nginx restart
ps aux | grep nginx

and last, add nginx as autostart deamon

/sbin/chkconfig nginx on
/sbin/chkconfig --list | grep nginx

How to install Memcache in cPanel?

Tuesday, September 28th, 2010

Take a coffee, this is going to be a long process.

Step 1: Configure Apache
Login to cPanel and start EasyApache. At the Exhaustive Option List choose Memcache. Compile Apache & Restart it.

Step 2: Memcache requires LibEvent
LibEvent can be downloaded from Monkey.org. Download the last 1.4.x available version.

wget http://monkey.org/~provos/libevent-1.4.14b-stable.tar.gz
tar xvfz libevent-1.4.14b-stable.tar.gz
cd libevent-1.4.14b-stable
./configure; make; make install

Step 3: Register LibEvent

nano /etc/ld.so.conf.d/libevent-i386.conf

Add the following text inside:

/usr/local/lib/

and at last, run:

ldconfig

Step 4: Compile and install Memcache (deamon)
Now you can install Memcache with the last version from their site.

wget http://memcached.googlecode.com/files/memcached-1.4.5.tar.gz
tar xvfz memcached-1.4.5.tar.gz
cd memcached-1.4.5
./configure; make; make install

Step 5: Install PHP extension for Memcache
Normall, you should be able to do this from cPanel but i get a compiling error. So here is an alternative:

wget http://pecl.php.net/get/memcache-3.0.3.tgz
tar xvfz memcache-3.0.3.tgz
cd memcache-3.0.3
phpize
./configure
make
make install

Edit /usr/local/lib/php.ini

nano /usr/local/lib/php.ini

and copy paste at the end of the file:

extension=memcache.so

and at last, restart Apache:

service httpd restart

Step 6: Run Memcache as a deamon on the startup files

nano /etc/memcached.conf

and add inside:

#Memory a usar
-m 16
# default port
-p 11211
# user to run daemon nobody/apache/www-data
-u nobody
# only listen locally
-l 127.0.0.1

create the startup files

touch /etc/init.d/memcached
chmod +x /etc/init.d/memcached

and add inside it

nano /etc/init.d/memcached

the following text

then run:

touch /usr/local/bin/start-memcached
chmod +x /usr/local/bin/start-memcached

and add inside the following text

Now, let’s test the scripts:

/etc/init.d/memcached restart

and review if the conf file is parsed ok:

ps aux | grep memcached

and last, add memcached as autostart deamon

/sbin/chkconfig memcached on
/sbin/chkconfig --list | grep memcached

it should output:

memcached 0:off 1:off 2:on 3:on 4:on 5:on 6:off

Step 7: Test Memcache in PHP
Create the memcache.php file and add this text
You should have in the browser:

String to store in memcached.

Increase phpmyadmin upload size in cPanel

Thursday, September 23rd, 2010

Changing the settings in php.ini through cPanel will affect only the accounts on the site but not the tools used in cPanel such as PHPMyAdmin.

If you want to increase the upload size or change settings of php for PHPMyAdminyou need to follow the next steps in SSH:


nano /usr/local/cpanel/3rdparty/etc/php.ini

and change
upload_max_filesize = 150M
post_max_size = 150M

then run in SSH

/usr/local/cpanel/bin/install_php_inis
service cpanel restart

cPanel – Munin Graph blank for MySQL

Monday, June 7th, 2010

The error is due to a bug in a Perl library Munin uses which causes the plugin cannot find the mysqladmin.

1. Find where is mysqladmin program located with the the following command:
locate mysqladmin

2. Edit the /etc/munin/plugin-conf.d/cpanel.conf Munin configuration file:

[mysql*]
user root
group wheel
env.mysqladmin /usr/bin/mysqladmin
env.mysqlopts --defaults-extra-file=/root/.my.cnf

Where the env.mysqladmin value is path returned by step above. Also ensure that /root/.my.cnf contains correct root password to the MySQL databases.
4. The format of /root/.my.cnf is:

[client]
user="root"
pass="******************"

5. Restart Munin service:

killall munin-node
su - munin --shell=/bin/bash
/usr/share/munin/munin-update
exit
service munin-node restart

Problem using PEAR ping command

Tuesday, July 7th, 2009

If you use cPanel and you get the following error when calling PING from PEAR:


Warning: popen() has been disabled for security reasons in /usr/lib/php/OS/Guess.php on line 242


Warning: fgets(): supplied argument is not a valid stream resource in /usr/lib/php/OS/Guess.php on line 243


Warning: pclose(): supplied argument is not a valid stream resource in /usr/lib/php/OS/Guess.php on line 252


Warning: exec() has been disabled for security reasons in /home/dev7sof/php/Net/Ping.php on line 243 unable to locate the ping binary

then in WHM -> PHP Configuration -> Switch to Advanced Mode -> remove from disable_functions the functions exec and popen

and save the new configuration.

Ping not working in cPanel

Tuesday, July 7th, 2009

If you try to run ‘ping’ as unprivileged user and you get the following message:

#ping www.google.com
ping: icmp open socket: Operation not permitted

then as root, run the following command:

#chmod +s ping

PEAR in cPanel

Monday, July 6th, 2009

In order to configure PEAR with cPanel you need to follow these steps:

1. In the WHM you need to be sure that you have configured Apache with PEAR.
2. If PEAR is not active in Apache go to easyApache and in Exhaustive List of Modules, check “PEAR” and compile Apache again.
3. Now, every normal user in cPanel will have the option to select the packages they want from their cPanel -> Software/Services -> PHP PEAR Packages.
4. (Additional) If an user doesn’t have the option at Step 3, be sure that in WHM -> Software -> Module Installers -> you have installed PEAR.
5. (Additional) If you get the following error:

PEAR configuration files "/.pearrc", "/usr/etc/pear.conf" does not exist

copy pear.conf from /etc/pear.conf -> /usr/etc/pear.conf

How to test a SVN commit?

Thursday, June 18th, 2009

Do a dry-run with:


svn merge --dry-run -r BASE:HEAD .