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

From MythTV Official Wiki
Jump to: navigation, search
(0.23 not working)
(link to MacPorts option)
(19 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{Warning}} Broken and incompatible protocol treatment prevents MythWeb 0.23-fixes from working with OSX builds as of Sep 4, 2010.  Please check this page for updates.
+
= Introduction =
 
 
  
 
Because Macs all come with a built-in [http://httpd.apache.org/ webserver], it is fairly easy to have [[MythWeb]] served from your Mac.  However, there are a few changes needed to the default configuration.  If you are interested in watching and recording TV using OSX, please see [[MythTV_on_Mac_OS_X]].
 
Because Macs all come with a built-in [http://httpd.apache.org/ webserver], it is fairly easy to have [[MythWeb]] served from your Mac.  However, there are a few changes needed to the default configuration.  If you are interested in watching and recording TV using OSX, please see [[MythTV_on_Mac_OS_X]].
Line 8: Line 7:
 
{{Warning}} Running a webserver opens your computer up to hacking attempts, particularly if you allow port-forwarding access through your firewall.
 
{{Warning}} Running a webserver opens your computer up to hacking attempts, particularly if you allow port-forwarding access through your firewall.
  
 +
 +
{{Warning}} MythWeb backend does not yet work in version 0.25 due to bug number {{Ticket|10600}}.  A patch is available to try on the linked ticket page.
 +
 +
 +
Note that it is also possible to install [[MythWeb via MacPorts]] (version 0.25, 0.26 or 0.27), whether or not you've installed [[MacPorts|Myth backend that way]] or not.
  
 
= Get a Copy of MythWeb =
 
= Get a Copy of MythWeb =
  
You will need a copy of the website files in the proper directory.  To get it, open '''Terminal''' and use the command-line program [http://subversion.tigris.org/svn svn] (which should already be present on your Mac, in <code>/usr/bin/svn</code>) like this:
+
You will need a copy of the website files in the proper directory.  To get it, open '''Terminal''' and use the command-line program [http://git-scm.com/download git] (which you will need to have installed on your Mac) like this:
  
 
  ''shell> ''cd /Library/WebServer
 
  ''shell> ''cd /Library/WebServer
  ''shell> ''svn co <nowiki>http://svn.mythtv.org/svn/branches/release-0-23-fixes/mythplugins/mythweb</nowiki> MythWeb
+
  ''shell> ''git clone -b fixes/0.25 <nowiki>https://github.com/MythTV/mythweb.git</nowiki> MythWeb
 
Here, the <code>''shell> ''</code> characters indicate the shell prompt, not something you need to type.
 
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 from the latest fixes to 0.25 in <code>/Library/WebServer/MythWeb</code>.
  
 
= Modify Webserver Configuration =
 
= Modify Webserver Configuration =
Line 23: Line 27:
 
== Work on a Copy ==
 
== 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 (along with the general configuration file) in '''TextEdit'''
+
Now you need to change the configuration of the webserver so that the website works.  Begin by copying the Linux version of the MythWeb configuration file and opening it (along with the general apache configuration file) in '''TextEdit'''
 +
 
 +
For OS X Server Lion all of the "/Library/WebServer/MythWeb" should be replaced with "/Library/Server/Web/Data/Sites/Default/MythWeb".
  
 
  ''shell> ''cd /Library/WebServer/MythWeb
 
  ''shell> ''cd /Library/WebServer/MythWeb
Line 30: Line 36:
 
  ''shell> ''open -a TextEdit mythweb.conf httpd.conf
 
  ''shell> ''open -a TextEdit mythweb.conf httpd.conf
  
===  Edit mythweb.conf ===
+
===  Editing mythweb.conf ===
  
 
First, make some changes to <code>mythweb.conf</code>
 
First, make some changes to <code>mythweb.conf</code>
Line 139: Line 145:
 
         Header append Vary User-Agent env=!dont-vary
 
         Header append Vary User-Agent env=!dont-vary
  
=== Edit httpd.conf ===
+
=== Editing httpd.conf ===
  
 
Now we just have to make a couple of changes to the main webserver configuration file <code>httpd.conf</code>.
 
Now we just have to make a couple of changes to the main webserver configuration file <code>httpd.conf</code>.
Line 155: Line 161:
 
and comment it out to read
 
and comment it out to read
 
  #Include /private/etc/apache2/extra/httpd-userdir.conf
 
  #Include /private/etc/apache2/extra/httpd-userdir.conf
 +
 +
==== OS X Server Lion ====
 +
 +
Find the line that says
 +
 +
    <IfDefine WEBSERVICE_ON>
 +
        Include /etc/apache2/sites/*.conf
 +
    </IfDefine>
 +
 +
And change it to
 +
 +
    <IfDefine WEBSERVICE_ON>
 +
        Include /etc/apache2/sites/*.conf
 +
        Include /etc/apache2/other/*.conf
 +
    </IfDefine>
 +
 +
  
 
=== Save ===
 
=== Save ===
Line 165: Line 188:
 
Create the password file for accessing your webserver by using the line
 
Create the password file for accessing your webserver by using the line
 
  ''shell> ''sudo htdigest  -c  /etc/apache2/other/mythweb-htdigest MythTV ''username''
 
  ''shell> ''sudo htdigest  -c  /etc/apache2/other/mythweb-htdigest MythTV ''username''
where you should replace ''username'' with your own choice.  You will be prompted for a password.  This username and password are the ones you will need to use the MythWeb site.
+
where you should replace ''username'' with your own choice.  You will be prompted for a password.  This username and password are the ones you will need to use the MythWeb site from remote computers, so they should not be considered particularly secure.
  
 
=== Set Up Config Files ===
 
=== Set Up Config Files ===
Line 185: Line 208:
 
= Fix MySQL Socket =
 
= Fix MySQL Socket =
  
If your database server is <code>localhost</code> you will need to [http://www.verysimple.com/blog/2009/01/07/php-on-os-cant-connect-to-local-mysql-server-through-socket-varmysqlmysqlsock/ tell PHP] how it can find a socket to communicate with MySQL.
+
If your database server is <code>localhost</code> you will need to [http://www.verysimple.com/blog/2009/01/07/php-on-os-cant-connect-to-local-mysql-server-through-socket-varmysqlmysqlsock/ tell PHP] how it can find a socket to communicate with MySQL. The way to do this depends on which version of OSX you are using:
  
 
====Leopard====
 
====Leopard====
Line 214: Line 237:
 
to read
 
to read
 
  date.timezone = America/Chicago
 
  date.timezone = America/Chicago
or the equivalent for your location.
+
or the [http://php.net/manual/en/timezones.php equivalent timezone] for your location.
 +
 
 +
 
 +
====LION====
 +
Begin by copying <code>/etc/php.ini.default</code> to <code>/etc/php.ini</code>.
 +
''shell> ''sudo cp -p  /etc/php.ini.default /etc/php.ini
 +
 
 +
Now edit the file <code>/etc/php.ini</code>.  Edit the part that says
 +
; date.timezone =
 +
to read
 +
date.timezone = America/Chicago
 +
or the [http://php.net/manual/en/timezones.php equivalent timezone] for your location.
 +
 
  
 
You will need to be an admin to edit this file.  If you are comfortable with the text-based editor <code>nano</code>, it is convenient to edit the file with the line
 
You will need to be an admin to edit this file.  If you are comfortable with the text-based editor <code>nano</code>, it is convenient to edit the file with the line
Line 221: Line 256:
 
= (Optional) Perl Upgrades =
 
= (Optional) Perl Upgrades =
  
To get streaming video working, you must install the Perl module for communicating with MySQL.  This requires having XCode installed so that a C compiler is available for the install.
+
To get streaming video working, you must install the Perl module for communicating with MySQL.  This requires having the [http://developer.apple.com XCode] development environment installed so that a C compiler is available to the Perl module installer.   After installing XCode, your next steps depend on which version of OSX you are using:
  
  
Line 234: Line 269:
 
==== Snow Leopard ====
 
==== Snow Leopard ====
  
The default 64-bit Perl installation cannot automatically install DBD::mysql (as of 2010-09-05).  Instead, it is easiest to [http://www.monkinetic.com/2010/05/perl-dbdmysql-and-mysql-can-play-nice-on-os-x-106.html switch the default version to 32-bit].  This involves the following commands
+
The default 64-bit Perl installation cannot automatically install DBD::mysql (as of OSX version 10.6.4, 2010-09-05).  Instead, it is easiest to [http://www.monkinetic.com/2010/05/perl-dbdmysql-and-mysql-can-play-nice-on-os-x-106.html switch the default version to 32-bit].  This involves the following commands
 
  ''shell> ''sudo su
 
  ''shell> ''sudo su
 
  ''shell# ''export VERSIONER_PERL_PREFER_32_BIT=yes
 
  ''shell# ''export VERSIONER_PERL_PREFER_32_BIT=yes
Line 252: Line 287:
 
= Start The Webserver =
 
= 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.
+
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.  MythWeb's url is "<nowiki>http://<ip.address>/MythWeb/" (example: http://192.168.2.222/MythWeb/)</nowiki>. Note that capitalization on "MythWeb" is important.
  
 
= Troubleshooting =
 
= Troubleshooting =
  
You can examine the error messages from the webserver using '''Console'''.  The most interesting is <code>/var/log/apache2/error_log</code>.  Since the MythWeb website uses PHP, you are looking for the startup message here to say that PHP is working.  It should look something like this
+
You can examine the error messages from the webserver using '''Console.app'''.  The most interesting is <code>/var/log/apache2/error_log</code>.  Since the MythWeb website uses PHP, you are looking for the startup message here to say that PHP is working.  It should look something like this
  Apache/2.2.13 (Unix) mod_ssl/2.2.13 OpenSSL/0.9.7l DAV/2 PHP/5.2.11 configured -- resuming normal operations
+
  Apache/2.2.14 (Unix) mod_ssl/2.2.14 OpenSSL/0.9.8l DAV/2 PHP/5.3.1 configured -- resuming normal operations
  
  
Command-line jockeys may enjoy causing the webserver to reload new configurations with the following set of pipes
+
Command-line jockeys may enjoy causing the webserver to reload new configurations with the following command
  ''shell> ''ps auxww | grep httpd | grep root | awk -F' '  '{print $2}'|xargs sudo kill -HUP
+
  ''shell> ''sudo apachectl graceful
  
 
= For more information =
 
= For more information =
Line 277: Line 312:
  
 
==== Install guide ====
 
==== Install guide ====
* The [http://svn.mythtv.org/trac/browser/branches/release-0-22-fixes/mythplugins/mythweb/INSTALL INSTALL] file distributed with the source code has a considerable amount of Linux-oriented setup information.
+
* The [https://github.com/MythTV/mythweb/blob/fixes/0.24/INSTALL INSTALL] file distributed with the source code has a considerable amount of Linux-oriented setup information.
  
  
Line 283: Line 318:
 
[[Category:Distribution_Specific_Install_Guides]]
 
[[Category:Distribution_Specific_Install_Guides]]
 
[[Category:MacOS]]
 
[[Category:MacOS]]
 +
[[Category:MythWeb]]

Revision as of 16:06, 29 January 2014

Introduction

Because Macs all come with a built-in webserver, it is fairly easy to have MythWeb served from your Mac. However, there are a few changes needed to the default configuration. If you are interested in watching and recording TV using OSX, please see MythTV_on_Mac_OS_X.

If you are interested in browsing an existing MythWeb server using OSX, please see MythWeb_client_on_Mac_OS_X.

Warning.png
Running a webserver opens your computer up to hacking attempts, particularly if you allow port-forwarding access through your firewall.


Warning.png
MythWeb backend does not yet work in version 0.25 due to bug number #10600. A patch is available to try on the linked ticket page.


Note that it is also possible to install MythWeb via MacPorts (version 0.25, 0.26 or 0.27), whether or not you've installed Myth backend that way or not.

Get a Copy of MythWeb

You will need a copy of the website files in the proper directory. To get it, open Terminal and use the command-line program git (which you will need to have installed on your Mac) like this:

shell> cd /Library/WebServer
shell> git clone -b fixes/0.25 https://github.com/MythTV/mythweb.git 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 from the latest fixes to 0.25 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 version of the MythWeb configuration file and opening it (along with the general apache configuration file) in TextEdit

For OS X Server Lion all of the "/Library/WebServer/MythWeb" should be replaced with "/Library/Server/Web/Data/Sites/Default/MythWeb".

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

Editing mythweb.conf

First, make some changes to mythweb.conf

URL Alias

Insert a line at the top that says

Alias /MythWeb /Library/WebServer/MythWeb

You may find it convenient to have a couple more aliases, such as

Alias /MythTV /Library/WebServer/MythWeb
Alias /Myth /Library/WebServer/MythWeb


Streaming Authentication

Find the lines near the top that look like

#   <LocationMatch .*/pl/stream/[0-9]+/[0-9]+>
#       Allow from all
#   </LocationMatch>
#
#   <LocationMatch .*/music/stream.php>
#       Allow from all
#   </LocationMatch>

and uncomment (remove the leading octothorpes from) them. So they should now read

   <LocationMatch .*/pl/stream/[0-9]+/[0-9]+>
       Allow from all
   </LocationMatch>
#
   <LocationMatch .*/music/stream.php>
       Allow from all
   </LocationMatch>

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 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
Warning.png
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 username and password.

You may have to change the location of the database server from localhost to mydvrmac.local or some equivalent if you do not want to fix your MySQL socket (see below). The error message for bad database information is not working as of mythtv 22-fixes-20091115.

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

Then uncomment the line that reads

   #    Header append Vary User-Agent env=!dont-vary

so that it now reads

       Header append Vary User-Agent env=!dont-vary

Editing 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

and uncomment it to read

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

OS X Server Lion

Find the line that says

   <IfDefine WEBSERVICE_ON>
       Include /etc/apache2/sites/*.conf
   </IfDefine>

And change it to

   <IfDefine WEBSERVICE_ON>
       Include /etc/apache2/sites/*.conf
       Include /etc/apache2/other/*.conf
   </IfDefine>


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> sudo htdigest  -c  /etc/apache2/other/mythweb-htdigest MythTV username

where you should replace username with your own choice. You will be prompted for a password. This username and password are the ones you will need to use the MythWeb site from remote computers, so they should not be considered particularly secure.

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

Change Data Directory Owner

As a security practice, the webserver runs as the user www rather than as an administrator. Change the ownership of the MythWeb files like this

shell> sudo chown -R root:admin /Library/WebServer/MythWeb
shell> sudo chown -R www:www /Library/WebServer/MythWeb/data

where the first line is optional, but the second is required (it allows the webserver some scratch space on the hard drive).

Fix MySQL Socket

If your database server is localhost you will need to tell PHP how it can find a socket to communicate with MySQL. The way to do this depends on which version of OSX you are using:

Leopard

To do this, you must edit the file /etc/php.ini. Find the lines that look like this

; Default socket name for local MySQL connects.  If empty, uses the built-in 
mysql.default_socket = 

and add the location where the MySQL installer really puts the socket

; Default socket name for local MySQL connects.  If empty, uses the built-in 
mysql.default_socket = /tmp/mysql.sock

You will need to be an admin to edit this file. If you are comfortable with the text-based editor nano, it is convenient to edit the file with the line

shell> sudo nano /etc/php.ini


Snow Leopard

Begin by copying /etc/php.ini.default to /etc/php.ini.

shell> sudo cp -p  /etc/php.ini.default /etc/php.ini

Now edit the file /etc/php.ini. Find the lines that look like this

; Default socket name for local MySQL connects.  If empty, uses the built-in 
mysql.default_socket = 

and add the location where the MySQL installer really puts the socket

; Default socket name for local MySQL connects.  If empty, uses the built-in 
mysql.default_socket = /tmp/mysql.sock

Also, locate the timezone specification so that we can fix it. Edit the part that says

; date.timezone =

to read

date.timezone = America/Chicago

or the equivalent timezone for your location.


LION

Begin by copying /etc/php.ini.default to /etc/php.ini.

shell> sudo cp -p  /etc/php.ini.default /etc/php.ini

Now edit the file /etc/php.ini. Edit the part that says

; date.timezone =

to read

date.timezone = America/Chicago

or the equivalent timezone for your location.


You will need to be an admin to edit this file. If you are comfortable with the text-based editor nano, it is convenient to edit the file with the line

shell> sudo nano /etc/php.ini

(Optional) Perl Upgrades

To get streaming video working, you must install the Perl module for communicating with MySQL. This requires having the XCode development environment installed so that a C compiler is available to the Perl module installer. After installing XCode, your next steps depend on which version of OSX you are using:


Leopard

shell> sudo perl -MCPAN -e 'install DBD::mysql'

It's fine if you allow it to automatically configure

Are you ready for manual configuration? [yes] no


Snow Leopard

The default 64-bit Perl installation cannot automatically install DBD::mysql (as of OSX version 10.6.4, 2010-09-05). Instead, it is easiest to switch the default version to 32-bit. This involves the following commands

shell> sudo su
shell# export VERSIONER_PERL_PREFER_32_BIT=yes
shell# defaults write com.apple.versioner.perl Prefer-32-Bit -bool yes
shell# defaults write /Library/Preferences/com.apple.versioner.perl Version 5.8.9

Automatic installation may now work with

shell> sudo perl -MCPAN -e 'install DBD::mysql'

Otherwise, you can download the package from CPAN, unpack it, and then build and install using

shell> perl Makefile.PL --mysql_config=/usr/local/mysql/bin/mysql_config
shell> make
shell> sudo make install

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. MythWeb's url is "http://<ip.address>/MythWeb/" (example: http://192.168.2.222/MythWeb/). Note that capitalization on "MythWeb" is important.

Troubleshooting

You can examine the error messages from the webserver using Console.app. The most interesting is /var/log/apache2/error_log. Since the MythWeb website uses PHP, you are looking for the startup message here to say that PHP is working. It should look something like this

Apache/2.2.14 (Unix) mod_ssl/2.2.14 OpenSSL/0.9.8l DAV/2 PHP/5.3.1 configured -- resuming normal operations


Command-line jockeys may enjoy causing the webserver to reload new configurations with the following command

shell> sudo apachectl graceful

For more information

Mailing Lists

If you have problems with this guide, the mythtv-users mailing list is the best place to start. Check the searchable archive to see if your problem has already been discussed. Also, you can check the mythtv-dev list to see if it's a problem with SVN.

External Links

Wiki


Install guide

  • The INSTALL file distributed with the source code has a considerable amount of Linux-oriented setup information.