Community mailing list archives

community@mail.odoo.com

Re: Muliple Odoo Website on single port

by
Andi Becker
- 05/20/2016 04:19:15
Hi Zoya

Here is an example with 2 sites running in one Odoo:

We use Apache2 on Ubuntu in that example.

in etc/apache2/sites-available you need to create for this example two virtual hosts - manually or i.e. via virtualmin/webmin etc and change the entry later like in that example as the customer is running also other sites on the same server which he manages with virtualmin.

dev.mydomain.de.conf - will look like that
---
<VirtualHost *:80>

SuexecUserGroup "#1000" "#1000"

ServerName dev.mydomain.de
ServerAlias www.dev.mydomain.de

DocumentRoot /home/customer1/domains/dev.mydomain.de/public_html

ErrorLog /var/log/virtualmin/dev.mydomain.de_error_log
LogLevel warn
CustomLog /var/log/virtualmin/dev.mydomain.de_access_log combined

ScriptAlias /cgi-bin/ /home/customer1/domains/dev.mydomain.de/cgi-bin/

DirectoryIndex index.html index.htm index.php index.php4 index.php5

<Directory /home/customer1/domains/dev.mydomain.de/public_html>

Options -Indexes +IncludesNOEXEC +SymLinksIfOwnerMatch +ExecCGI

allow from all
AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch

Require all granted

AddType application/x-httpd-php .php

AddHandler fcgid-script .php
AddHandler fcgid-script .php5
FCGIWrapper /home/customer1/domains/dev.mydomain.de/fcgi-bin/php5.fcgi .php
FCGIWrapper /home/customer1/domains/dev.mydomain.de/fcgi-bin/php5.fcgi .php5

</Directory>

<Directory /home/customer1/domains/dev.mydomain.de/cgi-bin>

allow from all
AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch

Require all granted

</Directory>

<IfModule mod_rewrite.c>

RewriteEngine On

# Permanent redirect (301 HTTP) if no canonical domain name
RewriteCond %{HTTP_HOST} !^dev.mydomain.de
RewriteRule ^/(.*)$ http://dev.mydomain.de/$1 [R=301,NE,L]

# Redirect 301 to HTTPS
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R=301,NE,L]

</IfModule>

RemoveHandler .php
RemoveHandler .php5

FcgidMaxRequestLen 1073741824

<Location "/" >
Order deny,allow
Deny from all
Allow from all
</Location>

<Location /git>

DAV on

AuthType Basic
AuthName dev.mydomain.de
AuthUserFile /home/customer1/domains/dev.mydomain.de/etc/git.basic.passwd

Require valid-user
Satisfy All


RewriteEngine off

AddHandler cgi-script .cgi

</Location>

</VirtualHost>

<VirtualHost 123.456.789.0:443 [a123:b456:c789:de0f::2]:443>

SuexecUserGroup "#1000" "#1000"

ServerName dev.mydomain.de
ServerAlias www.dev.mydomain.de

DocumentRoot /home/customer1/domains/dev.mydomain.de/public_html

ErrorLog /var/log/virtualmin/dev.mydomain.de_error_log
LogLevel warn
CustomLog /var/log/virtualmin/dev.mydomain.de_access_log combined

ScriptAlias /cgi-bin/ /home/customer1/domains/dev.mydomain.de/cgi-bin/

DirectoryIndex index.html index.htm index.php index.php4 index.php5

<Directory /home/customer1/domains/dev.mydomain.de/public_html>

Options -Indexes +IncludesNOEXEC +SymLinksIfOwnerMatch +ExecCGI

allow from all
AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch

Require all granted

AddType application/x-httpd-php .php

AddHandler fcgid-script .php
AddHandler fcgid-script .php5
FCGIWrapper /home/customer1/domains/dev.mydomain.de/fcgi-bin/php5.fcgi .php
FCGIWrapper /home/customer1/domains/dev.mydomain.de/fcgi-bin/php5.fcgi .php5

</Directory>
<Directory /home/customer1/domains/dev.mydomain.de/cgi-bin>

allow from all
AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
Require all granted

</Directory>

