how to create a blog website to support multiple installations

Jul 19, 05:02 AM

==wordpress update====
mu.wordpress.org
===============

it appears that both serendipity and wordPress will support multiple installations:

serendipity:
http://www.s9y.org/41.html

wordpress:
http://www.optiniche.com/blog/392/multiple-installs-single-database/

the advantage is that the database and the install can be in one and only one place, and have multiple websites sharing the same code and database.

======== d a t a b a s e c r e a t i o n =============

CREATE USER ‘testDatabase’@‘localhost’ IDENTIFIED BY ‘***’;

GRANT USAGE ON * . * TO ‘testDatabase’@‘localhost’ IDENTIFIED BY ‘***’ WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ;

CREATE DATABASE IF NOT EXISTS `testDatabase` ;

GRANT ALL PRIVILEGES ON `testDatabase` . * TO ‘testDatabase’@‘localhost’;

======= w o r d P r e s s ========================

this installation assumes installation in /usr/lib/wordpress directory!

1) create /usr/lib/.htaccess file:

php_flag log_errors on
php_value error_log /var/lib/wordpress/error.log
php_flag display_errors off
php_value error_reporting 6143

RewriteEngine On
RewriteRule ^$ /lib/index.php [L] ## default for index

RewriteCond %{REQUEST_URI} !=^/lib/ ## IF the uri does NOT contain “/lib/”
RewriteCond /%{REQUEST_FILENAME} !-f ## AND IF the requested filename is not a local file
RewriteCond /%{REQUEST_FILENAME} !-d ## AND IF the requested filename is not a local directory
RewriteCond /%{REQUEST_FILENAME} !-l ## AND FINALLY IF the requested filename is not a local symbolic link
RewriteRule ^(.+)$ /lib/$1 [L] ## THEN append ‘lib’ at the beginning of the request

2) in wp-config.php, add the following code:

$table_prefix = str_replace(‘www.’, ‘’, $_SERVER[‘HTTP_HOST’] ) ; // 2009-07-26 get rid of the www-dot prefix if there
$table_prefix = preg_replace(’/\W/’, ‘‘, $table_prefix) . ‘‘ ; // 2009-07-26 change any table_prefix special characters to // 2009-07-26 underscores; do periods only i suppose
error_log( ‘$table_prefix = ‘ . $table_prefix ); // 2009-07-26

// set two env variables, WP_CONTENT_DIR and WP_CONTENT_URL
$search_pattern = ‘?/(lib|wp-.)/.$?’; // define a pattern with any /lib/ or /wp-*/
error_log( ‘$search_pattern = ‘ . $search_pattern );

/*
replace the “script_filename” suffix with /wp-content/. remember, this is
the LONG filename, relative to the top of the directory tree */
$wp_content_dir = preg_replace ( $search_pattern , ‘/wp-content/’ , $_SERVER[‘SCRIPT_FILENAME’] ) ;
error_log( ‘$wp_content_dir = ‘ . $wp_content_dir );
define( ‘WP_CONTENT_DIR’, $wp_content_dir ) ;

/*
replace the script_name suffix with /wp-content/. this is the SHORT name relative to the top of the apache tree */
$wp_content_url = preg_replace ( $search_pattern , ‘/wp-content/’ , $_SERVER[‘SCRIPT_NAME’] ) ;
error_log( ‘$wp_content_url = ‘ . $wp_content_url );
define( ‘WP_CONTENT_URL’, $wp_content_url ) ;
//define( ‘WP_CONTENT_URL’, ‘’ );

3) in the users wordpress directory, add the following: ln -s /usr/lib/wordpress ./lib ## create symbolic links ln -s ./lib/.htaccess .htaccess cp -r /usr/lib/wordpress/wp-content ./wp-content

4) [OPTIONAL] in wordpress settings:
go into SETTINGS—>WORDPRESS-ADDRESS and take out the “lib”

========== s e r e n d i p i t y ====================

0) cd /usr/lib

1) wget
http://prdownloads.sourceforge.net/php-blog/serendipity-1.4.1.tar.gz?download

2) gzip -d seren*.gz ; tar -xvf seren*.tar ;

3) mv ./serendipity ./s9y

4) chmod 744 ./s9y

5) in /usr/lib/.htaccess file

cat <>/usr/lib/.htaccess;

RewriteEngine On

RewriteRule ^$ /lib/index.php [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*) ./lib/$1
ENDOFFILE

6) in user area:

ln -s ./lib/.htaccess .htaccess ;
ln -s /usr/lib/s9y ./lib ;
cp -r /usr/lib/s9y/deployment . ;
cp -r /usr/lib/s9y/htmlarea . ;
cp -r /usr/lib/s9y/template . ;

7) in install step:

a – mv /usr/lib/s9y/serendipity_config_local.inc.php /usr/lib/s9y/serendipity_config_local.inc.phpSAVE

b – in install screen:
change database user
change database password
change database prefix to domain (example user1_edwardsmark_com_)
change FULL PATH to: /usr/lib/s9y/
change RELATIVE PATH to: /
leave templates and uploads as templates/ uploads/
change BLOG TO URL and remove the “lib/”
change username to admin
change password to admin
change magick to yes

7) THIS NEEDS TO BE DONE AFTER EVERY NEW-USER INSTALL……..
in /usr/lib/s9y/serendipity_config_local.inc.php
$serendipity[‘dbPrefix’] = preg_replace(’?\.?’,’‘, $_SERVER[‘HTTP_HOST’] ) . ‘‘ ;

or use this command:

sed -iSAVE
“s?\(\$serendipity\[‘dbPrefix’\].\).?\1 preg_replace(’|\\\.|’, ‘‘, \$_SERVER\[‘HTTP_HOST’\] ) . ‘‘ ; ?”
serendipity_config_local.inc.php

DONT FORGET to include a wp_head()
function right before the closing < / head > tag. otherwise the theme will not let you log in to multi-user wordpress with domain mapping! 2010-03-16

Mark Edwards

,

---

Commenting is closed for this article.

---