Last active
March 22, 2024 18:32
-
-
Save daothanh/2f9be5af944e7cb92c84ceb64c4bc3fd to your computer and use it in GitHub Desktop.
Install odoo 12 on Centos 7 with nginx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
yum update | |
yum install epel-release -y | |
yum install centos-release-scl -y | |
yum install git wget ibxslt-devel bzip2-devel openldap-devel libjpeg-devel freetype-devel -y | |
sudo yum groupinstall 'Development Tools' -y | |
## Gist url | |
export GIST_URL="https://gist.githubusercontent.com/daothanh/2f9be5af944e7cb92c84ceb64c4bc3fd/raw" | |
export ODOO_DOMAIN=webcongty.pro | |
export ODOO_PASSWORD=abc@123 | |
export PERL_UPDATE_ENV="perl -p -e 's/\{\{([^}]+)\}\}/defined \$ENV{\$1} ? \$ENV{\$1} : \$&/eg' " | |
[[ -z $SYSTEM ]] && echo "Don't forget to define SYSTEM variable" | |
# Install Postpresql | |
yum install -y https://download.postgresql.org/pub/repos/yum/11/redhat/rhel-7-x86_64/pgdg-centos11-11-2.noarch.rpm | |
yum install -y postgresql11-server.x86_64 postgresql11-contrib.x86_64 | |
sudo /usr/pgsql-11/bin/postgresql-11-setup initdb | |
sudo systemctl start postgresql-11 | |
sudo systemctl enable postgresql-11 | |
# Create odoo user | |
su - postgres -c "createuser -s odoo" | |
# Install wkhtmltox | |
yum install -y https://downloads.wkhtmltopdf.org/0.12/0.12.5/wkhtmltox-0.12.5-1.centos7.x86_64.rpm | |
# Install Python 3 | |
yum install -y centos-release-scl | |
yum install -y rh-python36 | |
scl enable rh-python36 bash | |
#Install Nginx | |
cd /etc/yum.repos.d/ | |
wget -q ${GIST_URL}/nginx.repo -O nginx.repo | |
yum update | |
yum install nginx -y | |
systemctl enable nginx | |
service start nginx | |
# Install Certbot | |
yum -y install yum-utils | |
yum-config-manager --enable rhui-REGION-rhel-server-extras rhui-REGION-rhel-server-optional | |
yum -y install python2-certbot-nginx | |
# Install Odoo | |
su - odoo | |
cd /opt/odoo | |
git clone https://www.github.com/odoo/odoo --depth 1 --branch 12.0 /opt/odoo/odoo | |
scl enable rh-python36 bash | |
python -m venv odoo-venv | |
source odoo12-venv/bin/activate | |
# Upgrade pip | |
pip install --upgrade pip | |
pip install wheel | |
pip install -r odoo/requirements.txt | |
deactivate && exit | |
exit | |
mkdir /opt/odoo/odoo-custom-addons | |
chown odoo: /opt/odoo/odoo-custom-addons | |
# Odoo config | |
cd /etc/ | |
wget -q ${GIST_URL}/odoo.conf -O odoo.conf | |
eval "${PERL_UPDATE_ENV} < odoo.conf" | sponge odoo.conf | |
# Install and anable odoo service | |
cd /etc/systemd/system/ | |
wget -q ${GIST_URL}/odoo.service -O odoo.service | |
systemctl daemon-reload | |
systemctl start odoo | |
systemctl enable odoo | |
# Set enforce | |
setenforce 0 | |
# Config nginx | |
cd /etc/nginx/con.d/ | |
wget -q ${GIST_URL}/nginx-odoo.conf -O odoo.conf | |
eval "${PERL_UPDATE_ENV} < odoo.conf" | sponge odoo.conf | |
service nginx restart | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Odoo servers | |
upstream odoo { | |
server 127.0.0.1:8069; | |
} | |
upstream odoochat { | |
server 127.0.0.1:8072; | |
} | |
# HTTP -> HTTPS | |
server { | |
listen 80; | |
server_name www.{{ODOO_DOMAIN}} {{ODOO_DOMAIN}}; | |
#include snippets/letsencrypt.conf; | |
return 301 https://{{ODOO_DOMAIN}}$request_uri; | |
} | |
# WWW -> NON WWW | |
server { | |
listen 443 ssl http2; | |
server_name www.{{ODOO_DOMAIN}}; | |
ssl_certificate /etc/letsencrypt/live/{{ODOO_DOMAIN}}/fullchain.pem; | |
ssl_certificate_key /etc/letsencrypt/live/{{ODOO_DOMAIN}}/privkey.pem; | |
ssl_trusted_certificate /etc/letsencrypt/live/{{ODOO_DOMAIN}}/chain.pem; | |
#include snippets/ssl.conf; | |
return 301 https://{{ODOO_DOMAIN}}$request_uri; | |
} | |
server { | |
listen 443 ssl http2; | |
server_name {{ODOO_DOMAIN}}; | |
proxy_read_timeout 720s; | |
proxy_connect_timeout 720s; | |
proxy_send_timeout 720s; | |
# Proxy headers | |
proxy_set_header X-Forwarded-Host $host; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header X-Forwarded-Proto $scheme; | |
proxy_set_header X-Real-IP $remote_addr; | |
# SSL parameters | |
ssl_certificate /etc/letsencrypt/live/{{ODOO_DOMAIN}}/fullchain.pem; | |
ssl_certificate_key /etc/letsencrypt/live/{{ODOO_DOMAIN}}/privkey.pem; | |
ssl_trusted_certificate /etc/letsencrypt/live/{{ODOO_DOMAIN}}/chain.pem; | |
#include snippets/ssl.conf; | |
# log files | |
access_log /var/log/nginx/odoo.access.log; | |
error_log /var/log/nginx/odoo.error.log; | |
# Handle longpoll requests | |
location /longpolling { | |
proxy_pass http://odoochat; | |
} | |
# Handle / requests | |
location / { | |
proxy_redirect off; | |
proxy_pass http://odoo; | |
} | |
# Cache static files | |
location ~* /web/static/ { | |
proxy_cache_valid 200 90m; | |
proxy_buffering on; | |
expires 864000; | |
proxy_pass http://odoo; | |
} | |
# Gzip | |
gzip_types text/css text/less text/plain text/xml application/xml application/json application/javascript; | |
gzip on; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[nginx] | |
name=nginx repo | |
baseurl=http://nginx.org/packages/centos/7/$basearch/ | |
gpgcheck=0 | |
enabled=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[options] | |
; This is the password that allows database operations: | |
admin_passwd = {{ODOO_PASSWORD}} | |
db_host = False | |
db_port = False | |
db_user = odoo | |
db_password = False | |
addons_path = /opt/odoo/odoo/addons | |
; You can enable log file with uncommenting the next line | |
; logfile = /var/log/odoo12/odoo.log | |
; If you are using custom modules | |
; addons_path = /opt/odoo/odoo12/addons,/opt/odoo/odoo12-custom-addons |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=Odoo | |
Requires=postgresql-11.service | |
After=network.target postgresql-11.service | |
[Service] | |
Type=simple | |
SyslogIdentifier=odoo | |
PermissionsStartOnly=true | |
User=odoo | |
Group=odoo | |
ExecStart=/usr/bin/scl enable rh-python36 -- /opt/odoo/odoo12-venv/bin/python3 /opt/odoo/odoo/odoo-bin -c /etc/odoo.conf | |
StandardOutput=journal+console | |
[Install] | |
WantedBy=multi-user.target |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment