Last active
August 29, 2015 13:57
-
-
Save lluis/9528453 to your computer and use it in GitHub Desktop.
make owncloud multi-virtualhost
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DocumentRoot /var/www/owncloud | |
<Directory /var/www/owncloud/> | |
AllowOverride All | |
<FilesMatch ".+\.ph(p[345]?|t|tml)$"> | |
SetHandler application/x-httpd-php | |
</FilesMatch> | |
</Directory> | |
<Directory /var/www/owncloud.domain.net/htdocs/owncloud> | |
Order allow,deny | |
Deny from all | |
</Directory> | |
SetEnv OC_DOMAIN owncloud.domain.net | |
SetEnv OC_DBNAME dbname | |
SetEnv OC_DBUSER dbuser | |
SetEnv OC_DBPASS dbpass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// /var/www/owncloud/lib/private/config.php | |
private function writeData() { | |
// (coment all function | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// /var/www/owncloud/config/config.php | |
// original idea from http://owncloud.10557.n7.nabble.com/Multiple-Instances-on-one-server-td7644.html | |
$DOMAIN = getenv('OC_DOMAIN'); | |
$DBNAME = getenv('OC_DBNAME'); | |
$DBUSER = getenv('OC_DBUSER'); | |
$DBPASS = getenv('OC_DBPASS'); | |
$DBHOST = 'localhost'; | |
$INSTANCE = substr(md5($DOMAIN),0,13); //Generate instance id for every domain | |
$CONFIGURED = strlen($DOMAIN) > 0 && | |
strlen($DBNAME) > 0 && | |
strlen($DBUSER) > 0 && | |
strlen($DBPASS) > 0; | |
if ( ! $CONFIGURED ) { | |
echo 'Server not configured for '.$_SERVER['HTTP_HOST']; | |
throw new Exception('Not configured for '.$_SERVER['HTTP_HOST']); | |
} | |
//Check if already exists the instance or not | |
$INSTALLED = false; | |
$con = mysqli_connect($DBHOST, $DBUSER, $DBPASS, $DBNAME); | |
if ( !mysqli_connect_errno() ) { // Check connection | |
$result = mysqli_query($con,"SELECT * FROM oc_users"); | |
$INSTALLED = mysqli_num_rows($result) > 0; | |
} | |
mysqli_close($con); | |
$CONFIG = array ( | |
'instanceid' => $INSTANCE, | |
'passwordsalt' => 'your_salt_here', | |
'datadirectory' => '/var/www/'.$DOMAIN.'/htdocs/owncloud', | |
'dbtype' => 'mysql', | |
'dbtableprefix' => 'oc_', | |
'dbhost' => $DBHOST, | |
'dbname' => $DBNAME, | |
'dbuser' => $DBUSER, | |
'dbpassword' => $DBPASS, | |
'version' => '6.0.0.14', | |
'installed' => $INSTALLED, | |
'maintenance' => false, | |
'theme' => '', | |
'loglevel' => '2', | |
'trashbin_retention_obligation' => 10, | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// /var/www/owncloud/lib/private/setup.php | |
//generate a random salt that is used to salt the local user passwords | |
//$salt = OC_Util::generateRandomBytes(30); | |
//OC_Config::setValue('passwordsalt', $salt); | |
// read salt from config file | |
$salt = OC_Config::getValue('passwordsalt'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment