CopyrightIBMCorporation2013TrademarksCreatingaDrupalmultisiteinstallationPage1of10CreatingaDrupalmultisiteinstallationCreatemultipleDrupalsitesfromasinglecodebaseandmultipledatabasesTimiOgunjobiApril30,2013OneimportantfeatureoftheDrupalcontentmanagementsystemisthatitenablesyoutorunmultiplewebsitesfromasinglebaseinstallationoftheframework—afeaturecalledmultisiteinstallations.
Suchinstallationsareparticularlyusefultowebadministratorswhohavetomanageandmaintainseveralsitesonalong-termbasis,andthefunctionalitysimplifiestheadministrationofmultipleDrupalinstallationslocatedonthesameserverbymakingallofthemrunfromasinglescript.
Inthisarticle,seehowtoinstall,configure,run,andadministermultisiteDrupal.
Therearemanyreasonswhyasystemsadministratorordevelopermaychoosetohostmultiplesitesonthesameserverinamultisiteconfiguration.
Forexample,suchaconfigurationcould:EnableyoutobuildanefficientdevelopmentenvironmentAllowyoutostageandtestasitebeforeitgoespublicLetyourundifferentsoftwareonthesamesiteEnablesharingofasinglecodebaseacrossseveralsitesLeveragesharedhostingAllowyoutorunsimilarsecure(HTTPoverSecureSocketsLayer[HTTPS])andstandard(HTTP)sitesonthesameserverEaseserveradministrationNotallofthesereasons,however,arebestaddressedwithDrupal'smultisitefeature.
Thisarticlesfocusesonjustonestrategy:howtouseDrupal'sbuilt-inmultisitesupporttocreateandserveseveralsitesfromoneinstanceofDrupal.
BasicconsiderationsUsingtheDrupalcontentmanagementsystem(CMS)tocreateamultisiteconfigurationhasseveraldistinctadvantages,oneofwhichisthatitisprobablytheeasiestconfigurationtosetupandmaintain.
AnotheristhatdataduplicationisminimizedbecauseDrupalisinstalledinonlyoneplaceonyourserver.
Finally,DrupalhasawealthofcontributedmodulesthatcanbeusedtodeveloperWorksibm.
com/developerWorks/CreatingaDrupalmultisiteinstallationPage2of10augmentmultisitehandling,offeringadvancedcapabilitiestoallthesitesinthearrangement.
Thecombinationofaddedfeaturesandsimplifiedadministrationwouldbeaboonforanyonewantingtosetupandadministeramultisitearrangement.
Nevertheless,thereareafewdrawbackstousingsuchaconfiguration,andtwoinparticulardeserveclearmention:securityandsharing.
Thesitesinamultisiteinstallationsharethesamecodeandthusthesamefiles.
Asaresult,anyonewhogainsaccesstotheserver'sfilesystemforonesitealsohasaccesstoallthefilesusedforallofthesitesonthatmultisiteinstallation.
Therefore,incaseswheredifferentpeoplearemanagingdifferentsiteswithinthearrangement,itmaynotbequitesecure.
Ifsecurityamongsitesisaprimaryissue,orifdifferentpeoplemanagethevarioussites,Drupal'sbuilt-inmultisitefunctionalitymaynotbethebestsolution.
Instead,considergivingeachsiteitsowndistinctDrupalinstance.
Althoughtheadvantagesofeasieradministrationthatthemultisitearrangementaffordswillbelost,yoursiteswillbebetterprotectedfrommishaps.
Thesecondconcern—sharing—centersarounddatabaseaccess.
EventhoughDrupal'smultisitessharethesamesourcecode,theydonotsharethesamedatabasedata.
Thus,nodes,users,andcommentsinonesitearenotaccessiblebydefaultfromothersites.
Thisbehaviorcanactuallyberegardedasagoodthing,butinsituationswheretheadministratormayrequirethatallthesitesshareinformation,itmaybealimitationforthedesignofDrupal'smultisitefeature.
Nevertheless,thesweetspotforDrupal'sbuilt-inmultisitesupportisthatmodules,themes,and,eventosomeextent,uploadedfiles,canbesharedacrossallthesites.
Inaddition,thesameorcustomfilescanberetainedindifferentfolderscorrespondingtothedifferentsitesintheconfiguration.
Ifit'simportantthatallcontentbeshared,considerusingamultidomainfeature,whichiseasilyprovidedbyamoduleofthesamename.
InstallingDrupalformultisiteuseAfterdownloadingtheDrupalarchive(seeRelatedtopicsforalink),extractthefileandcopytheresultingfoldertothedocumentrootofyourwebserver.
Thistaskisn'tdifficultwithasuitableFTPclient;withSecureShell(SSH)accesstoyourserver,thetaskiseveneasier.
Simplyrunawgetcommandtodownloadthearchivefilefromtherepository,andextractittoproducetheDrupalinstallationfolder.
(Ifyourdevelopmentenvironmentislocal,standbyformoreoptions.
)Nametheinstallationfolder/goodsite.
Threedifferentsiteswillbecreatedforthisexercise;therefore,threedifferentdatabasesareneeded—oneforeachsite.
UsingphpMyadminfromtheCpanelofyourserver,thistaskiseasilyaccomplished.
Next,installtheframework.
Twotasksmustbeperformed,however,beforeusingyourwebbrowsertoruntheinstaller:ProvideDrupalwiththeinformationitneedsaboutthesitesyouintendtorun.
Passthesite-specificconfigurationdatafromDrupaltoallofthesites.
Toachievethefirsttask,createaspecialdirectoryforeachsite.
Forthesecond,locateasettingsfileineachdirectory.
Theobjectiveistosetuponemasterinstallationwithtwosub-sites.
Eachsub-sitesharesthesamefilesasthecore,buteachwillhaveitsownseparateURLanddatabase.
TheURLsofthesitestobecreatedare:ibm.
com/developerWorks/developerWorksCreatingaDrupalmultisiteinstallationPage3of10Mastersite:http://goodsite.
comSub-site1:http://bettersite.
comSub-site2:http://bestsite.
comInstallingthefirsthostAfterplacingtheDrupalsourcecodeinthedocumentrootandhavingcreatedtheMySQLdatabases,begininstallingthefirstsiteandthemasterdomain.
ThemasterdomainThemasterdomainnameistheURLfromwhichthemainsitewillbeaccessed(inthisarticle,http://goodsite.
com).
TheprimarypurposeofthemasterdomainistohostthebaseDrupalinstallation.
Regardlessofwhetherthisdomainisusedasoneofyoursites,ifanysub-sitesfails,theirURLswilldefaulttothemasterdomain;therefore,itisagoodideathatthissitecontaininformationrelevanttothesub-sites,suchascontactinformation.
Asmentioned,asubfoldermustbecreatedwithinthemainDrupalfolderforeachsub-site.
WhatmanywouldimaginethemostdifficulttaskinDrupal'smultisiteinstallationissimplyroutine:LetDrupalknowwhatsitesyouwanttohost,andsimplycreatesubfoldersforthosesitesinthe/sitesfolder.
IntheDrupalmainrootfolderisadirectorycalled/sites.
Ifyou'veadministeredDrupalbefore,youknowallnon-corecodeoughttoresidewithinthisfolder.
InthedefaultDrupalinstallation,the/sitesfoldercontainstwodirectories.
Thefirst,calledall/,iswhereyoushouldputdownloadedthemesandmodules.
Theall/directoryisthelocationforinformationsharedacrossallsites.
Thesecondfolder,nameddefault/,iswhereconfigurationfilesshouldbekept,aswellasnon-coreandcustomthemesandmodules.
Drupaltypicallysearchesthedefault/directoryforsiteconfigurationinformationunlessitisinstructedotherwise.
Note,however,thattheseareassumptionsforageneric,single-hostsite—notnecessarilyforamultisiteinstallation.
CreatingthesubfoldersandfilesAbigtipforbuildingmultisiteDrupalisthatapartfromtheall/anddefault/folders,otherfolderscanbecreatedin/sites,andDrupalwillassignthemspecialmeaning.
Morespecifically,Drupalassumesthatallotherdirectoriesfoundinthe/sitesfolderrepresentahostnameorahostnamepattern.
Youcreateasubfolderinthepattern/goodsite/sites/underthe/sitesfolderforallsub-sites,substitutingyourintendedURLforthenameofeachsub-sitefolder.
Inthisexample,youhavethefollowingsub-sites,asshowninFigure1.
Sub-site1:/goodsite/sites/bettersiteSub-site2:/goodsite/sites/bestsitedeveloperWorksibm.
com/developerWorks/CreatingaDrupalmultisiteinstallationPage4of10Figure1.
The/sitesfolderhierarchyForeachsub-site,completethefollowingsteps:1.
Copythefiledefault.
settings.
phpfromsites/defaulttoeachsub-sitefolder,andrenameitsettings.
php.
2.
UseCHMODtosetthepermissiononsettings.
phpto644,ifitisnotthecurrentpermission.
3.
ForaDrupal,Version6installation,createafoldernamedfilesundereachsub-site,anduseCHMODtochangethepermissionto755.
ThisisafolderinsidewhichDrupalisabletowritecontent—typically,uploadedfiles,imagethumbnails,aggregatedCascadingStyleSheet(CSS),andJavaScriptfiles.
Thesefilesarenotstoredinthedatabase,butratherinthefilesystem,soyoumusthaveadirectoryinwhichthesefilescanreside.
Bydefault,Drupallooksforasubdirectorynamedfiles/withinthedirectoryofeverysite.
InadefaultDrupalinstallation,thisfolderwouldbeinsites/default/files/.
4.
Createafoldercalledmodulesforeachsub-site.
Thisisthefolderinwhichanymodulesspecifictothatsub-sitereside.
Anymodulesthatallsiteswilluseshouldresideinthesites/all/modulesfolder.
5.
Createafoldercalledthemesforeachsub-site.
Thisiswhereanythemesuniquetothatsub-siteareplaced.
Anythemethatallsiteswilluseshouldresideinsites/all/themes.
Now,pointthesub-siteURLstoyourwebserver,iftheyarenotadministeredbythesamehostingcompany.
Ifyouusedifferenthostsforthevarioussites,youwillneedtochangetheDomainNameSystem(DNS)information(boththeregistrarsandthehostingcompaniesshouldbeabletotellyouhowtodoso).
Thereafter,youwillhaveto"park"thatdomainontopofyourprimarydomain—inthiscase,goodsite.
com.
Fromthispoint,youhaveafewalternatives,themoredifficultofwhichinvolvesusingwhat'scalledasymlink.
Parkingismuchsimpler,however;soinyourCpanel,clickonParkedDomains.
Addbettersite.
comandbestsite.
cominNewDomainName,andthenclickonAddDomain.
CreatingthemultisitesThereareseveralwaystogofromhere,butagain,let'staketheeasiestroute:directlyloadingthedatabaseforeachsub-sitewiththetablescreatedinthemastersiteinstallation.
Todoso,youibm.
com/developerWorks/developerWorksCreatingaDrupalmultisiteinstallationPage5of10mustcreateadumpofthedatabasetablesfromthemastersiteinstallationandsaveitlocally.
Then,eitheruploadthisfilewithphpMyadminoropenitusingacodeeditor.
Tousethesecondoption,performthesetaskswithinphpMyadmin:1.
Gotothedatabasecreatedforthesub-site.
2.
GotoSQL,andthenpasteallofthecodefromtheStructuredQueryLanguage(SQL)dumpthere.
3.
ClickonGo.
Thisprocedurereproducesthemastersitedatabasetablesinthesub-sitedatabase.
Next,openthesettings.
phpfileforeachsub-site,andlookforthefollowingline:$db_url='mysql://username:password@localhost/databasename';Changethisdatabaseconnectingstringtoreflecttheparametersforthesub-sitedatabase(username,password,hostname,databasename).
Nowifyougotobettersite.
com,youshouldgetthestandard"WelcometoyournewDrupalwebsite"page,asshowninFigure2.
Repeatthesestepsforalladditionalsites.
Figure2.
YournewwebsiteinDrupalCreatingmultisitesfromsub-domainsThereisanotherwaytoquicklycreatemultisitesbyfirstdetailingthemassub-domainsfromtheCpanel.
Inthismethod,however,youmustinitiallycreatefoldersforeachsiteunder/goodsite/sites,thistimeusingthefollowingconvention(seeFigure3):Sub-site1:/www/goodsite/sites/bettersite.
comSub-site2:/www/goodsite/sites/bestsite.
comdeveloperWorksibm.
com/developerWorks/CreatingaDrupalmultisiteinstallationPage6of10Figure3.
Creatingmultisitesfromsub-domainsNotethatthesub-domainfoldersmusthavethesamenamesasthesub-domainsthemselves.
Asbefore,putacopyofdefault.
settings.
phpineachsub-domainfolder,changethefilenametosettings.
php,andissueCHMODtochangethepermissionto644.
Now,returntoCpanelandcreatetwosub-domains:bettersite.
goodsite.
combestsite.
goodsite.
comCreateasymlinkAsymlinkisafilethatcontainsareferencetoanotherfileorfolderintheformofanabsoluteorrelativepathandiscreatedtoaffectpathnameresolution.
Useanycodeeditortocreateafilecalledsymlink.
php,andthenaddcodesimilartothefollowing:Inthiscase,thefilewouldlooksomethinglikethis:Putthissymlinkinthemaindirectoryofthemainsite,andrunitfromtheURLhttp://goodsite.
com/symlink.
php.
Ifthecodesyntaxisgood,youshouldseeablankpage;otherwise,youwillseeerrormessages.
Tweakthecodeinthisfileuntilitcomesoutcorrectly.
Configure.
htaccessNowopenthe.
htaccessfileinanycodeeditor.
Lookforthefollowingline:#RewriteBase/ibm.
com/developerWorks/developerWorksCreatingaDrupalmultisiteinstallationPage7of10Removethehashsign(#),andaddthefollowinglinebeforesavingthechanges:RedirectMatch301^/sub-domain/(.
*)$http://sub-domain.
yoursite.
com$1Here'swhat.
htaccessshouldlooklikewhenfinished:RewriteBase/RedirectMatch301^/bettersite/(.
*)$http://bettersite.
goodsite.
com/$1RedirectMatch301^/bestsite/(.
*)$http://bestsite.
goodsite.
com/$1Thisredirectionmakesitpossibleforbothhttp://goodsite.
com/bettersiteandhttp://bettersite.
goodsite.
comtoberedirectedtothesamesite.
Ifeverythinghasbeendonecorrectly,youwillbedirectedtotheinstallationpagewhenyouaccessthesub-siteURLshttp://bettersite.
goodsite.
comandhttp://bestsite.
goodsite.
com.
Withallthesitesinstalled,it'seasyfromtheCpaneltoassociatethesitehttp://bettersite.
goodsite.
comusingaredirecttotheURLhttp://bettersite.
com.
MultisiteonalocalhostrunningUbuntuRunningamultisiteinstallationonUbuntuisabitmorecomplicatedthanwhatyouhavedonesofarforremotehosting.
Amultisiteinstallationcanbeeasilyconfiguredusingthemethodoutlinedinthefollowingsections.
CreateanewhostsfolderBeginbycreatingafoldercalledgoodsiteinyourhomefolderusingthefollowingcode:>>filesystem/home//Theresultshouldbe->/home//goodsite.
NowcopyallyourDrupalfilesintothisfolder.
EditthehostsfileEditthehostsfilebyopeningaterminalwindowwiththefollowingcommand:sudogedit/etc/hosts'Youcanthenaddanysitenameintheformat127.
0.
0.
1mysite.
com.
Forthisexample,addthefollowinglines:127.
0.
0.
1goodsite.
com127.
0.
0.
1bettersite.
com127.
0.
0.
1bestsite.
comEditthesitesavailableNowgotothesites-availablefoldertocreateafilecalledgoodsite.
comusingthefollowingcommands:developerWorksibm.
com/developerWorks/CreatingaDrupalmultisiteinstallationPage8of10cd/etc/apache2/sites-availablesudocpdefaultgoodsite.
comsudogeditgoodsite.
comThefirstcommandgoestothesites-availablefolder;thesecondcommandcopiesthedefaultfileandrenamesitgoodsite.
com.
Thethirdcommandopensthefilegoodsite.
comforediting.
AddthecodeshowninListing1tothefile.
Listing1.
Additiontothesites-availablefolderfileforthenewsiteServerAdminwebmaster@localhostServerNamegoodsite.
comDocumentRoot/home//goodsiteOptionsFollowSymLinksAllowOverrideAllSavegoodsite.
com,enableit,andthenreloadApacheusingthefollowingcommands:sudoa2ensitemysite.
comsudo/etc/init.
d/apache2reloadCreatesub-sitefoldersCreateyoursub-siteinthe/sitesfolder/home/[yourubuntuloginname]/goodsite/sites/bettersite.
com,andthenaddsettings.
phptothenewfolder.
Ifyouhavealreadynavigatedtothesites/directory,copythesettings.
phpfilewiththefollowingcommand:$cpdefault/default.
settings.
phpbettersite.
com/settings.
php$chmod777bettersite.
com/settings.
phpRunsub-siteinstallationOpenyourbrowser,thentypehttp://bettersite.
com.
Youshouldseetheinstallationsetuppage.
Makethesettings.
phpfileread-onlyagaintoavoidsecuritymessages,thenrunthesub-siteinstallation.
Next,createasitefolderandruntheinstallationforbestsite.
comaswellasanyothersub-sitesmentionedinyourhostsconfiguration.
MultisitemodulesModulesareusedtoextendthefunctionalityofabasicDrupalinstallationandcomeinvariouscategories,fromadministrativetoactualperformance-enhancementfunctionalities.
Severalmodulescanassistincreatingamultisiteorsimilarconfiguration.
Fordetailsonhowtousethesemodules,consulttheinstallationdocumentationforeachmodule.
TheDomainAccessmodulesTheDomainAccessmodules(seeRelatedtopicsforalink)enablethecreationofamultisiteusingasinglecodebase,ashareduserdatabase,andsharedsign-onbutwithdifferentcontentibm.
com/developerWorks/developerWorksCreatingaDrupalmultisiteinstallationPage9of10databases.
Suchaconfigurationisdifferentfromwhatwehavedoneinthisarticle.
DomainAccessisactuallydescribedasasetofmodulesthatfacilitaterunningagroupofsitesbyusingonebasicDrupalcodeinstalledinsideasingleshareddatabase.
Thesemodulesenableallofthesitestoshareusers,content,andsettingsiftheyhavebeenpreconfiguredtooperateinsuchaway.
TheDomainAccessmodulesemployDrupal'sNodeAccessSystemtoestablishwhichcontentshouldbemadeavailableoneachsiteinthemultisitearrangement.
Themodules,unlikeothermultidomainmodules,alsocontroluseraccessonthebasisoftheactivedomaintheuserisviewing,notonthebasisofthegrouporsitetowhichtheuserbelongs.
TheMultisiteManagermoduleTheMultisiteManager(seeRelatedtopicsforalink)isacontributedmodulethatallowscreationofnewDrupalsitesfromabaseDrupalsitewithouttheneedtoaccesstheinstallationdatabase.
Bydefault,thenewsiteisinstalledinthesamedatabaseasthebaseinstallation,butwithadifferentprefix.
Otherwise,ifthecurrentuserhasaccesspermissiontocreateadatabase,theinstallationcouldpossiblybedoneinthatdatabase.
ConclusionThisarticleexploredhowtocreateamultisitesconfigurationusingDrupalasthebaseCMS.
Youinstalledthemastersiteandlocatedthesub-siteswithinitsdirectorystructure.
Youlearnedhowtorunmultisiteinstallationsonaremoteserverbyusingtheadministrativefacilitiesyourhostingcompanyprovides.
Youalsolearnedhowtocreateamultisiteinstallationonalocalmachine—specifically,onacomputerrunningUbuntuLinux.
ThisarticlealsointroducedtwoDrupalmodulesthatcanassistyouinthecreationofbothmultisiteandmultidomainconfigurations.
developerWorksibm.
com/developerWorks/CreatingaDrupalmultisiteinstallationPage10of10RelatedtopicsDownloadthelatestversionofDrupal.
LearnmoreabouttheDomainAccessmodules.
LearnmoreabouttheMultisiteManagermodule.
CopyrightIBMCorporation2013(www.
ibm.
com/legal/copytrade.
shtml)Trademarks(www.
ibm.
com/developerworks/ibm/trademarks/)
优惠码年付一次性5折优惠码:TYO-Lite-Open-Beta-1y-50OFF永久8折优惠码:TYO-Lite-Open-Beta-Recur-20OFF日本vpsCPU内存SSD流量带宽价格购买1核1.5G20 GB4 TB1Gbps$10.9/月购买2核2 G40 GB6 TB1Gbps$16.9/月购买2核4 G60 GB8 TB1Gbps$21.9/月购买4核4 G80 GB12 TB...
cmivps香港VPS带来了3个新消息:(1)双向流量改为单向流量,相当于流量间接扩大一倍;(2)Hong Kong 2T、Hong Kong 3T、Hong Kong 无限流量,这三款VPS开始支持Windows系统,如果需要中文版Windows系统请下单付款完成之后发ticket要求官方更改即可;(3)全场7折年付、8折月付优惠,优惠码有效期一个月!官方网站:https://www.cmivp...
提速啦简单介绍下提速啦 是成立于2012年的IDC老兵 长期以来是很多入门级IDC用户的必选商家 便宜 稳定 廉价 是你创业分销的不二之选,目前市场上很多的商家都是从提速啦拿货然后去分销的。提速啦最新物理机活动 爆炸便宜的香港CN2物理服务器 和 日本CN2物理服务器香港CTG E5 2650 16G内存 20M CN2带宽 1T硬盘 150元/月日本CN2 E5 2650 16G内存 20M C...
rewritebase为你推荐
weipin唯品单号为16060958116346的快递在哪了呢?在线漏洞检测网站检测工具,谁有?iphone越狱后怎么恢复苹果越狱后怎么恢复出厂设置开机滚动条如何关闭开机滚动条?畅想中国畅想中国发展前景lockdowndiphone4s 完美越狱5.1.1时出现Could not connect to lockdownd。求救啊!!网页打不开的原因为什么我的网页打不开怎样申请支付宝怎么申请支付宝优锁诺基亚软件大全,特别是程序锁的软件2018最火爆的歌曲2018最火十大歌曲是哪些?
域名论坛 中文域名注册 希网动态域名 budgetvm 新秒杀 80vps site5 站群服务器 圣迭戈 美国php空间 免费网络电视 三拼域名 架设服务器 hostker 免费个人空间 老左来了 共享主机 服务器是干什么的 新世界服务器 免费asp空间 更多