Linux

FAQs/HOW-TO's related to Linux and/or BSD server administration.

Drupal .htaccess rewrite with 'www' but not for sub-domains

Say you have your Drupal's .htaccess set "To redirect all users to access the site WITH the 'www.' prefix", and you added a sub-domain, and it came out looking something like http://www.sub.domain.com. So, most people will NOT want the "www" added to the url in this case. So what do you do? Easy.

Use this instead:


# To redirect all users to access the site WITH the 'www.' prefix,
# (http://example.com/... will be redirected to http://www.example.com/...)
# uncomment the following:
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} !^(subdomain1|subdomain2|subdomain3)\. [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

So what changed? We simply added this line:

Tags: Drupal Linux admin

Add memcached Support to Magento

After you successfully install memcached and pecl/memcached (memcached PHP support), you will next want take full advantage of it by enabling native support for memcached in magento.

NOTE: you must have memcached and pecl/memcached already installed. Otherwise your Magento installation will break if you try following this guide.

Ok... now that the warning is out the way. Here's how we do it...

Edit your local.xml


vi ./app/etc/local.xml

Add the following between

Tags: magento memcached Linux

How to set a custom sub-domain path in DirectAdmin

UPDATE: See below, there's an easier way to do this. Plus DirectAdmin's way doesn't seem to be working through the 'Custom HTTPD Configurations' way.... So, just use the way listed below. It's much easier.

*** OLD WAY / start ***
I work with Drupal's Domain Access module a lot. However, if you're using DirectAdmin as your hosting control panel, then making sub-domains will not work with the default setup. DirectAdmin puts the sub-domain into a separate directory, and in order for Domain Access to work with sub-domains on DirectAdmin, this needs to be set as the same directory/path as the top domain.

A simple work around is to login to DirectAdmin as administrator, and go into "Custom HTTPD Configurations".

Here you will paste the following code:

Tags: DirectAdmin Linux Drupal Domain Access

Cannot find autoconf. Please check your autoconf installation and the $PHP_AUTOCONF environment variable.

if you try running the following:

phpize

and get this error

$PHP_PREFIX/bin/phpize
Configuring for:
PHP Api Version: 20041225
Zend Module Api No: 20060613
Zend Extension Api No: 220060519
Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.

Then it's because you don't have autoconf installed.

To fix this error, do the following:

yum install autoconf

or you can install from source (if you want to use the latest version)


cd /usr/local/src/

/* find latest version of m4 here: http://ftp.gnu.org/gnu/m4/ */

Tags: Server Linux

phpMyAdmin database export "Save as file" template

Whenever you do a database backup using phpMyAdmin, you are presented with a default file name structure for saves, usually like so:

__DB__

which basically gives you the name of the database you just backed up. Which is ok, however, most people would also like the date and time stamp included as well...

So...

This is how it's done... replace the above with :

__DB__-%F-%T

or for newer version of phpMyAdmin

@DATABASE@-%F-%T

__DB__ = name of database Example: my_database
%F = Same as "%Y-%m-%d" (year-month-day) Example: 2009-11-25
%T = time stamp . (24 hour format, hour_minute_second) Example: 11_07_31

which will save a file with the naming structure similar to:

my_database-2009-11-25-11_07_31.sql

You can easily use other date/time structure, to suit your personal preference.

Tags: Linux admin mysql