Difference between pages "User:Javichu/Temp 18" and "Product Opener/Installation"

From Open Food Facts wiki
< User:Javichu(Difference between pages)
Jump to navigation Jump to search
 
 
Line 1: Line 1:
<div style="color:red; font-size:xx-large; text-align:center">
+
Installation instructions for Product Opener (see [[Project:Product Opener]]).
'''''Merging & updating: Puffed cereal cakes'''''
+
 
</div>
+
== Before you start ==
 +
 
 +
Product Opener is not yet released as open source. The instructions below are for reference and for early testers of Product Opener. They are very likely to change as the code will be restructured, made more independent of proprietary code and specific Open Food Facts uses etc.
 +
 
 +
When it is released, Product Opener will have much easier to use install scripts and instructions.
 +
 
 +
== Install directory ==
 +
 
 +
Instructions below use /home/obf for the install directory, replace with your install dir.
 +
 
 +
== Product Opener code ==
 +
 
 +
=== Configuration ===
 +
 
 +
==== startup.pl ====
 +
 
 +
This file is used to preload Perl module in Apache.
 +
It contains a path that needs to be updated:
  
= EN - FR =
 
== Galettes de céréales ==
 
 
<pre>
 
<pre>
fr:Galettes de céréales
+
# Needs to be configured
 +
use lib "/home/obf/cgi/";
 +
</pre>
  
< fr:Galettes de céréales
+
==== Config.pm ====
fr:Galettes de maïs
 
  
< fr:Galettes de céréales
+
==== Config2.pm ====
fr:Galettes de riz
 
  
< fr:Galettes de riz
+
Contains info about the domain, database and path. This is separated from Config.pm so that it is easy to create test instance that share the same configuration in Config.pm but are on other domains.
fr:Galettes de riz complet
 
</pre>
 
  
= ES =
 
== Tortitas de cereales ==
 
 
<pre>
 
<pre>
< en:Cereals
+
# server constants
es:Tortitas de cereales
+
$domain = "openbeautyfacts.org";
  
< es:Tortitas de cereales
+
# server paths
es:Tortitas de arroz
+
$www_root = "/home/obf/html";
 +
$data_root = "/home/obf";
  
< es:Tortitas de cereales
+
$mongodb = "obf";
es:Tortitas de varios cereales
 
 
</pre>
 
</pre>
  
= Common =
+
== MongoDB database ==
== Top category ==
+
 
'''''Incluir: Cereales y derivados, Pan y repostería'''''
+
== Apache servers ==  
 +
 
 +
In production we use a light weight Apache web server for static files (e.g. images) that does reverse proxying to a modperl Apache server that dynamically generates the HTML pages.
 +
 
 +
If the trafic is low or moderate, you can use only one Apache mod_perl server that also serves images etc.
 +
 
 +
In the example below, the Apache mod_perl server listens on port 19000.
 +
 
 +
=== Light-weight reverse proxy for static files ===
 +
 
 +
Add to httpd.conf:
  
 
<pre>
 
<pre>
< en:Cereals and their products
 
en:Puffed cereal cakes
 
es:Tortitas de cereales
 
fr:Galettes de céréales
 
</pre>
 
  
== Puffed rice cakes ==
+
<VirtualHost *>
<pre>
+
DocumentRoot /home/obf/html
< en:Puffed cereal cakes
+
ServerName world.openbeautyfacts.org
en:Puffed rice cakes
+
ServerAlias *.openbeautyfacts.org
es:Tortitas de arroz
+
 
fr:Galettes de riz
+
ErrorLog /home/obf/logs/proxy_error_log
 +
CustomLog /home/obf/logs/proxy_access_log combined
 +
ServerAdmin stephane@openbeautyfacts.org
  
< en:Puffed rice cakes
+
<Directory "/home/obf/html">
en:Puffed wholegrain rice cakes
+
    Options -Indexes FollowSymLinks
es:Tortitas de arroz integral
+
    Order allow,deny
fr:Galettes de riz complet
+
    Allow from all
 +
</Directory>
 +
RewriteEngine on
 +
RewriteCond  %{REQUEST_URI}  !/./
 +
RewriteRule ^(/cgi/.*)$ http://localhost:19000$1 [P,L]
 +
RewriteMap escape int:escape
 +
RewriteRule ^/favicon.ico$ /favicon.ico [L]
 +
RewriteCond  %{REQUEST_URI}  !^/images/
 +
RewriteCond  %{REQUEST_URI}  !^/js/
 +
RewriteCond  %{REQUEST_URI}  !^/rss/
 +
RewriteCond  %{REQUEST_URI}  !^/robots
 +
RewriteCond  %{REQUEST_URI}  !^/clicks/
 +
RewriteCond  %{REQUEST_URI}  !^/data/
 +
