<?xml version="1.0" encoding="utf-8"?><!DOCTYPE article  PUBLIC '-//OASIS//DTD DocBook XML V4.4//EN'  'http://www.docbook.org/xml/4.4/docbookx.dtd'><article><articleinfo><title>MemberManual/ServingWebsites</title><revhistory><revision><revnumber>55</revnumber><date>2021-02-24 02:47:00</date><authorinitials>ClintonEbadi</authorinitials><revremark>fix example, fast_php is deprecated</revremark></revision><revision><revnumber>54</revnumber><date>2020-02-28 03:14:08</date><authorinitials>ClintonEbadi</authorinitials><revremark>Change language in HTTP subsection to make it clearer that the linked page explains how to generate a CSR</revremark></revision><revision><revnumber>53</revnumber><date>2018-10-20 18:18:58</date><authorinitials>ClintonEbadi</authorinitials><revremark>bits about sni and windows xp are finally not very relevant, ip address comment more generic ... for now digitalocean gives free ipv4 as long as we use them</revremark></revision><revision><revnumber>52</revnumber><date>2018-10-20 18:14:37</date><authorinitials>ClintonEbadi</authorinitials><revremark>php5 -&gt; fast_php</revremark></revision><revision><revnumber>51</revnumber><date>2016-02-09 21:59:33</date><authorinitials>StephenMichel</authorinitials><revremark>sentence order makes sense now</revremark></revision><revision><revnumber>50</revnumber><date>2014-05-02 05:43:29</date><authorinitials>c-50-148-186-167.hsd1.ca.comcast.net</authorinitials></revision><revision><revnumber>49</revnumber><date>2014-04-23 03:58:12</date><authorinitials>ClintonEbadi</authorinitials><revremark>the cruft! oh the cruft!</revremark></revision><revision><revnumber>48</revnumber><date>2014-04-23 03:50:52</date><authorinitials>ClintonEbadi</authorinitials><revremark>webdav in general works, but dav.hcoop.net is gone</revremark></revision><revision><revnumber>47</revnumber><date>2014-04-23 01:28:31</date><authorinitials>MattCarberry</authorinitials><revremark>Removed WebDAV info now that it no longer exists.</revremark></revision><revision><revnumber>46</revnumber><date>2013-01-21 17:50:35</date><authorinitials>ClintonEbadi</authorinitials><revremark>fun fact: because of TIME you don't need an IP to use SSL any more, hooray</revremark></revision><revision><revnumber>45</revnumber><date>2013-01-14 07:15:36</date><authorinitials>ClintonEbadi</authorinitials><revremark>typos</revremark></revision><revision><revnumber>44</revnumber><date>2013-01-14 07:12:58</date><authorinitials>ClintonEbadi</authorinitials><revremark>cat / coming domtool-tail changes</revremark></revision><revision><revnumber>43</revnumber><date>2013-01-06 11:53:10</date><authorinitials>ClintonEbadi</authorinitials><revremark>note that permissions do not actually affect anything and only need to be set to make suexec shut up</revremark></revision><revision><revnumber>42</revnumber><date>2013-01-05 06:09:35</date><authorinitials>c-66-41-66-133.hsd1.mn.comcast.net</authorinitials></revision><revision><revnumber>41</revnumber><date>2012-12-17 21:17:32</date><authorinitials>ClintonEbadi</authorinitials><revremark>organizational nit</revremark></revision><revision><revnumber>40</revnumber><date>2009-11-18 13:20:50</date><authorinitials>AdamChlipala</authorinitials><revremark>I believe the original was right.  Let us know if one of our machines is missing 'fsr'.</revremark></revision><revision><revnumber>39</revnumber><date>2009-11-18 08:09:26</date><authorinitials>quinto.staff.cscs.ch</authorinitials><revremark>typo fix</revremark></revision><revision><revnumber>38</revnumber><date>2009-09-09 20:08:25</date><authorinitials>ClintonEbadi</authorinitials><revremark>Revert to revision 36.</revremark></revision><revision><revnumber>37</revnumber><date>2009-09-09 18:20:33</date><authorinitials>93.174.94.59</authorinitials><revremark>zD0N8X on Aviation Environment Protection (CAEP) is responsible for setting standards relat-, [[http://ukazurenet.com/members/qantas_2D00_airline/default.aspx|qantas airline]]In regions where temperat</revremark></revision><revision><revnumber>36</revnumber><date>2008-07-15 19:58:18</date><authorinitials>AdamChlipala</authorinitials><revremark>domtool-tail</revremark></revision><revision><revnumber>35</revnumber><date>2008-07-07 04:28:02</date><authorinitials>localhost</authorinitials><revremark>converted to 1.6 markup</revremark></revision><revision><revnumber>34</revnumber><date>2008-05-25 13:30:37</date><authorinitials>AdamChlipala</authorinitials><revremark>RunningYourOwnApache</revremark></revision><revision><revnumber>33</revnumber><date>2008-04-20 23:48:27</date><authorinitials>DavorOcelic</authorinitials></revision><revision><revnumber>32</revnumber><date>2008-04-20 23:46:57</date><authorinitials>DavorOcelic</authorinitials></revision><revision><revnumber>31</revnumber><date>2008-03-11 17:23:53</date><authorinitials>JustinLeitgeb</authorinitials><revremark>modify WebDAV instructions -- read and write works with https://dav.hcoop.net</revremark></revision><revision><revnumber>30</revnumber><date>2008-01-20 06:42:59</date><authorinitials>MichaelOlson</authorinitials><revremark>s/and/or/</revremark></revision><revision><revnumber>29</revnumber><date>2008-01-20 06:42:12</date><authorinitials>MichaelOlson</authorinitials><revremark>Add PHP explanation</revremark></revision><revision><revnumber>28</revnumber><date>2008-01-15 01:55:02</date><authorinitials>adsl-dynamic-pool-xxx.hcm.fpt.vn</authorinitials></revision><revision><revnumber>27</revnumber><date>2007-12-15 17:20:32</date><authorinitials>AdamChlipala</authorinitials><revremark>members -&gt; members2</revremark></revision><revision><revnumber>26</revnumber><date>2007-12-14 00:32:43</date><authorinitials>AdamChlipala</authorinitials><revremark>Stress /var/log/apache2 off limits</revremark></revision><revision><revnumber>25</revnumber><date>2007-12-11 03:17:15</date><authorinitials>RyanMikulovsky</authorinitials><revremark>.htaccess warning</revremark></revision><revision><revnumber>24</revnumber><date>2007-11-24 01:53:38</date><authorinitials>RyanMikulovsky</authorinitials><revremark>REALLY bold it this time</revremark></revision><revision><revnumber>23</revnumber><date>2007-11-24 01:53:13</date><authorinitials>RyanMikulovsky</authorinitials><revremark>bold  USER</revremark></revision><revision><revnumber>22</revnumber><date>2007-11-23 22:01:43</date><authorinitials>RyanMikulovsky</authorinitials><revremark>USER.daemon for dynamic websites..</revremark></revision><revision><revnumber>21</revnumber><date>2007-11-22 20:11:56</date><authorinitials>AdamChlipala</authorinitials><revremark>Rewrite Domtool example to use 'webAtIp' like mwolson should have in the first place. ;-)</revremark></revision><revision><revnumber>20</revnumber><date>2007-11-19 03:38:31</date><authorinitials>MichaelOlson</authorinitials><revremark>update dav example.  remove ssl example</revremark></revision><revision><revnumber>19</revnumber><date>2007-11-17 05:51:28</date><authorinitials>MichaelOlson</authorinitials><revremark>Typo</revremark></revision><revision><revnumber>18</revnumber><date>2007-11-17 05:50:23</date><authorinitials>MichaelOlson</authorinitials><revremark>Remove warning, update paths</revremark></revision><revision><revnumber>17</revnumber><date>2007-11-16 02:50:21</date><authorinitials>MichaelOlson</authorinitials><revremark>Link to MoinMoin subpage</revremark></revision><revision><revnumber>16</revnumber><date>2007-11-14 05:14:27</date><authorinitials>MichaelOlson</authorinitials><revremark>HTTPS is a work-in-progress</revremark></revision><revision><revnumber>15</revnumber><date>2007-11-12 15:33:37</date><authorinitials>MichaelOlson</authorinitials><revremark>update freq of webalizer</revremark></revision><revision><revnumber>14</revnumber><date>2007-11-12 15:31:44</date><authorinitials>MichaelOlson</authorinitials><revremark>Mention webalizer and ~/.logs/apache</revremark></revision><revision><revnumber>13</revnumber><date>2007-11-12 05:23:30</date><authorinitials>RyanMikulovsky</authorinitials></revision><revision><revnumber>12</revnumber><date>2007-11-12 05:23:00</date><authorinitials>RyanMikulovsky</authorinitials></revision><revision><revnumber>11</revnumber><date>2007-11-12 03:46:17</date><authorinitials>RyanMikulovsky</authorinitials><revremark>extraneous / at end of WebDAV setup URL</revremark></revision><revision><revnumber>10</revnumber><date>2007-11-12 03:45:47</date><authorinitials>MichaelOlson</authorinitials><revremark>Fix ssl cert instructions link</revremark></revision><revision><revnumber>9</revnumber><date>2007-11-12 03:41:18</date><authorinitials>MichaelOlson</authorinitials><revremark>Add HTTPS example and link to ssl cert subpage</revremark></revision><revision><revnumber>8</revnumber><date>2007-11-12 03:35:19</date><authorinitials>MichaelOlson</authorinitials><revremark>Make DAV example more generic</revremark></revision><revision><revnumber>7</revnumber><date>2007-11-12 03:33:37</date><authorinitials>MichaelOlson</authorinitials><revremark>Add DAV example</revremark></revision><revision><revnumber>6</revnumber><date>2007-11-12 02:11:34</date><authorinitials>MichaelOlson</authorinitials><revremark>Initial DAV and HTTPS instructions, sans examples</revremark></revision><revision><revnumber>5</revnumber><date>2007-11-12 01:54:55</date><authorinitials>MichaelOlson</authorinitials><revremark>Move &quot;see ...&quot; part to end of section for readability, and point at MemberManual AFS section</revremark></revision><revision><revnumber>4</revnumber><date>2007-11-11 20:11:21</date><authorinitials>RyanMikulovsky</authorinitials><revremark>transfer stuff from MigrationGuide</revremark></revision><revision><revnumber>3</revnumber><date>2007-11-11 19:57:53</date><authorinitials>RyanMikulovsky</authorinitials><revremark>add a friendly hints, and links, to make common tasks described in the manual easily accessible</revremark></revision><revision><revnumber>2</revnumber><date>2007-11-11 19:44:47</date><authorinitials>RyanMikulovsky</authorinitials><revremark>add some content</revremark></revision><revision><revnumber>1</revnumber><date>2007-10-25 01:22:48</date><authorinitials>MichaelOlson</authorinitials><revremark>Initial contents</revremark></revision></revhistory></articleinfo><para>This is the chapter of the <ulink url="https://wiki.hcoop.net/MemberManual/ServingWebsites/MemberManual#">MemberManual</ulink> that describes how to serve your website(s). </para><section><title>Static Web Sites</title><para>If you're going to use a domain, please read the next section.  If you plan on having static websites without any CGI such as <code>php</code> or <code>perl</code>, then read on.  In your home directory, there is a directory named <code>public_html</code>.  By default, you can access this at <code>http://www.hcoop.net/~USER</code>.  You will never be able to execute server-side scripts when accessing webpages in that manner.  </para></section><section><title>Dynamic Web Sites</title><para>If you plan on having a website that utilizes CGI such as <code>php</code> or <code>perl</code>, then you must either have a domain or an <code>hcoop.net</code> subdomain (i.e., <code>USER.hcoop.net</code>). </para><para>When you have chosen a domain to be hosted by HCoop, you then simply request control of that domain at the <ulink url="http://members.hcoop.net">portal</ulink>.  Once it is authorized by an administrator, you will be able to utilize <ulink url="https://wiki.hcoop.net/MemberManual/ServingWebsites/DomTool#">DomTool</ulink>.  <ulink url="https://wiki.hcoop.net/MemberManual/ServingWebsites/DomTool#">DomTool</ulink> will let Apache and other services know about your domain.  Please take a look at <ulink url="https://wiki.hcoop.net/MemberManual/ServingWebsites/MemberManual/UsingDomtool#">using DomTool</ulink>, <ulink url="https://wiki.hcoop.net/MemberManual/ServingWebsites/DomTool/UserGuide#">DomTool user guide</ulink>, and <ulink url="https://wiki.hcoop.net/MemberManual/ServingWebsites/DomTool/Examples#">DomTool examples</ulink> to learn how to do this.  Our nameservers are <code>ns1.hcoop.net</code> and <code>ns2.hcoop.net</code>. </para><para>As a hint, <ulink url="https://wiki.hcoop.net/MemberManual/ServingWebsites/DomTool#">DomTool</ulink> configurations are stored in <code>~/.domtool/</code>.  Some users have made their production configurations readable and so you may be able to learn from them.  See the bottom of <ulink url="https://wiki.hcoop.net/MemberManual/ServingWebsites/DomTool/Examples#">DomTool examples</ulink> to find out who is showing off their <ulink url="https://wiki.hcoop.net/MemberManual/ServingWebsites/DomTool#">DomTool</ulink> configurations. </para><para>If your web application needs write access to a data directory, give USER.daemon write permission to it and all of its subdirectories.  In this example, be sure to replace <emphasis role="strong">USER</emphasis> with your username (lowercase): </para><screen><![CDATA[fsr sa ./webdata USER.daemon write]]></screen><para>Alternatively, use only <code>fs</code> if you need to set the ACL for just one directory. </para><para>For database help, take a look at this manual's <ulink url="https://wiki.hcoop.net/MemberManual/ServingWebsites/MemberManual/Databases#">Databases</ulink> chapter. </para><para>To see how you can transfer files to HCoop, see the <ulink url="https://wiki.hcoop.net/MemberManual/ServingWebsites/MemberManual/TransferringFiles#">Transferring Files</ulink> chapter. </para><para>In addition, .htaccess files are not processed on our servers.  See <ulink url="https://wiki.hcoop.net/MemberManual/ServingWebsites/DomTool/Examples#">DomTool Examples</ulink> to learn how to use rewrite rules and other features normally provided by .htaccess. </para><section><title>PHP</title><para>We use FastCGI based PHP 7.2 by default to serve <code>.php</code>, <code>.phtml</code>, and <code>.php5</code> files. We may offer PHP variants (supported variants are documented in the <ulink url="https://hcoop.net/domtool/apache.html#T_php_version">Domtool library reference</ulink>); to explicitly set the PHP version, use the <code>phpVersion</code> action as follows. </para><para>To use PHP 5 in a directory or virtual host: </para><screen><![CDATA[phpVersion php56;]]></screen></section><section><title>Common Web Applications</title><para>It is likely that another member has configured one of many common applications and documented it on the <ulink url="https://wiki.hcoop.net/MemberManual/ServingWebsites/MemberManual/WebApplications#">../WebApplications</ulink> page. </para></section></section><section><title>Running your own web server</title><para>Many popular Apache modules for &quot;fast web serving,&quot; like mod_python and mod_perl, are incompatible with our security requirements; they force all Python, Perl, etc., scripts run through them to run as a single UNIX user.  Thus, to use these modules, you will need to run your own separate web server.  See <ulink url="https://wiki.hcoop.net/MemberManual/ServingWebsites/RunningYourOwnApache#">RunningYourOwnApache</ulink>. You will probably want to run lighttpd instead of your own Apache, since configuring it is much simpler. </para><para>It also couldn't hurt to petition the authors of these modules to fix this problem. <inlinemediaobject><imageobject><imagedata depth="16" fileref="https://wiki.hcoop.net/moin_static1911/moniker_bt/img/smile4.png" width="16"/></imageobject><textobject><phrase>;-)</phrase></textobject></inlinemediaobject> </para></section><section><title>Examining your logs</title><para>The error and access logs are stored in <code>~/.logs/apache</code>.  They are separated by machine and domain.  Your <code>~/.logs/apache</code> directory is updated once every 20 minutes from the &quot;real&quot; logs in <code>/var/log/apache2</code> on the machine that serves your virtual host.  This is almost certainly <code>navajos</code>. </para><para>It is <emphasis>expected</emphasis> that you don't have permission to read your logs in <code>/var/log/apache2</code>.  Instead, use the handy <code>domtool-tail</code> program to view the logs in realtime.  For instance, this command line will dump the last entries in the access log for www.domain.com, in the style of the UNIX <code>tail</code> program.  We assume that you have Domtool permissions on domain.com. </para><screen><![CDATA[domtool-tail [-n LINES] www.domain.com access]]></screen><para>The optional <code>-n LINES</code> argument will fetch that many lines from the log. </para><para>You can view a graphical representation of your access logs by browsing our webalizer interface at <ulink url="https://members.hcoop.net/webalizer/"/>.  Its statistics are updated once per day. </para></section><section><title>Permissions Issues (403 Access Denied)</title><para>When you publish web content, it will probably live in your home directory.  The web server will need permission to read your files, or it will return &quot;403 Access Denied&quot; errors.  Since your home directory is in AFS, <emphasis role="strong">normal UNIX permissions are irrelevant</emphasis>. </para><para>For instance, if you get a 403 error serving <code>~/public_html/otherdir/page.html</code>, you might run this to see what's up: </para><screen><![CDATA[$ fs listacl ~/public_html/otherdir
Access list for /afs/hcoop.net/user/y/yo/you/public_html/otherdir is
Normal rights:
  system:administrators rlidwka
  system:anyuser l
  you rlidwka]]></screen><para>Oops!  Apache only matches the &quot;system:anyuser&quot; principal, so it only gets the &quot;l&quot; (= &quot;list&quot;) permission and can only list your directory contents.  Try this to fix it: </para><screen><![CDATA[$ fs setacl ~/public_html/otherdir system:anyuser read
$ fs setacl ~/public_html system:anyuser read
$ fs setacl ~ system:anyuser l]]></screen><para>The first two give full read permission on the mentioned directories. &quot;l&quot; permission is needed in every parent directory of a file to be able to access it, so the last line makes sure &quot;l&quot; is granted to system:anyuser on your home directory. </para><para>When your web content is accessed through your own virtual host, you can also grant read access to <code>$USER.daemon</code> instead of the broader <code>system:anyuser</code>, where <code>$USER</code> is your username. This is your bizarro-world twin, which Apache runs as when serving your content. </para><para>Note that your CGI directories and executables should be in the group <code>nogroup</code>; if this is not the case you may see cryptic warnings in your <code>error.log</code> along the lines of <code>suexec policy violation: see suexec log for more details</code>. </para><para>See <ulink url="https://wiki.hcoop.net/MemberManual/ServingWebsites/MemberManual/GettingStarted#">the Getting Started chapter</ulink> of the Member Manual, in particular the <emphasis>AFS</emphasis> section, for information on how to work with AFS's <emphasis role="strong">separate</emphasis> notion of permissions. </para></section><section><title>Permissions Issues (500 Server Error for CGIs)</title><para>If you get a 500 server error when running a CGI script, one likely cause is directory permissions. <code>suexec</code> will refuse to run a cgi if its parent directory is writeable by others.  So, make sure permissions are set to 755 and not 775.  Note that the directory permissions do not actually affect anything (since we're using <ulink url="https://wiki.hcoop.net/MemberManual/ServingWebsites/AndrewFileSystem#">AndrewFileSystem</ulink>), but modifying the suexec code to skip the checks is considered too risky. </para></section><section><title>Getting HTTPS access working</title><para>In order to serve websites over HTTPS, you will need to generate an SSL certificate and optionally request an IP address from us. </para><orderedlist numeration="arabic"><listitem><para><ulink url="https://wiki.hcoop.net/MemberManual/ServingWebsites/MemberManual/ServingWebsites/SslCert#">Generate a Key and Certificate Signing Request</ulink>, and then either generate a self-signed SSL certificate yourself, buy one from somewhere (search for &quot;ssl certificate&quot; using your search engine of choice for a list of popular vendors), or request a certificate from letsencrypt. </para></listitem><listitem><para><ulink url="https://members.hcoop.net/portal/cert">Request permission to use your certificate for a domain</ulink>. </para></listitem><listitem><para>Add a stanza to your <ulink url="https://wiki.hcoop.net/MemberManual/ServingWebsites/DomTool#">DomTool</ulink> configuration file.  Examples of this may be found at <ulink url="https://wiki.hcoop.net/MemberManual/ServingWebsites/DomTool/Examples#">DomTool/Examples</ulink>. </para></listitem></orderedlist><para>This relies on <ulink url="http://en.wikipedia.org/wiki/Server_Name_Indication">TLS SNI</ulink> to work, which will work in almost all cases (the only notable software no longer supporting SNI is Java 6, which is deprecated). If for any reason you need a dedicated IP address,  we are <ulink url="https://members.hcoop.net/portal/ip">happy to provide you with one</ulink> as long as our upstream providers will provide them. </para></section><section><title>WebDAV</title><para>WebDAV is a set of extensions to the HTTP protocol which allows users to collaboratively edit and manage files on remote web servers.  WebDAV is useful when working on a website using systems that cannot mount an AFS share. General information of WebDAV can be found at<ulink url="http://research.cs.berkeley.edu/doc/dav/"/>. </para><para>If you want to be able to use DAV services with your own domain name, you will need to set up a host which is served via HTTPS.  The <emphasis>Getting HTTPS access working</emphasis> section above should be of help.  Then, you will want to add a stanza to your <ulink url="https://wiki.hcoop.net/MemberManual/ServingWebsites/DomTool#">DomTool</ulink> configuration to serve DAV.  An example follows. </para><screen><![CDATA[  (* Redirect HTTP to HTTPS *)
  web "dav" with
    rewriteRule "^(.*)$" "https://dav.yourdomain$1" [redirect];
  end;
]]><![CDATA[
  (* Serving DAV over HTTPS *)
  web "dav" where
    DocumentRoot = home "dav";
    SSL = use_cert "/etc/apache2/ssl/user/yourdomain.pem";
  with
    addDefaultCharset "utf-8";
]]><![CDATA[
    location "/" with
      davFilesystem;
    end;
  end;]]></screen><para>You will almost certainly want to require authorization to access your <code>davFilesystem</code>, since it runs with your <code>$USER.daemon</code> tokens, and can therefore read and write anything it can. </para><!--rule (<hr>) is not applicable to DocBook--><para> <ulink url="https://wiki.hcoop.net/MemberManual/ServingWebsites/CategoryMemberManual#">CategoryMemberManual</ulink> </para></section></article>