How to use PECL with /tmp mounted with “noexec”

The situation here is that you run a server and when trying to install a PHP module via PECL you receive the “checking whether the C compiler works… configure: error: cannot run C compiled programs.” error followed by the build failing.

The problem is that PECL is trying to write and run the files its trying to build in your /tmp directory, but your /tmp directory is mounted with “noexec” so the files can not be executed. What you will see will look something like this:

Note: I’m building APC on a cPanel CentOS server.

$ pecl install apc
downloading APC-3.0.19.tgz ...
Starting to download APC-3.0.19.tgz (115,735 bytes)
.........done: 115,735 bytes
47 source files, building
running: phpize
Configuring for:
PHP Api Version:         20090626
Zend Module Api No:      20090626
Zend Extension Api No:   220090626
Use apxs to set compile flags (if using APC with Apache)? [yes] : yes
building in /var/tmp/pear-build-root/APC-3.0.19
running: /root/tmp/pear/APC/configure --with-apxs
checking for egrep... grep -E
checking for a sed that does not truncate output... /bin/sed
checking for cc... cc
checking for C compiler default output file name... a.out
checking whether the C compiler works... configure: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details.
ERROR: `/root/tmp/pear/APC/configure --with-apxs' failed

One solution out there is to unmount then remount /tmp without ‘noexec’ when trying to build via pecl, but this method opens up a security hole in the server for the time you have it mounted without ‘noexec’. The next method is to build the module yourself using the typical “phpize”, “./configure” then “make install”. This method is better then the first but this one is just a workaround for the problem making you unable to use PECL and still makes you od much more work then you have to with PECL.

My solution to this seems to be the most simple, and easiest one of the bunch. All you have to do is create a symlink from where PECL wants to save and run the files to somewhere where it can run them, in this case /root/tmp, with the following command:

$ mkdir /root/tmp/pear-build-root && ln -s /root/tmp/pear-build-root /tmp/

After running that command (as root or other super user) retry installing your module via PECL and it should now work without issue.

“New” website and Blog

Gears

Moving and moving.

In my ongoing effort to improve VlexoFree we now have a “new” website and a new blog!

The reason I’m saying new with quotes is that all the content and the basic look of the site is basically the same. The sidebar styles on the pages are now changed to match the blog and I’ve moved all pages over to be managed by WordPress (except for iPanel and Blesta).

Some pages have been removed from the menu (but can still be accessed if you try hard enough) as they really had no usable content that you cant get from the wiki..

Also, in a addition to VlexoFree related content in this new blog, there will (and already is) other content related to programming, server maintenance and other things that people might find helpful.

I guess if anyone else thinks they could post some useful content on this blog contact me and show me what you got.

Automatically install DomainKeys on new accounts in cPanel

DomainKeys is an e-mail authentication system designed to verify the DNS domain of an e-mail sender and the message integrity. cPanel supports this but the feature is disabled by default on new accounts. If you want to make it easy on your users and enable this automatically you just need to add a few lines to your postwwwacct file.

The following code runs the domain_keys_installer script at then end of a new account creation, thus enabling DomainsKeys for all new accounts.

Create (if not already there) /scripts/postwwwacct then copy and past the following code into the file:

#!/usr/bin/php
<?php
$opts = array();
$argv0 = array_shift($argv);

while(count($argv)) {
 $key = array_shift($argv);
 $value = array_shift($argv);
 $opts[$key] = $value;
}
shell_exec("/usr/local/cpanel/bin/domain_keys_installer " . $opts['user']);
?>

DomainsKeys will now be installed on all new accounts you create.

Automatically exclude backing up new accounts in cPanel

cPanel is setup so is that if automatic backups are enabled in WHM then every new account will be added to the backup list. If you’re picky about which accounts you want the be backed up and don’t want to manually exclude the accounts upon creation, you can use this method.

What the following code does is writes the username of the account currently being created to the system’s /etc/cpbackup-userskip.conf file to be excluded from backups.

Create (if not already there) /scripts/postwwwacct then copy and past the following code into the file:

#!/usr/bin/php
<?php
$opts = array();
$argv0 = array_shift($argv);

while(count($argv)) {
 $key = array_shift($argv);
 $value = array_shift($argv);
 $opts[$key] = $value;
}

$fp = fopen('/etc/cpbackup-userskip.conf','a');
fwrite($fp,$opts['user'].chr(10));
fclose($fp);
?>

All new accounts will now be excluded from the backup list!