RewriteCond  %{REQUEST_URI}  !^/files/
 +
RewriteRule  ^(.*)$ http://localhost:19000/cgi/display.pl?${escape:$1} [P,L,QSA]
 +
</VirtualHost>
  
< en:Puffed cereal cakes
 
en:Puffed rice cakes with black chocolate
 
es:Tortitas de arroz con chocolate negro
 
fr:Galettes de riz au chocolat noir
 
  
< en:Puffed cereal cakes
+
<VirtualHost *>
en:Puffed rice cakes with milk chocolate
+
DocumentRoot /home/obf/html
es:Tortitas de arroz con chocolate con leche
+
ServerName openbeautyfacts.org
fr:Galettes de riz au chocolat au lait
+
ErrorLog /home/obf/logs/proxy_error_log
 +
CustomLog /home/obf/logs/proxy_access_log combined
 +
DirectoryIndex index.html index.shtml
 +
<Directory "/home/obf/html">
 +
    Options -Indexes FollowSymLinks Includes
 +
    Order allow,deny
 +
    Allow from all
 +
</Directory>
 +
RewriteEngine on
 +
RewriteCond %{HTTP_HOST} ^openbeautyfacts\.org
 +
RewriteRule ^/products$ /products.shtml [L]
  
< en:Puffed cereal cakes
+
</VirtualHost>
en:Puffed rice cakes with white chocolate
 
es:Tortitas de arroz con chocolate blanco
 
fr:Galettes de riz au chocolat blanc
 
  
< en:Puffed cereal cakes
 
en:Puffed rice cakes with carob
 
es:Tortitas de arroz con algarroba
 
fr:Galettes de riz au caroube
 
 
</pre>
 
</pre>
  
== Puffed corn cakes ==
+
=== modperl Apache server for dynamic pages ===
<pre>
+
 
< en:Puffed cereal cakes
+
* download the latest version of the source of the Apache httpd server from the 2.2 branch (2.2.29 when writing this)
en:Puffed corn cakes
+
** do not use the 2.4 branch as mod_perl is not yet compatible with it
es:Tortitas de maíz
+
* extract the source
fr:Galettes de maïs
+
* ./configure --with-mpm=prefork --prefix=/home/obf/apache --enable-rewrite --enable-proxy --enable-proxy_http --enable-deflate --disable-userdir --enable-headers
 +
* make
 +
* make install
 +
 
 +
* download the latest version of mod_perl from http://perl.apache.org/
 +
* extract the source
 +
* perl Makefile.PL MP_APXS=/home/obf/apache/bin/apxs
 +
* make
 +
* make install
 +
 
 +
==== Configuration ====
 +
 
 +
In /home/obf/apache/conf/httpd.conf:
 +
 
 +
Change the port:
  
< en:Puffed cereal cakes
+
Listen 19000
en:Puffed corn cakes with black chocolate
 
es:Tortitas de maíz con chocolate negro
 
fr:Galettes de maïs au chocolat noir
 
  
< en:Puffed cereal cakes
+
Add at the end:
en:Puffed corn cakes with milk chocolate
 
es:Tortitas de maíz con chocolate con leche
 
fr:Galettes de maïs au chocolat au lait
 
</pre>
 
  
== Other puffed one-cereal cakes ==
 
 
<pre>
 
<pre>
< en:Puffed cereal cakes
+
PerlWarn Off
en:Puffed oat cakes
+
PerlRequire /home/obf/cgi/startup.pl
es:Tortitas de avena
 
fr:Galettes d'avoine
 
  
< en:Puffed cereal cakes
 
en:Puffed wheat cakes
 
es:Tortitas de trigo
 
fr:Galettes de blé
 
  
< en:Puffed wheat cakes
+
<Location /cgi>
en:Puffed spelt cakes
+
SetHandler perl-script
es:Tortitas de espelta
+
PerlResponseHandler ModPerl::Registry
fr:Galettes d'épautre
+
PerlOptions +ParseHeaders
 +
Options +ExecCGI
 +
Order allow,deny
 +
Allow from all
 +
</Location>
  
< en:Puffed wheat cakes
 
en:Puffed Khorasan wheat cakes, Puffed Kamut cakes
 
es:Tortitas de trigo de Jorasán, Tortitas de Kamut
 
fr:Galettes de blé de Khorasan, Galettes de Kamut
 
</pre>
 
  
== Puffed multigrain cakes ==
+
<VirtualHost *>
<pre>
+
DocumentRoot /home/obf/html
< en:Puffed cereal cakes
+
ServerName world.openbeautyfacts.org
en:Puffed multigrain cakes
+
ErrorLog /home/obf/logs/error_log
es:Tortitas multicereales, Tortitas de varios cereales
+
CustomLog /home/obf/logs/access_log combined
fr:Galettes multicéréales
+
ScriptAlias /cgi/ "/home/obf/cgi/"
 +
