MythWeb via MacPorts

From MythTV Official Wiki
Revision as of 15:37, 25 May 2014 by Pvr4me (talk | contribs) (Extra steps when using installer)

Jump to: navigation, search
Running a web server may open your computer up to hacking attempts, particularly if you allow access through your firewall. Instructions for securing MythWeb are available elsewhere in this wiki and you should take appropriate steps before enabling access via the Internet.

This page assumes that you have used the pre-built installer to install a complete Myth system on an OS X machine and now want to serve MythWeb from the same machine. Other configurations are possible but are left as an exercise for the reader! See Building MythWeb yourself if you are not using the pre-built installer.


Everything required to run MythWeb is installed by the pre-built installer and the necessary configuration and set-up steps are detailed in the following sections.

Ensure copies exist of required files

Enter each one of the following lines in turn in (These commands are not required if you built MythWeb with MacPorts.) Any errors will report a message; successful completion just returns the command prompt.

sudo cp -np /opt/dvr/apache2/htdocs/index.html.sample /opt/dvr/apache2/htdocs/index.html
sudo cp -np /opt/dvr/apache2/bin/envvars-std /opt/dvr/apache2/bin/envvars
sudo cp -np /opt/dvr/apache2/conf/original/httpd.conf /opt/dvr/apache2/conf/httpd.conf
sudo cp -np /opt/dvr/apache2/conf/original/extra/* /opt/dvr/apache2/conf/extra/

Configure Apache and PHP

Based on:

You must enter a series of commands in Terminal and modify a couple of configuration files with a text editor (such as TextEdit or TextWrangler).

Register PHP with Apache

In Terminal, enter:

cd /opt/dvr/apache2/modules
sudo /opt/dvr/apache2/bin/apxs -a -e -n "php5"

Edit Apache's httpd.conf

You will probably need to change the permissions on the http.conf file in order to edit the file:

sudo chmod 666 /opt/dvr/apache2/conf/httpd.conf

Using a text editor, update /opt/dvr/apache2/conf/httpd.conf file to extend the "DirectoryIndex" directive to include additional "index" files. Search for:

DirectoryIndex index.html

and change it this way:

DirectoryIndex index.php index.html

Also, at the end of the httpd.conf file, add the following lines so that Apache includes the mod_php "AddType" configurations and MythWeb's configuration file:

# Include PHP configurations
Include conf/extra/mod_php.conf
# MythWeb config
Include htdocs/MythWeb/mythweb.conf

If you have a lower-end machine running Apache/PHP/MythWeb, you may find that the default settings use memory pretty aggressively. Since we're only likely to be accessing MythWeb from a small number of computers--and seldom simultaneously--I found adding the following configuration values to httpd.conf helpful:

# MythWeb optional - Ease Apache memory demands 
StartServers 1
MinSpareServers 1
MaxSpareServers 4
MaxClients 7
MaxRequestsPerChild 300

based on

Save your changes and close the https.conf file.

Modify PHP configuration

In Terminal, enter:

cd /opt/dvr/etc/php5
sudo cp php.ini-development php.ini

Setup the MySQL default socket to use the MacPorts configuration (/opt/dvr/var/run/mysql5/mysqld.sock)

$ sudo -i
# cd /opt/dvr/etc/php5
# cp php.ini php.ini.bak
# defSock=`/opt/dvr/bin/mysql_config5 --socket`
# cat php.ini | sed \
  -e "s#pdo_mysql\.default_socket.*#pdo_mysql\.default_socket=${defSock}#" \
  -e "s#mysql\.default_socket.*#mysql\.default_socket=${defSock}#" \
  -e "s#mysqli\.default_socket.*#mysqli\.default_socket=${defSock}#" > tmp.ini
# grep default_socket tmp.ini  # Check it!
# mv tmp.ini php.ini
# exit # OR rm php.ini.bak && exit

Restart Apache so that your changes take effect

sudo port unload apache2; sudo port load apache2

Configure MythWeb

MythWeb works 'out of the box'. To do: determine if any more configuration is necessary or desirable.

Accessing MythWeb

http://localhost/MythWeb or http://web.server.ip/MythWeb

Building MythWeb and supporting software yourself

If you have built your own MythTV software using MacPorts, you can also build and install MythWeb. You will also have to complete the configuration and set-up steps above. Note that the pre-built software is installed under '/opt/dvr' while your version will be under '/opt/local'. Adapt all the instructions above by replace '/opt/dvr' with '/opt/local'.

Choose the version of MythWeb that matches your installed version of Myth. Use Terminal to run the following commands:

At the Terminal prompt, you enter What happens
sudo port install mythweb.27
sudo port install mythweb.26
sudo port install mythweb.25
Download, build and install the MythWeb and supporting software. The first time, it may require several minutes to download, build and install the MacPorts versions of Apache2 and PHP5.


404 Not Found

Check, under the /var/log section for an apache2 error log. If you see lines like "File does not exist: /Library/WebServer/Documents/MythWeb", the Apache software built into OS X is intercepting the web request and isn't configured to handle it. Be sure that MacPorts Apache2 is the only one running; not the version built into OS X. Prior to Mountain Lion, go into the System Preferences>Sharing and ensure Web Sharing is not clicked. For Mountain Lion (OS X 10.8.x), search the web for instructions on enabling/disabling web sharing.