Difference between revisions of "MythWeb on Nginx"

From MythTV Official Wiki
Jump to: navigation, search
Line 1: Line 1:
 
{{incomplete}}
 
{{incomplete}}
==MythWeb on Nginx--
+
 
 +
* work in progress - stuarta
 +
 
 +
 
 +
==MythWeb on Nginx==
  
 
MythWeb provides a web interface for scheduling and managing recordings from a web browser located on any machine, with new features being added such as remote control.
 
MythWeb provides a web interface for scheduling and managing recordings from a web browser located on any machine, with new features being added such as remote control.
Line 8: Line 12:
 
== Installation ==
 
== Installation ==
  
Your distribution should have a package for nginx. If not, you can visit their site for the code.  
+
Your distribution should have a package for nginx. It is probably woefully out of date.
 +
Do yourself a favour and go and get the packages provided at nginx.org [[http://wiki.nginx.org/Install]]
  
The default HTML directory for my Fedora distribution was /usr/share/nginx/html, whereas a package of MythWeb goes to the Apache directory.../var/www/html/. You can create a symbolic link, or just have nginx root to the same directory as Apache...a good move if you aren't sure you are going to commit to an alternate web server.
+
The default HTML directory for the nginx packages is /usr/share/nginx/html, whereas a package of MythWeb goes to the Apache directory.../var/www/html/. You can create a symbolic link, or just have nginx root to the same directory as Apache...a good move if you aren't sure you are going to commit to an alternate web server.
  
 
So, we'll assume the root is /var/www/html and that the mythweb directory is right off the root.
 
So, we'll assume the root is /var/www/html and that the mythweb directory is right off the root.
Line 16: Line 21:
 
== Fast-CGI for PHP ==
 
== Fast-CGI for PHP ==
  
Unlike Apache, Nginx doesn't have PHP support built in, and it must be configured for it. You'll need to install spawn-fcgi.  
+
Unlike Apache, Nginx doesn't have PHP support built in, and it must be configured for it.
 +
The old way was to use fast-cgi. If you are using nginx, you are trying to get performance
 +
and scalability. Forget FastCGI and install php-fpm. If you really have trouble finding php
 +
fpm then these instructions should also work for fastcgi.
 +
 
 +
== PHP FPM ==
 +
 
 +
Ubuntu/Debian have php fpm packages available by default.
 +
 
 +
apt-get install php5-fpm
 +
 
 +
This installs a php fpm instance and the default configuration out of the box
 +
has it listening on 127.0.0.1:9000
  
 
<code>
 
<code>

Revision as of 00:11, 8 November 2011

Incomplete.png Incomplete, needs to be expanded. Please help to fill the gaps or discuss the issue on the talk page

  • work in progress - stuarta


MythWeb on Nginx

MythWeb provides a web interface for scheduling and managing recordings from a web browser located on any machine, with new features being added such as remote control.

An Apache server can use a lot of memory, especially for a system where the number of users of the server can be measured on one hand...essentially private. Nginx(pronounced N-Gen-X), is a lightweight, high-performance Web server/reverse proxy.

Installation

Your distribution should have a package for nginx. It is probably woefully out of date. Do yourself a favour and go and get the packages provided at nginx.org [[1]]

The default HTML directory for the nginx packages is /usr/share/nginx/html, whereas a package of MythWeb goes to the Apache directory.../var/www/html/. You can create a symbolic link, or just have nginx root to the same directory as Apache...a good move if you aren't sure you are going to commit to an alternate web server.

So, we'll assume the root is /var/www/html and that the mythweb directory is right off the root.

Fast-CGI for PHP

Unlike Apache, Nginx doesn't have PHP support built in, and it must be configured for it. The old way was to use fast-cgi. If you are using nginx, you are trying to get performance and scalability. Forget FastCGI and install php-fpm. If you really have trouble finding php fpm then these instructions should also work for fastcgi.

PHP FPM

Ubuntu/Debian have php fpm packages available by default.

apt-get install php5-fpm

This installs a php fpm instance and the default configuration out of the box has it listening on 127.0.0.1:9000

       location ~ \.php$ {
           fastcgi_pass   127.0.0.1:9000;
           fastcgi_index  index.php;
           fastcgi_param SCRIPT_FILENAME /var/www/html$fastcgi_script_name;
           fastcgi_param db_server localhost;
           fastcgi_param db_name  mythconverg;
           fastcgi_param db_login mythtv;
           fastcgi_param db_password mythtv;
           fastcgi_param hostname mymythbox;
           include        fastcgi_params;
       }

Rewrite Rules

Unlike Apache, Nginx does not support .htaccess files, so all configuration must go in the nginx configuration. Of course, for convenience, nginx is defaultly set up to include all files on a conf.d directory, so you can separate out pieces for portability.


    location /mythweb/ {
           root /var/www/html;
          # The two Auth Lines assume that you want to password protect - which is recommended
           auth_basic          "Restricted";
          # Supports a standard htpasswd file, which defaults to the same directory as nginx.conf
           auth_basic_user_file htpasswd;
           if (!-e $request_filename) {
        rewrite  ^/mythweb/(pl(/.*)?)$        /mythweb/mythweb.pl?PATH_INFO=/$1 last;
        rewrite   ^/mythweb/(.+)$            /mythweb/mythweb.php?PATH_INFO=/$1 last;
               }
           if (!-f $request_filename) {
           rewrite     ^/mythweb/(.*)$                  /mythweb/mythweb.php last;
                }
            }

See Also