</VirtualHost>
 +
 
 +
PerlPostReadRequestHandler My::ProxyRemoteAddr
 
</pre>
 
</pre>

Revision as of 13:44, 4 September 2014

Installation instructions for Product Opener (see Project:Product Opener).

Before you start

Product Opener is not yet released as open source. The instructions below are for reference and for early testers of Product Opener. They are very likely to change as the code will be restructured, made more independent of proprietary code and specific Open Food Facts uses etc.

When it is released, Product Opener will have much easier to use install scripts and instructions.

Install directory

Instructions below use /home/obf for the install directory, replace with your install dir.

Product Opener code

Configuration

startup.pl

This file is used to preload Perl module in Apache. It contains a path that needs to be updated:

# Needs to be configured
use lib "/home/obf/cgi/";

Config.pm

Config2.pm

Contains info about the domain, database and path. This is separated from Config.pm so that it is easy to create test instance that share the same configuration in Config.pm but are on other domains.

# server constants
$domain = "openbeautyfacts.org";

# server paths
$www_root = "/home/obf/html";
$data_root = "/home/obf";

$mongodb = "obf";

MongoDB database

Apache servers

In production we use a light weight Apache web server for static files (e.g. images) that does reverse proxying to a modperl Apache server that dynamically generates the HTML pages.

If the trafic is low or moderate, you can use only one Apache mod_perl server that also serves images etc.

In the example below, the Apache mod_perl server listens on port 19000.

Light-weight reverse proxy for static files

Add to httpd.conf:


<VirtualHost *>
DocumentRoot /home/obf/html
ServerName world.openbeautyfacts.org
ServerAlias *.openbeautyfacts.org

ErrorLog /home/obf/logs/proxy_error_log
CustomLog /home/obf/logs/proxy_access_log combined
ServerAdmin stephane@openbeautyfacts.org

<Directory "/home/obf/html">
    Options -Indexes FollowSymLinks
    Order allow,deny
    Allow from all
</Directory>
RewriteEngine on
RewriteCond  %{REQUEST_URI}  !/./
RewriteRule ^(/cgi/.*)$ http://localhost:19000$1 [P,L]
RewriteMap escape int:escape
RewriteRule ^/favicon.ico$ /favicon.ico [L]
RewriteCond  %{REQUEST_URI}  !^/images/
RewriteCond  %{REQUEST_URI}  !^/js/
RewriteCond  %{REQUEST_URI}  !^/rss/
RewriteCond  %{REQUEST_URI}  !^/robots
RewriteCond  %{REQUEST_URI}  !^/clicks/
RewriteCond  %{REQUEST_URI}  !^/data/
RewriteCond  %{REQUEST_URI}  !^/files/
RewriteRule  ^(.*)$ http://localhost:19000/cgi/display.pl?${escape:$1} [P,L,QSA]
</VirtualHost>


<VirtualHost *>
DocumentRoot /home/obf/html
ServerName openbeautyfacts.org
ErrorLog /home/obf/logs/proxy_error_log
CustomLog /home/obf/logs/proxy_access_log combined
DirectoryIndex index.html index.shtml
<Directory "/home/obf/html">
    Options -Indexes FollowSymLinks Includes
    Order allow,deny
    Allow from all
</Directory>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^openbeautyfacts\.org
RewriteRule ^/products$ /products.shtml [L]

</VirtualHost>

modperl Apache server for dynamic pages

  • download the latest version of the source of the Apache httpd server from the 2.2 branch (2.2.29 when writing this)
    • do not use the 2.4 branch as mod_perl is not yet compatible with it
  • extract the source
  • ./configure --with-mpm=prefork --prefix=/home/obf/apache --enable-rewrite --enable-proxy --enable-proxy_http --enable-deflate --disable-userdir --enable-headers
  • make
  • make install
  • download the latest version of mod_perl from http://perl.apache.org/
  • extract the source
  • perl Makefile.PL MP_APXS=/home/obf/apache/bin/apxs
  • make
  • make install

Configuration

In /home/obf/apache/conf/httpd.conf:

Change the port:

Listen 19000

Add at the end:

PerlWarn Off
PerlRequire /home/obf/cgi/startup.pl


<Location /cgi>
SetHandler perl-script
PerlResponseHandler ModPerl::Registry
PerlOptions +ParseHeaders
Options +ExecCGI
Order allow,deny
Allow from all
</Location>


<VirtualHost *>
DocumentRoot /home/obf/html
ServerName world.openbeautyfacts.org
ErrorLog /home/obf/logs/error_log
CustomLog /home/obf/logs/access_log combined
ScriptAlias /cgi/ "/home/obf/cgi/"
</VirtualHost>

PerlPostReadRequestHandler My::ProxyRemoteAddr