SSLEngine on
SSLProtocol           all -SSLv2 -SSLv3
SSLCipherSuite         ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM
SSLCertificateFile /home/customer1/domains/dev.mydomain.de/ssl.cert
SSLCertificateKeyFile /home/customer1/domains/dev.mydomain.de/ssl.key

RequestHeader set X-Forwarded-Proto "https"

<IfModule mod_rewrite.c>
RewriteEngine On

# Permanent redirect (301 HTTP) if no canonical domain name
RewriteCond %{HTTP_HOST} !^dev.mydomain.de
RewriteRule ^/(.*)$ https://dev.mydomain.de/$1 [R=301,NE,L]
</IfModule>

RemoveHandler .php
RemoveHandler .php5

FcgidMaxRequestLen 1073741824

<Location "/" >
Order deny,allow
Deny from all
Allow from all
</Location>

<Location "/web/database" >
Order deny,allow
Deny from all
Allow from 61.0.249.127 64.167.94.28 192.168.122.0/24 127.0.0.0/255.0.0.0 ::1/128
</Location>

<Location "/website/info" >
Order deny,allow
Deny from all
Allow from 61.0.249.127 64.167.94.28 192.168.122.0/24 127.0.0.0/255.0.0.0 ::1/128
</Location>

<Location /git>

DAV on
AuthType Basic
AuthName dev.mydomain.de
AuthUserFile /home/customer1/domains/dev.mydomain.de/etc/git.basic.passwd
Require valid-user
Satisfy All

RewriteEngine off

AddHandler cgi-script .cgi

</Location>

# Comment to disable proxy
ProxyRequests Off
ProxyPreserveHost On
ProxyPass /longpolling/        http://localhost:8072/longpolling/ retry=0
ProxyPassReverse /longpolling/ http://localhost:8072/longpolling/ retry=0
ProxyPass /                    http://localhost:8069/ retry=0
ProxyPassReverse /             http://localhost:8069/ retry=0

</VirtualHost>

======== // ===========

site2.mydomain.de.conf - will look like that:
----------

<VirtualHost *:80>

SuexecUserGroup "#1000" "#1000"

ServerName site2.mydomain.de
    ServerAlias www.site2.mydomain.de

DocumentRoot /home/customer1/domains/site2.mydomain.de/public_html

ErrorLog /var/log/virtualmin/site2.mydomain.de_error_log
LogLevel warn
CustomLog /var/log/virtualmin/site2.mydomain.de_access_log combined

ScriptAlias /cgi-bin/ /home/customer1/domains/site2.mydomain.de/cgi-bin/

DirectoryIndex index.html index.htm index.php index.php4 index.php5

<Directory /home/customer1/domains/site2.mydomain.de/public_html>

Options -Indexes +IncludesNOEXEC +SymLinksIfOwnerMatch +ExecCGI

allow from all
AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch

Require all granted

AddType application/x-httpd-php .php

AddHandler fcgid-script .php
AddHandler fcgid-script .php5
FCGIWrapper /home/customer1/domains/site2.mydomain.de/fcgi-bin/php5.fcgi .php
FCGIWrapper /home/customer1/domains/site2.mydomain.de/fcgi-bin/php5.fcgi .php5

</Directory>

<Directory /home/customer1/domains/site2.mydomain.de/cgi-bin>

allow from all
AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch

Require all granted

</Directory>

<IfModule mod_rewrite.c>

RewriteEngine On

# Permanent redirect (301 HTTP) if no canonical domain name
RewriteCond %{HTTP_HOST} !^site2.mydomain.de
RewriteRule ^/(.*)$ http://site2.mydomain.de/$1 [R=301,NE,L]

# Redirect 301 to HTTPS
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R=301,NE,L]

</IfModule>

RemoveHandler .php
RemoveHandler .php5

FcgidMaxRequestLen 1073741824

<Location "/" >
Order deny,allow
Deny from all
Allow from all
</Location>

<Location /git>

DAV on

AuthType Basic
AuthUserFile /home/customer1/domains/site2.mydomain.de/etc/git.basic.passwd

Require valid-user
Satisfy All


RewriteEngine off

AddHandler cgi-script .cgi

</Location>

</VirtualHost>

<VirtualHost 123.456.789.0:443 [a123:b456:c789:de0f::2]:443>

SuexecUserGroup "#1000" "#1000"

ServerName site2.mydomain.de
    ServerAlias www.site2.mydomain.de

DocumentRoot /home/customer1/domains/site2.mydomain.de/public_html

ErrorLog /var/log/virtualmin/site2.mydomain.de_error_log
LogLevel warn
CustomLog /var/log/virtualmin/site2.mydomain.de_access_log combined

ScriptAlias /cgi-bin/ /home/customer1/domains/site2.mydomain.de/cgi-bin/

DirectoryIndex index.html index.htm index.php index.php4 index.php5

<Directory /home/customer1/domains/site2.mydomain.de/public_html>

Options -Indexes +IncludesNOEXEC +SymLinksIfOwnerMatch +ExecCGI

allow from all
AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch

Require all granted

AddType application/x-httpd-php .php

AddHandler fcgid-script .php
AddHandler fcgid-script .php5
FCGIWrapper /home/customer1/domains/site2.mydomain.de/fcgi-bin/php5.fcgi .php
FCGIWrapper /home/customer1/domains/site2.mydomain.de/fcgi-bin/php5.fcgi .php5

</Directory>
<Directory /home/customer1/domains/site2.mydomain.de/cgi-bin>

allow from all
AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
Require all granted

</Directory>

SSLEngine on
SSLProtocol           all -SSLv2 -SSLv3
SSLCipherSuite         ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM
SSLCertificateFile /home/customer1/domains/site2.mydomain.de/ssl.cert
SSLCertificateKeyFile /home/customer1/domains/site2.mydomain.de/ssl.key

RequestHeader set X-Forwarded-Proto "https"

<IfModule mod_rewrite.c>
RewriteEngine On

# Permanent redirect (301 HTTP) if no canonical domain name
RewriteCond %{HTTP_HOST} !^site2.mydomain.de
RewriteRule ^/(.*)$ https://site2.mydomain.de/$1 [R=301,NE,L]
</IfModule>

RemoveHandler .php
RemoveHandler .php5

FcgidMaxRequestLen 1073741824

<Location "/" >
Order deny,allow
Deny from all
Allow from all
</Location>

<Location "/web/database" >
Order deny,allow
Deny from all
Allow from 61.109.73.200 192.168.122.0/24 127.0.0.0/255.0.0.0 ::1/128
</Location>

<Location "/website/info" >
Order deny,allow
Deny from all
Allow from 61.109.73.200 192.168.122.0/24 127.0.0.0/255.0.0.0 ::1/128
</Location>

<Location /git>

DAV on
AuthType Basic
AuthUserFile /home/customer1/domains/site2.mydomain.de/etc/git.basic.passwd
Require valid-user
Satisfy All

RewriteEngine off

AddHandler cgi-script .cgi

</Location>

# Comment to disable proxy
ProxyRequests Off
ProxyPreserveHost On
ProxyPass /longpolling/        http://localhost:8072/longpolling/ retry=0
ProxyPassReverse /longpolling/ http://localhost:8072/longpolling/ retry=0
ProxyPass /                    http://localhost:8069/ retry=0
ProxyPassReverse /             http://localhost:8069/ retry=0

</VirtualHost>

============= // =============

In that example also SSL Certificates get used and some stuff gets enabled by only certain IP addresses - you can simply uncomment those parts if not needed and of course change those IP addresses to yours/the customers

If you have one time setup that stuff it is quite easily to multiply the script (copy/paste) and than apply only those settings which change from site to site to each new multiple website you are having (search and replace) or even an automated script which is doing that for you (and/or for your customers)

============= // =============

Don't forget to restart apache2 i.e. on Ubuntu with 

service apache2 restart

to apply the changes.

============= // ============

in etc/odoo/mydomain-server.conf

you should have something like:

------
[options]
; This is the password that allows database operations:
admin_passwd = My123/456PassW.V9
db_host = False
db_port = False
db_password = False
db_user = myDBuser

# Ports to use
xmlrpc_port = 8069
longpolling_port = 8072

# Workers and timeouts
workers = 4
limit_time_real = 3600
limit_time_cpu = 3600

# Is it behind a HTTP reverse proxy?
proxy_mode = 1

# DB filtering for multi-site instances
# Example: dbfilter=^%d$
# %d = hostname

#dbfilter=^%h$

# Logfile
logfile = /var/log/odoo/customer1-server.log

# Addons Path
addons_path=/home/customer1/customer1-server/addons,/home/customer1/customer1-custom/addons,/home/customer1/customer1-custom/debranding,/home/customer1/customer1-custom/knowledge,/home/customer1/customer1-custom/project,/home/customer1/customer1-custom/reports,/home/customer1/customer1-custom/web,/home/customer1/customer1-custom/website

========== // ==========

Those addons paths shown here are how the customer/agency likes to have his modules sorted, you should insert your own paths here. They have setup groups i.e. for debranding which makes it easier for them to update those modules on a regular base i.e. from their github and also which makes it easier for them to take one of those working module groups from one site to another site.

===========  //  =========

in etc/init.d you need to enter your 

customer1-server file

which might look like that:
----

# Description: ODOO Business Applications
### END INIT INFO
PATH=/bin:/sbin:/usr/bin
DAEMON=/home/customer1/customer1-server/openerp-server
NAME=customer1-server
DESC=customer1-server

# Specify the user name (Default: odoo).
USER=customer1

# Specify an alternate config file (Default: /etc/openerp-server.conf).
CONFIGFILE="/etc/odoo/customer1-server.conf"

# pidfile
PIDFILE=/var/run/$NAME.pid

# Additional options that are passed to the Daemon.
DAEMON_OPTS="-c $CONFIGFILE"
[ -x $DAEMON ] || exit 0
[ -f $CONFIGFILE ] || exit 0
checkpid() {
[ -f $PIDFILE ] || return 1
pid=`cat $PIDFILE`
[ -d /proc/$pid ] && return 0
return 1
}

case "${1}" in
start)
echo -n "Starting ${DESC}: "
start-stop-daemon --start --quiet --pidfile ${PIDFILE} \
--chuid ${USER} --background --make-pidfile \
--exec ${DAEMON} -- ${DAEMON_OPTS}
echo "${NAME}."
;;
stop)
echo -n "Stopping ${DESC}: "
start-stop-daemon --stop --quiet --pidfile ${PIDFILE} \
--oknodo
echo "${NAME}."
;;

restart|force-reload)
echo -n "Restarting ${DESC}: "
start-stop-daemon --stop --quiet --pidfile ${PIDFILE} \
--oknodo
sleep 1
start-stop-daemon --start --quiet --pidfile ${PIDFILE} \
--chuid ${USER} --background --make-pidfile \
--exec ${DAEMON} -- ${DAEMON_OPTS}
echo "${NAME}."
;;
*)
N=/etc/init.d/${NAME}
echo "Usage: ${NAME} {start|stop|restart|force-reload}" >&2
exit 1
;;

esac
exit 0

============ // =============

don't forget to set the correct permissions to those files and the correct owners as well as check if all paths and passwords are the correct ones.

If everything is fine you should be able to run your multiple sites in one Odoo after restarting also the Odoo webserver.

i.e. on Ubuntu with

service customer1-server restart


=========== // ==============

In Odoo itself of course you need to configure those both sites like already described, so I won't repeat that here.

With kind regards,
Mit freundlichen Grüßen,
Con un cordial saludo,
Cordialement,
с сердечным приветом,
เรื่องที่เกี่ยวกับชนิด,
與親切的問候,

 ANDI BECKER

CEO/General Manager LisAndi Co., Ltd.

--------------------------------------------------

LisAndi Co. Ltd., Phuket, Thailand (lisandi.com)
15/21 M.2 Viset Road, Rawai, Muang, Phuket, Thailand 83130

Mobile: +66 (0)81 606 3378
VoIP:   +49 (0)711 50 88788 50
Fax:     +49 (0)711 50 88788 50
Skype:          lisandi
Facebook:     andibecker
Google Talk/Facetime/eMail:  andi@lisandi.com

--------------------------------------------------