Difference between revisions of "MythWeb on Mac OS X Backend"

From MythTV Official Wiki
Jump to: navigation, search
(Initial version)
 
(Getting a Copy of MythWeb)
Line 7: Line 7:
 
  ''shell> ''cd /Library/WebServer
 
  ''shell> ''cd /Library/WebServer
 
  ''shell> ''svn co <nowiki>http://svn.mythtv.org/svn/branches/release-0-22-fixes/mythplugins/mythweb</nowiki> MythWeb
 
  ''shell> ''svn co <nowiki>http://svn.mythtv.org/svn/branches/release-0-22-fixes/mythplugins/mythweb</nowiki> MythWeb
 +
Here, the <code>''shell> ''</code> characters indicate the shell prompt, not something you need to type.
  
 
This will put a copy of the latest website code in <code>/Library/WebServer/MythWeb</code>.
 
This will put a copy of the latest website code in <code>/Library/WebServer/MythWeb</code>.
 
  
 
= Modify Webserver Configuration =
 
= Modify Webserver Configuration =

Revision as of 16:54, 22 November 2009

Because Macs all come with a built-in webserver, it is fairly easy to have MythWeb served from your Mac. However, it is a good idea to keep your setup Mac-like, which involves certain changes to the recommended directory structure.

Getting a Copy of MythWeb

You will need a copy of the website files in the proper directory. To get it, use the command-line program svn (which should already be present on your Mac, in /usr/bin/svn) like this:

shell> cd /Library/WebServer
shell> svn co http://svn.mythtv.org/svn/branches/release-0-22-fixes/mythplugins/mythweb MythWeb

Here, the shell> characters indicate the shell prompt, not something you need to type.

This will put a copy of the latest website code in /Library/WebServer/MythWeb.

Modify Webserver Configuration

Work on a Copy

Now you need to change the configuration of the webserver so that the website works. Begin by copying the Linux configuration file and opening it

shell> cd /Library/WebServer/MythWeb
shell> cp mythweb.conf.apache mythweb.conf
shell> cp /etc/apache2/httpd.conf ./
shell> open -a TextEdit mythweb.conf httpd.conf

mythweb.conf

First, make some changes to mythweb.conf

Directory Locations

Find the line that says

    <Directory "/var/www/html/data">

and change it to

    <Directory /Library/WebServer/MythWeb/data>

where it is important to remove the quotes.


A couple lines below that, find the line that says

   <Directory "/var/www/html" >

and change it to

    <Directory /Library/WebServer/MythWeb>

Again, it is important to remove the quotes.


Authentication and Security

In the Authentication section below that, uncomment (remove the leading octothorpes from) the setup lines. So the section that formerly read like this

   #    AuthType           Digest
   #    AuthName           "MythTV"
   #    AuthUserFile       /var/www/htdigest
   #    Require            valid-user
   #    BrowserMatch       "MSIE"      AuthDigestEnableQueryStringHack=On
   #    Order              allow,deny
   #    Satisfy            any

should now read like this

       AuthType           Digest
       AuthName           "MythTV"
       AuthUserFile       /etc/apache2/other/mythweb-htdigest
       Require            valid-user
       BrowserMatch       "MSIE"      AuthDigestEnableQueryStringHack=On
       Order              allow,deny
       Satisfy            any

Note the change in location of the AuthUserFile.

Backend Details

Make sure the backend details, which currently look like this

           setenv db_server        "localhost"
           setenv db_name          "mythconverg"
           setenv db_login         "mythtv"
           setenv db_password      "mythtv"

have your correct database information, in particular the password.

URL Rewrite

Find the line that says

   #    RewriteBase    /mythweb

uncomment and change the capitalization so that it now reads

       RewriteBase    /MythWeb

Compression and Deflation

Find the section that looks like this

   #    BrowserMatch ^Mozilla/4 gzip-only-text/html
   #    BrowserMatch ^Mozilla/4\.0[678] no-gzip
   #    BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
   #
   #    AddOutputFilterByType DEFLATE text/html
   #    AddOutputFilterByType DEFLATE text/css
   #    AddOutputFilterByType DEFLATE application/x-javascript

and uncomment it to read like this

       BrowserMatch ^Mozilla/4 gzip-only-text/html
       BrowserMatch ^Mozilla/4\.0[678] no-gzip
       BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
       AddOutputFilterByType DEFLATE text/html
       AddOutputFilterByType DEFLATE text/css
       AddOutputFilterByType DEFLATE application/x-javascript


httpd.conf

Now we just have to make a couple of changes to the main webserver configuration file httpd.conf.

Enable PHP

Find the line that says

#LoadModule php5_module        libexec/apache2/libphp5.so


Additional Security

If you don't plan to use this Mac webserver for other purposes, you may wish to disable some security risks such as the user directory module. To do so, find the line

Include /private/etc/apache2/extra/httpd-userdir.conf

and comment it out to read

#Include /private/etc/apache2/extra/httpd-userdir.conf


Save

Save these files and quit TextEdit.


Finish Webserver Configuration

Create Password File

Create the password file for accessing your webserver by using the line

shell> htpasswd -nb username password > /Library/WebServer/MythWeb/mythweb-htdigest

where you should replace username and password with your own choices.

Set Up Config Files

Now you need to put these configuration files where the webserver can read them.

shell> sudo cp /etc/apache2/httpd.conf /etc/apache2/httpd.conf.pre-mythweb
shell> cd /Library/WebServer/MythWeb
shell> sudo cp mythweb.conf /etc/apache2/other/mythweb.conf
shell> sudo cp httpd.conf /etc/apache2/httpd.conf
shell> sudo cp mythweb-htdigest /etc/apache2/other/mythweb-htdigest

Start The Webserver

To start the webserver, go to System Preferences and open the Sharing pane. Click the checkbox next to Web Sharing. If it was already on, then click it off and on again, so as to restart the webserver with your new configuration.