Professional Documents
Culture Documents
Build ASP.NET/Mono Applications with mod_mono and Apache on Debian 5 (Lenny) - Linode Guides & Tutorials
Guides&Tutorials(/docs/)
WebServerGuides(/docs/websites/)
WebApplicationFrameworks(/docs/websites/frameworks/)
BuildASP.NET/MonoApplicationswithmod_monoandApacheonDebian5(Lenny)
Deprecated
Thisguidehasbeendeprecatedandisnolongerbeingmaintained.
mod_monoisanApachemodulethatmakesitpossibletorunASP.NETapplicationsin
LinuxenvironmentsrunningApache.WhileASP.NETisaMicrosofttechnologyandis
traditionallyusedwithIIS, mod_monohasbecomeaviableoptionfordeployingASP.NET
applicationsonLinux.Thisguideisinspiredbythemod_monoguidecreatedbytheUbuntu
Community(https://help.ubuntu.com/community/ModMono)andtheMonoProjectsApache
andMonodocument(http://monoproject.com/Mod_mono)withminormodifications.This
guidedoesnotcoverinstallationandconfigurationoftheMonoIDEwhichisusedto
developASP.NETapplicationsonLinux.IfyouareinterestedindevelopingusingVisual
StudioforMono,youcandownloada30daytrialofthecommercialMonoToolspluginat
theMonoToolsforVisualStudiopage(http://gomono.com/monotools).
Thisguideassumesthatyouvefollowedthestepsoutlinedinourgettingstartedguide
(/docs/gettingstarted/).YouwillinstalltheApachewebserver(/docs/web
servers/apache/installation/debian5lenny)withveryminimalconfiguration.Ifyoualready
haveApacheinstalledandconfigured,youmayomitthesestepshowever,ifyouhavenot
installedApacheandareunfamiliarwiththisserverreadtheinstallationguideforadditional
https://www.linode.com/docs/websites/frameworks/build-aspnetmono-applications-with-modmono-and-apache-on-debian-5-lenny
1/12
18/11/2014
Build ASP.NET/Mono Applications with mod_mono and Apache on Debian 5 (Lenny) - Linode Guides & Tutorials
documentation.Additionally, mod_monoisincompatiblewiththeintegratedPHPinterpreter
describedinotherguides.Ifyouneedtohavebothmod_monoandPHPrunningonthe
sameApacheserveryouwillneedtorunPHPscriptsusingtheCGImethod(/docs/web
servers/apache/phpcgi/debian5lenny)
hostname
hostnamef
Thefirstcommandshouldshowyourshorthostname,andthesecondshouldshowyour
fullyqualifieddomainname(FQDN).
aptgetupdate
aptgetupgrade
Install Apache
IfyoualreadyhaveApacheinstalledandconfigured,youcansafelyskipthissectionofthe
guide.InstallApachebyrunningthefollowingcommand:
https://www.linode.com/docs/websites/frameworks/build-aspnetmono-applications-with-modmono-and-apache-on-debian-5-lenny
2/12
18/11/2014
Build ASP.NET/Mono Applications with mod_mono and Apache on Debian 5 (Lenny) - Linode Guides & Tutorials
aptgetinstallapache2
Asmentionedearlier,youwillneedtogototheinstallationguideifyouwishtoconfigure
yourserverbeyondthedefaultconfiguration.
Install mod_mono
TheApachedaemonmustbestoppedbefore mod_monoisinstalled.Issuethefollowing
commandtostoptheapacheprocess:
1
/etc/init.d/apache2stop
Atthispointwereabletoinstalltherequiredpackagesfor mod_mono.Runthefollowing
command:
1
aptgetinstallmonoapacheserver2libapache2modmonolibmonoi18n2.0cil
WhentheinstallationprocesscompletesstartApachewiththefollowingcommand:
1
/etc/init.d/apache2start
Configure Apache
Werecommendusingnamebasedvirtualhostsforwebhosting.RefertotheApache
documentationforsettingupNamebasedvirtualhosts(/docs/web
servers/apache/installation/debian5
lenny#configure_apache_for_named_based_virtual_hosting).
Recentversionsof mod_monoutilizethe AutoHostingmethodofapplicationdeployment.
ThisallowsnonprivilegeduserstodeploynewapplicationswithoutmodifyingApache
configurationfiles.Whilethisprovidesgreatflexibility,itmayalsopresentasecurityrisk.As
https://www.linode.com/docs/websites/frameworks/build-aspnetmono-applications-with-modmono-and-apache-on-debian-5-lenny
3/12
18/11/2014
Build ASP.NET/Mono Applications with mod_mono and Apache on Debian 5 (Lenny) - Linode Guides & Tutorials
aresult, mod_monomustbeenabledonapervirtualhostbasis.
Forthesakeofthisguide,weregoingtocreateasiteontherootofourexampledomain,
example.com.IfyoualreadyhaveanApacheconfigurationfortherootofyoursite,youwill
needtomodifyyourexistingvirtualhostfileorcreateanewoneonasubdomainofyour
site.Createthevirtualhostfile,takingthefollowingexamplevirtualhostconfigurationand
modifyingittosuityourneeds.YoumayalsousetheMod_MonoConfigurationGenerator
(http://gomono.com/configmodmono/)togenerateyourowncustomconfiguration.
<VirtualHost*:80>
ServerNameexample.com
ServerAdminadmin@example.com
ServerAliaswww.example.com
DocumentRoot/srv/www/example.com/public_html
ErrorLog/srv/www/example.com/logs/error.log
CustomLog/srv/www/example.com/logs/access.logcombined
MonoServerPathexample.com"/usr/bin/modmonoserver2"
MonoDebugexample.comtrue
MonoSetEnvexample.comMONO_IOMAP=all
MonoApplicationsexample.com"/:/srv/www/example.com/public_html"
<Location"/">
Allowfromall
Orderallow,deny
MonoSetServerAliasexample.com
SetHandlermono
SetOutputFilterDEFLATE
SetEnvIfNoCaseRequest_URI"\.(?:gif|jpe?g|png)$"nogzipdontvary
</Location>
<IfModulemod_deflate.c>
AddOutputFilterByTypeDEFLATEtext/htmltext/plaintext/xmltext/javascript
</IfModule>
</VirtualHost>
Saveandclosethefile,andcreatethedirectoriesreferencedinthe DocumentRootand
ErrorLogdirective:
https://www.linode.com/docs/websites/frameworks/build-aspnetmono-applications-with-modmono-and-apache-on-debian-5-lenny
4/12
18/11/2014
1
2
Build ASP.NET/Mono Applications with mod_mono and Apache on Debian 5 (Lenny) - Linode Guides & Tutorials
mkdirp/srv/www/example.com/public_html
mkdir/srv/www/example.com/logs
Enablethesitebyrunningthe a2ensitecommand:
1
a2ensiteexample.com
Sincewehavemodifiedthevirtualhostconfiguration,Apachemustbereloaded:
1
/etc/init.d/apache2reload
Note:ShouldyourestartApacheinthefuture,youwillseeanerrorthatwilllooksimilarto
this:
1
2
3
[crit](13)Permissiondenied:Failedtoattachtoexistingdashboard,
andremovingdashboardfile'/tmp/mod_mono_dashboard_XXGLOBAL_1'failed
(Operationnotpermitted).Furtheractionimpossible.
Youcansafelyignorethiswarning,asitwontaffectdeploymentusingthemethods
explainedinthisguide.
aptgetinstallmysqlserver
https://www.linode.com/docs/websites/frameworks/build-aspnetmono-applications-with-modmono-and-apache-on-debian-5-lenny
5/12
18/11/2014
Build ASP.NET/Mono Applications with mod_mono and Apache on Debian 5 (Lenny) - Linode Guides & Tutorials
InorderforyourASP.NETapplicationtocommunicateproperlywithyourMySQLserver,
youmustinstalltheMySQLConnector/Netdriver.Thefollowingcommandsdownloadand
installthe6.2.3versionoftheconnector.ChecktheMySQLUpstream
(http://dev.mysql.com/downloads/connector/net/)toensurethatthisthelatestversionofthe
plugin:
1
2
3
4
5
6
cd/opt/
wgethttp://dev.mysql.com/get/Downloads/ConnectorNet/mysqlconnectornet6.2.3noi
unzipdmysqlConnectormysqlconnectornet6.2.3noinstall.zip
cdmysqlConnector
gacutilimysql.data.dll
gacutilimysql.web.dll
mysqlurootp
Nextyoumustcreatethesampletable.IssuethefollowingcommandsattheMySQL
prompt:
1
2
3
4
5
6
7
8
CREATEDATABASEsample
USEsample
CREATETABLEtest(idINTAUTO_INCREMENTPRIMARYKEY,nameVARCHAR(25))
INSERTINTOsample.testVALUES(null,'Lucy')
INSERTINTOsample.testVALUES(null,'Ivan')
INSERTINTOsample.testVALUES(null,'Nicole')
INSERTINTOsample.testVALUES(null,'Ursula')
INSERTINTOsample.testVALUES(null,'Xavier')
https://www.linode.com/docs/websites/frameworks/build-aspnetmono-applications-with-modmono-and-apache-on-debian-5-lenny
6/12
18/11/2014
Build ASP.NET/Mono Applications with mod_mono and Apache on Debian 5 (Lenny) - Linode Guides & Tutorials
Finallyyoumustcreateatestusernamedtestuserandgivethatuseraccesstothenewly
createdsampledatabase:
1
2
3
CREATEUSER'testuser'@'localhost'IDENTIFIEDBY'somepassword'
GRANTALLPRIVILEGESONsample.*TO'testuser'@'localhost'
FLUSHPRIVILEGES
https://www.linode.com/docs/websites/frameworks/build-aspnetmono-applications-with-modmono-and-apache-on-debian-5-lenny
7/12
18/11/2014
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
Build ASP.NET/Mono Applications with mod_mono and Apache on Debian 5 (Lenny) - Linode Guides & Tutorials
<%@PageLanguage="C#"%>
<%@ImportNamespace="System.Data"%>
<%@ImportNamespace="MySql.Data.MySqlClient"%>
<!DOCTYPEhtmlPUBLIC"//W3C//DTDXHTML1.0Strict//EN""http://www.w3.org/TR/xht
<htmlxmlns="http://www.w3.org/1999/xhtml"xml:lang="en"lang="en">
<head>
<title>ASPandMySQLTestPage</title>
<metahttpequiv="ContentType"content="text/htmlcharset=utf8"/>
<scriptrunat="server">
privatevoidPage_Load(Objectsender,EventArgse)
{
stringconnectionString="Server=127.0.0.1Database=sampleUserID=testuserPassw
MySqlConnectiondbcon=newMySqlConnection(connectionString)
dbcon.Open()
MySqlDataAdapteradapter=newMySqlDataAdapter("SELECT*FROMtest",dbcon)
DataSetds=newDataSet()
adapter.Fill(ds,"result")
dbcon.Close()
dbcon=null
SampleControl.DataSource=ds.Tables["result"]
SampleControl.DataBind()
}
</script>
</head>
<body>
<h1>TestingSampleDatabase</h1>
<asp:DataGridrunat="server"id="SampleControl"/>
</body>
</html>
https://www.linode.com/docs/websites/frameworks/build-aspnetmono-applications-with-modmono-and-apache-on-debian-5-lenny
8/12
18/11/2014
Build ASP.NET/Mono Applications with mod_mono and Apache on Debian 5 (Lenny) - Linode Guides & Tutorials
Nextyouwillneedtocreatea web.configfile.Youcancopyandpastethetheexample
below.Pleasenotethat CustomErrorshavebeenturnedoffinthisweb.configfor
debuggingpurposes.The customErrorsmodelineshouldberemovedinaproduction
environment.
<configuration>
<system.web>
<customErrorsmode="Off"/>
<compilation>
<assemblies>
<addassembly="MySql.Data"/>
</assemblies>
</compilation>
</system.web>
</configuration>
Visitthe testdb.aspxfileinawebbrowser.IfyouseethetextTestingSampleDatabases
inyourbrowserwiththeinformationthatyouinsertedintothedatabaseabove,younow
haveafunctioning mod_monoinstallationandcancontinuewiththedevelopmentand
deploymentofyourownapplication!
More Information
Youmaywishtoconsultthefollowingresourcesforadditionalinformationonthistopic.
Whiletheseareprovidedinthehopethattheywillbeuseful,pleasenotethatwecannot
vouchfortheaccuracyortimelinessofexternallyhostedmaterials.
MonoProjectHomepage(http://monoproject.com/Mod_mono)
MonoProjectAutohostingDocumentation(http://www.mono
project.com/AutoHosting)
Mod_MonoConfigurationGenerator(http://gomono.com/configmodmono/)
ModMonoUbuntuCommunityDocumentation
https://www.linode.com/docs/websites/frameworks/build-aspnetmono-applications-with-modmono-and-apache-on-debian-5-lenny
9/12
18/11/2014
Build ASP.NET/Mono Applications with mod_mono and Apache on Debian 5 (Lenny) - Linode Guides & Tutorials
(https://help.ubuntu.com/community/ModMono)
ThisguideispublishedunderaCCBYND3.0(http://creativecommons.org/licenses/bynd/3.0/us/)license.
Overview (https://www.linode.com/linodes)
Plans&Pricing(https://www.linode.com/pricing)
Features(https://www.linode.com/linodes)
Backups(https://www.linode.com/backups)
NodeBalancers(https://www.linode.com/nodebalancers)
Longview(https://www.linode.com/longview)
Managed(https://www.linode.com/managed)
https://www.linode.com/docs/websites/frameworks/build-aspnetmono-applications-with-modmono-and-apache-on-debian-5-lenny
10/12
18/11/2014
Build ASP.NET/Mono Applications with mod_mono and Apache on Debian 5 (Lenny) - Linode Guides & Tutorials
StackScripts(https://www.linode.com/stackscripts)
Mobile(https://www.linode.com/mobile)
CLI(https://www.linode.com/cli)
API(https://www.linode.com/api)
Resources (https://www.linode.com/docs)
GettingStarted(https://www.linode.com/docs/gettingstarted)
MigratingtoLinode(https://www.linode.com/docs/migratefromshared)
HostingaWebsite(https://www.linode.com/docs/hostingwebsite)
Guides&Tutorials(https://www.linode.com/docs)
SpeedTest(https://www.linode.com/speedtest)
Forum(https://forum.linode.com/)
Chat(https://www.linode.com/chat)
SystemStatus(http://status.linode.com/)
Company (https://www.linode.com/about)
AboutUs(https://www.linode.com/about)
Blog(https://blog.linode.com)
Logos(https://www.linode.com/logos)
Careers(https://www.linode.com/careers)
Contact(https://www.linode.com/contact)
https://www.linode.com/docs/websites/frameworks/build-aspnetmono-applications-with-modmono-and-apache-on-debian-5-lenny
11/12
18/11/2014
Build ASP.NET/Mono Applications with mod_mono and Apache on Debian 5 (Lenny) - Linode Guides & Tutorials
Contact Us (https://www.linode.com/contact)
8554LINODE(tel:+18554546633)
(8554546633)(tel:+18554546633)
Emailus(mailto:support@linode.com)
Facebook(https://facebook.com/linode)
Twitter(https://twitter.com/linode)
Google+(https://plus.google.com/+linode/)
Linkedin(https://linkedin.com/company/linode)
Github(https://github.com/linode/)
2014Linode,LLC
TermsofService(https://www.linode.com/tos)
PrivacyPolicy(https://www.linode.com/privacy)
Security(https://www.linode.com/security)
https://www.linode.com/docs/websites/frameworks/build-aspnetmono-applications-with-modmono-and-apache-on-debian-5-lenny
12/12