MythWeb 0.27 on Nginx 1.4.x on CentOS 6.x
Howto install MythWeb on a CentOS v6.4 VM, using Nginx as the web server and php-fpm to run the php. The database server is on another VM. The mythweb package is installed from ATRPMs as part of the backend installation (mythweb-0.27-280.noarch).
Install
Install the nginx repository
# rpm -Uvh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
Install Nginx
# yum install nginx
Install php fast package manager. The other php support should be installed already (except php-process seems to be missing).
yum install php-fpm php-process
Configure php-fpm
Edit the default '/etc/php-fpm.d/www.conf'. I've removed all the additional comments and increased the 'memory_limit'.
[www] listen = 127.0.0.1:9000 listen.allowed_clients = 127.0.0.1 user = nginx group = nginx pm = dynamic pm.max_children = 50 pm.start_servers = 5 pm.min_spare_servers = 5 pm.max_spare_servers = 35 slowlog = /var/log/php-fpm/www-slow.log php_admin_value[error_log] = /var/log/php-fpm/www-error.log php_admin_value[memory_limit] = 64M php_admin_flag[log_errors] = on php_value[session.save_handler] = files php_value[session.save_path] = /var/lib/php/session
Add the nginx user to the apache group so that it can group access the mythtv web files:
# usermod -G apache -a nginx
Start the service
# chkconfig php-fpm on # service php-fpm start
Configure Nginx
Add a Nginx configuration '/etc/nginx/conf.d/mythtv.conf'. It is assumed to be in a controlled environment, so password and TLS is not implemented. The MythTV content is located in the root of the web site (no 'mythweb' path name prefix is required).
server { listen [::]:80 default_server ipv6only=off; server_name _ ""; root /var/www/html/mythweb; error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } location / { # auth_basic "MythWeb"; # auth_basic_user_file mythweb.passwd; index /mythweb.php; try_files $uri @handler; } location ~ /.+\.php { fastcgi_pass 127.0.0.1:9000; include fastcgi_params; fastcgi_index mythweb.php; fastcgi_split_path_info ^(.+\.php)(/?.+)$; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param db_server onyx.lucidsolutions.co.nz; fastcgi_param db_name mythconverg; fastcgi_param db_login mythtv; fastcgi_param db_password mythtv; fastcgi_param hostname mythtv.lucidsolutions.co.nz; } location @handler { rewrite /(.+\.(php|pl))/.* /$1 last; rewrite /(pl(/.*)?)$ /mythweb.pl/$1 last; rewrite /(.+)$ /mythweb.php/$1 last; rewrite /(.*)$ /mythweb.php last; } }
Links
- http://www.mythtv.org/wiki/MythWeb_on_Nginx
- http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/www-apps/mythweb/files/mythweb.conf.nginx
- https://bbs.archlinux.org/viewtopic.php?id=138339
Appendices
php-process dependency missing
The following error message is displayed in the nginx log.
2013/11/10 22:32:07 [error] 1742#0: *56 FastCGI sent in stderr: "PHP message: PHP Fatal error: Call to undefined function posix_getpwuid() in /var/www/html/mythweb/includes/data_dir.php on line 17" while reading response header from upstream, client: ::ffff:10.20.11.3, server: _, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "mythtv.lucidsolutions.co.nz"
Fix this by installing the php-process package