jenkins-bot has submitted this change and it was merged. Change subject: Run MediaWiki on Apache + fastcgi + HHVM ......................................................................
Run MediaWiki on Apache + fastcgi + HHVM - The default is still to use the Zend interpreter. - role::hhvm updated to install hhvm-nightly package from Facebook. - Enable multiverse repos in apt module. Needed for libapache2-mod-fastcgi. - When role::hhvm is enabled, Apache will switch to fastcgi + HHVM. - HHVM uses apache::env type from I3b387fe6c to set 'HHVM' flag. - Apache configuration files can branch on presence / absence of HHVM using <IfDefine HHVM> and <IfDefine !HHVM> blocks. - Update MediaWiki's Apache configuration file to use this technique so that it is runnable under both HHVM and PHP, depending on which is present. Change-Id: Ied0b9e5d969b2df5b8e7c744f5c36ef78bd9c024 --- M puppet/manifests/roles.pp M puppet/modules/apache/manifests/init.pp M puppet/modules/apache/manifests/mods.pp M puppet/modules/apache/manifests/site.pp M puppet/modules/apt/manifests/init.pp A puppet/modules/apt/templates/multiverse.list.erb M puppet/modules/hhvm/manifests/init.pp A puppet/modules/hhvm/templates/server.hdf.erb M puppet/modules/mediawiki/manifests/apache.pp M puppet/modules/mediawiki/templates/mediawiki-apache-site.erb 10 files changed, 134 insertions(+), 18 deletions(-) Approvals: Ori.livneh: Looks good to me, approved jenkins-bot: Verified diff --git a/puppet/manifests/roles.pp b/puppet/manifests/roles.pp index 454ad09..fe38b91 100644 --- a/puppet/manifests/roles.pp +++ b/puppet/manifests/roles.pp @@ -762,10 +762,10 @@ } # == Class: role::hhvm -# This role will eventually configure your MediaWiki instance to run -# under HHVM. It is still a work-in-progress. At the moment it merely -# installs the latest HHVM packages from the upstream apt repository. +# This role will configure your MediaWiki instance to run under HHVM. +# under HHVM. class role::hhvm { + include role::mediawiki include ::hhvm } diff --git a/puppet/modules/apache/manifests/init.pp b/puppet/modules/apache/manifests/init.pp index 74f0591..b1796f5 100644 --- a/puppet/modules/apache/manifests/init.pp +++ b/puppet/modules/apache/manifests/init.pp @@ -38,7 +38,7 @@ } exec { 'setup apache env.d': - command => 'echo \'for envfile in ${APACHE_CONFDIR}/env.d/*; do . $envfile; done\' >>>/etc/apache2/envvars', + command => 'echo \'for envfile in /etc/apache2/env.d/*; do . $envfile; done\' >>/etc/apache2/envvars', unless => 'grep -q env.d /etc/apache2/envvars', require => File['/etc/apache2/env.d'], } diff --git a/puppet/modules/apache/manifests/mods.pp b/puppet/modules/apache/manifests/mods.pp index a99d390..cbfee2e 100644 --- a/puppet/modules/apache/manifests/mods.pp +++ b/puppet/modules/apache/manifests/mods.pp @@ -22,11 +22,15 @@ # mod_wsgi class apache::mods::wsgi { - package { 'libapache2-mod-wsgi': - ensure => present, - } + package { 'libapache2-mod-wsgi': } -> apache::mod { 'wsgi': } +} - apache::mod { 'wsgi': - require => Package['libapache2-mod-wsgi'], - } +# mod_fastcgi +class apache::mods::fastcgi { + package { 'libapache2-mod-fastcgi': } -> apache::mod { 'fastcgi': } +} + +# mod_actions +class apache::mods::actions { + apache::mod { 'actions': } } diff --git a/puppet/modules/apache/manifests/site.pp b/puppet/modules/apache/manifests/site.pp index 9747a64..2dec725 100644 --- a/puppet/modules/apache/manifests/site.pp +++ b/puppet/modules/apache/manifests/site.pp @@ -53,7 +53,10 @@ recurse => true, purge => true, force => true, - before => File["/etc/apache2/sites-available/${site_file}"], + before => [ + File["/etc/apache2/sites-available/${site_file}"], + Misc::Evergreen['apache2'], + ], } apache::conf { "000-${site}": diff --git a/puppet/modules/apt/manifests/init.pp b/puppet/modules/apt/manifests/init.pp index fc6e7ce..feba6f4 100644 --- a/puppet/modules/apt/manifests/init.pp +++ b/puppet/modules/apt/manifests/init.pp @@ -25,6 +25,11 @@ unless => 'apt-key list | grep -q Wikimedia', } + file { '/etc/apt/sources.list.d/multiverse.list': + content => template('apt/multiverse.list.erb'), + notify => Exec['apt-get update'], + } + file { '/etc/apt/sources.list.d/wikimedia.list': content => template('apt/wikimedia.list.erb'), require => Exec['add wikimedia apt key'], diff --git a/puppet/modules/apt/templates/multiverse.list.erb b/puppet/modules/apt/templates/multiverse.list.erb new file mode 100644 index 0000000..a69cecd --- /dev/null +++ b/puppet/modules/apt/templates/multiverse.list.erb @@ -0,0 +1,7 @@ +# Ubuntu multiverse package repository source file. +# This file is managed by Puppet. +# +deb http://archive.ubuntu.com/ubuntu <%= scope.lookupvar('::lsbdistcodename') %> multiverse +deb-src http://archive.ubuntu.com/ubuntu <%= scope.lookupvar('::lsbdistcodename') %> multiverse +deb http://security.ubuntu.com/ubuntu <%= scope.lookupvar('::lsbdistcodename') %>-security multiverse +deb-src http://security.ubuntu.com/ubuntu <%= scope.lookupvar('::lsbdistcodename') %>-security multiverse diff --git a/puppet/modules/hhvm/manifests/init.pp b/puppet/modules/hhvm/manifests/init.pp index b5b5e55..68afb7a 100644 --- a/puppet/modules/hhvm/manifests/init.pp +++ b/puppet/modules/hhvm/manifests/init.pp @@ -5,5 +5,34 @@ # work-in-progress. # class hhvm { - package { 'hhvm': } + include ::apache + include ::apache::mods::actions + include ::apache::mods::alias + include ::apache::mods::fastcgi + + package { 'hhvm-nightly': + require => Apache::Mod['actions', 'alias', 'fastcgi'], + } + + # Define an 'HHVM' flag, the presence of which can be checked + # with <IfDefine> directives. This allows Apache site config + # files to provide HHVM-specific configuration blocks. + apache::env { 'hhvm': + content => 'export APACHE_ARGUMENTS="${APACHE_ARGUMENTS:- }-D HHVM"', + require => Service['hhvm'], + } + + file { '/etc/hhvm/server.hdf': + ensure => file, + content => template( 'hhvm/server.hdf.erb'), + require => Package['hhvm-nightly'], + notify => Service['hhvm'], + } + + service { 'hhvm': + ensure => running, + provider => debian, + enable => true, + require => File['/etc/hhvm/server.hdf'], + } } diff --git a/puppet/modules/hhvm/templates/server.hdf.erb b/puppet/modules/hhvm/templates/server.hdf.erb new file mode 100644 index 0000000..374ddd6 --- /dev/null +++ b/puppet/modules/hhvm/templates/server.hdf.erb @@ -0,0 +1,52 @@ +# This file is managed by puppet +# +PidFile = /var/run/hhvm/pid + +# Have experienced issues with load.php returning partial results +# on large results with gzip enabled + +Server { + Type = fastcgi + Port = 9000 + SourceRoot = <%= scope.lookupvar('role::mediawiki::dir') %> + DefaultDocument = index.php + GzipCompressionLevel = 0 +} + +Log { + Level = Warning + AlwaysLogUnhandledExceptions = true + RuntimeErrorReportingLevel = 8191 + UseLogFile = true + UseSyslog = false + File = /vagrant/logs/hhvm-error.log + Access { + * { + File = /var/log/hhvm/access.log + Format = %h %l %u % t \”%r\” %>s %b + } + } +} + +Repo { + Central { + Path = /vagrant/logs/.hhvm.hhbc + } +} + +#include "/usr/share/hhvm/hdf/static.mime-types.hdf" +StaticFile { + FilesMatch { + * { + pattern = .*\.(dll|exe) + headers { + * = Content-Disposition: attachment + } + } + } + Extensions : StaticMimeTypes +} + +MySQL { + TypedResults = false +} diff --git a/puppet/modules/mediawiki/manifests/apache.pp b/puppet/modules/mediawiki/manifests/apache.pp index 9da8779..8e0b01e 100644 --- a/puppet/modules/mediawiki/manifests/apache.pp +++ b/puppet/modules/mediawiki/manifests/apache.pp @@ -15,9 +15,8 @@ apache::site { $mediawiki::wiki_name: ensure => present, content => template('mediawiki/mediawiki-apache-site.erb'), - require => [ Apache::Mod['alias'], Apache::Mod['rewrite'] ], + require => Apache::Mod['alias', 'rewrite'], } - file { '/var/www/favicon.ico': ensure => file, diff --git a/puppet/modules/mediawiki/templates/mediawiki-apache-site.erb b/puppet/modules/mediawiki/templates/mediawiki-apache-site.erb index 158ca80..3f0a5a1 100644 --- a/puppet/modules/mediawiki/templates/mediawiki-apache-site.erb +++ b/puppet/modules/mediawiki/templates/mediawiki-apache-site.erb @@ -6,6 +6,7 @@ ServerName vagrant ServerAdmin http://www.mediawiki.org/wiki/Vagrant DocumentRoot "/var/www" +LogLevel error <Directory /> Options FollowSymLinks @@ -29,9 +30,25 @@ Alias /wiki "<%= scope.lookupvar('mediawiki::dir') %>/index.php" Alias /w "<%= scope.lookupvar('mediawiki::dir') %>" Alias /images "<%= scope.lookupvar('mediawiki::upload_dir') %>" +Alias /mediawiki-vagrant.png /var/www/mediawiki-vagrant.png +Alias /favicon.ico /var/www/favicon.ico -# Causes Apache to fail to start when it initializes before /vagrant has -# been mounted: -# ErrorLog "/vagrant/logs/apache-error.log" +<IfDefine HHVM> + # FIXME: HHVM seems to require that PHP files be part of the docroot + # file hierarchy, but this means that /index.php and /api.php are + # valid entrypoints. + DocumentRoot "<%= scope.lookupvar('mediawiki::dir') %>" -LogLevel error + # Remove the default PHP type and handler. + RemoveHandler .php + RemoveType .php + + # Configure HHVM to handle PHP + AddType application/php5-fastcgi .php + Action application/php5-fastcgi /php5-hhvm + Alias /php5-hhvm /usr/lib/cgi-bin/php5-hhvm + FastCgiExternalServer /usr/lib/cgi-bin/php5-hhvm -host 127.0.0.1:9000 + <FilesMatch "\.php$"> + SetHandler application/php5-fastcgi + </FilesMatch> +</IfDefine> -- To view, visit https://gerrit.wikimedia.org/r/105834 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ied0b9e5d969b2df5b8e7c744f5c36ef78bd9c024 Gerrit-PatchSet: 9 Gerrit-Project: mediawiki/vagrant Gerrit-Branch: master Gerrit-Owner: EBernhardson <ebernhard...@wikimedia.org> Gerrit-Reviewer: EBernhardson <ebernhard...@wikimedia.org> Gerrit-Reviewer: Ori.livneh <o...@wikimedia.org> Gerrit-Reviewer: Yuvipanda <yuvipa...@gmail.com> Gerrit-Reviewer: jenkins-bot _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits