Which web server should i use apache2 or nginx for better performance ?
I have learnt that performance is not a real issue in an early project. In your case I will choose nginx because its simplicity. For me, nginx configuration is easier to read than apache configuration.
My solution is something like this.
- dabase name convention : should be in lowercase
- default server is www.localhost.local (php web server). It should be replaced with real domain.
- openerp server is openerp.localhost.local
- any access to subdomain other than 'openerp' will be redirected to openerp.localhost.local
The http context is something like the following.
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server_names_hash_bucket_size 64;
upstream openerp {
server 127.0.0.1:8869;
}
server {
listen 80;
server_name www.localhost.local;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
# it could be php app
try_files $uri $uri/ /index.html;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
server {
listen 80;
server_name ~^(?<subdomain>.*)\.localhost\.local$;
if ($subdomain != 'openerp') {
rewrite ^ http://openerp.localhost.local/?db=$subdomain last;
}
}
server {
listen 80;
server_name openerp.localhost.local;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
try_files $uri @python_openerp;
}
location @python_openerp {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $host;
proxy_redirect off;
proxy_read_timeout 300;
proxy_pass http://openerp;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
And don't forget to edit the hosts file.