MythWeb via MacPorts

From MythTV Official Wiki
Revision as of 02:16, 11 November 2013 by Pvr4me (Talk | contribs)

Jump to: navigation, search
Warning.png
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 MacPorts to install the Myth backend and database 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!


Installation

MythWeb is now available for installation via MacPorts. If you haven't done so already, you must have Apple's XCode and the MacPorts application installed. See the MacPorts web site for instructions.

Install MythWeb and supporting software

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
or
sudo port install mythweb.26
or
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.

Configure Apache and PHP

Based on: https://trac.macports.org/wiki/howto/MAMP

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/local/apache2/modules
sudo /opt/local/apache2/bin/apxs -a -e -n "php5" libphp5.so

Edit Apache's http.conf

Using a text editor, update /opt/local/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

Modify PHP configuration

In Terminal, enter:

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

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

$ sudo -i
# cd /opt/local/etc/php5
# cp php.ini php.ini.bak
# defSock=`/opt/local/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

Troubleshooting

404 Not Found

Check Console.app, 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.