Skip to content

Instantly share code, notes, and snippets.

@inspiretk
Last active October 19, 2019 01:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save inspiretk/57166a07e7640cd5242ca92eac7ca2d7 to your computer and use it in GitHub Desktop.
Save inspiretk/57166a07e7640cd5242ca92eac7ca2d7 to your computer and use it in GitHub Desktop.
WORKING VPS Install Odoo Multi Domain Non WWW SSL Security
Working. Install odoo on Ubuntu 18.04 VPS using script. Odoo 12 Community Edition.
Follow A2: a2 Odoo Install 12 Community Edition
Then Follow A3: a3 Domain redirect Multi Domain Setup
sudo apt update && sudo apt upgrade -y
sudo apt install git python3-pip build-essential wget python3-dev python3-venv python3-wheel libxslt-dev libzip-dev libldap2-dev libsasl2-dev python3-setuptools node-less -y
wget https://builds.wkhtmltopdf.org/0.12.1.3/wkhtmltox_0.12.1.3-1~bionic_amd64.deb
sudo apt install ./wkhtmltox_0.12.1.3-1~bionic_amd64.deb -y
# source go to https://github.com/Yenthe666/InstallScript
sudo wget https://raw.githubusercontent.com/Yenthe666/InstallScript/12.0/odoo_install.sh
nano odoo_install.sh
# Line OE_USER="odoo" is your odoo folder name leave as it is
# Line OE_SUPERADMIN="admin" is the master password for this Odoo installation (admin). Change admin to your new strong password
sudo chmod +x odoo_install.sh
sudo ./odoo_install.sh
# odoo will install on port 8069; odoo version 12 community edition
# If you're installing multiple domain:
## Go to your DNS, and point A record to your seriver IP
## Access your odoo: domain:8069 and create your domain
#!/bin/bash
# This script is to setup 1 domains on same server with 1 odoo install
# It will have lets encrypt ssl, www to non www redirect, odoo port 8069 to port 80
# Make sure both domains point to your server ip
# Make sure you make a STRONG PASSWORD for Master Password for your databases
# In below script, CHANGE to your domain name all lowercase eg DOMAIN1=YourDomainName.com
# go to cd /etc and type ls and see if you can see your odoo conf file, this script has /etc/odoo-server.conf, yours can be different
# if your odoo conf file is different, rename it in the script variables ODOOCFOLDER and ODOOCFILE
# run these commands below with root user, you can disable root user after you're done
# nano nginxressl.sh
# Copy everything in this script and paste it in, save file and exit
# chmod +x nginxressl.sh
# ./nginxressl.sh
# (when script is running, press enter to continue, put your important email for ssl renewal notices, 2 for redirect to non www)
DOMAIN1=thuani.com
ODOOCFOLDER=/etc
ODOOCFILE=odoo-server.conf
echo -e "\n---- Update odoo conf file for mutliple database ----"
cd $ODOOCFOLDER
# echo "db_host = False" >> $ODOOCFILE
# echo "db_port = False" >> $ODOOCFILE
# echo "db_user = odoo" >> $ODOOCFILE
echo "dbfilter = %d" >> $ODOOCFILE
# sudo sed -i 's/dbfilter = /dbfilter = ^%h\$/g' $ODOOCFILE
sudo service odoo-server restart
echo -e "\n---- apt-get update and upgrade ----"
cd
sudo apt-get update
sudo apt-get upgrade -y
echo -e "\n---- Install nginx, and set up ----"
sudo apt install nginx -y
echo -e "\n---- Setting up basic firewall Nginx Full and OpenSSH ----"
sudo ufw enable
sudo ufw allow 'Nginx Full'
sudo ufw allow 'OpenSSH'
echo -e "\n---- Setting up nginx conf for your first domain ----"
cd /etc/nginx/sites-available
sudo sed -i '$ d' default
sudo sed -i '$ d' default
sudo sed -i '$ d' default
sudo sed -i 's|# First attempt to serve request as file, then|proxy_pass http://localhost:8069;|g' default
sudo sed -i 's|# as directory, then fall back to displaying a 404.|proxy_http_version 1.1;|g' default
sudo sed -i 's|try_files $uri $uri/ =404;|proxy_set_header Upgrade $http_upgrade;|g' default
sudo sed -i "/proxy_set_header Upgrade \$http_upgrade;/a proxy_set_header Connection 'upgrade';" default
sudo sed -i "/proxy_set_header Connection 'upgrade';/a proxy_set_header Host \$host;" default
sudo sed -i "/proxy_set_header Host \$host;/a proxy_cache_bypass \$http_upgrade;" default
echo -e "\n---- Removing default_server in default nginx file----"
cd /etc/nginx/sites-available
sudo sed -i 's/listen 80 default_server;/listen 80;/g' default
sudo sed -i "s|listen \[::\]:80 default_server;|listen \[::\]:80;|g" default
echo -e "\n---- Rename default nginx file to your domain name and delete enabled default file ----"
cd /etc/nginx/sites-available
sudo cp default $DOMAIN1
cd /etc/nginx/sites-enabled
echo -e "\n---- Create template nginx file called template ----"
cd /etc/nginx/sites-available
sudo cp $DOMAIN1 template
echo -e "\n---- Setting up redirect www to non www and fixing up server name----"
echo -e "\n---- Doing on domain1 ----"
cd /etc/nginx/sites-available
echo "server {" >> $DOMAIN1
echo "listen 80;" >> $DOMAIN1
echo "server_name www.$DOMAIN1;" >> $DOMAIN1
echo "return 301 \$scheme://$DOMAIN1\$request_uri;" >> $DOMAIN1
echo "}" >> $DOMAIN1
sed -i "/server_name _;/c\server_name $DOMAIN1;" $DOMAIN1
sudo service nginx restart
echo -e "\n---- Enable the domains ngix file from available to enable ----"
sudo ln -s /etc/nginx/sites-available/$DOMAIN1 /etc/nginx/sites-enabled/$DOMAIN1
nginx -t
sudo service nginx restart
echo -e "\n---- EVERYTHING COMPLETED!!! ----"
echo -e "\n---- Both domains: ----"
echo -e "\n---- will push www to non www; ----"
echo -e "\n---- push to https ssl ----"
echo -e "\n---- use default website port 80, so no need to put port number 8069 at the end for odoo ----"
echo -e "\n---- Gooooood Luck to you!!! ----"
#!/bin/bash
# This script is to install odoo 12 Community Edition, setup 1 domain on same server
# www to non www redirect, odoo port 8069 to port 80
# Setup nginx, odoo-server.conf for dbfilter = %d for multiple domains on 1 server
# make sure each domain has it's own database domainname_com_au
# Make sure you make a STRONG PASSWORD for Master Password for your databases
# In below script, CHANGE to your domain name all lowercase eg DOMAIN1=yourdomainname.com
# odoo-server.conf is found at /etc/odoo-server.conf
# run these commands below with root user, you can disable root user after you're done
# nano odoongixmultinonw.sh
# Copy everything in this script and paste it in, save file and exit
# chmod +x odoongixmultinonw.sh
# ./odoongixmultinonw.sh
echo -e "\n---- Updating system and installing odoo requirements ----"
sudo apt update && sudo apt upgrade -y
sudo apt install git python3-pip build-essential wget python3-dev python3-venv python3-wheel libxslt-dev libzip-dev libldap2-dev libsasl2-dev python3-setuptools node-less -y
wget https://builds.wkhtmltopdf.org/0.12.1.3/wkhtmltox_0.12.1.3-1~bionic_amd64.deb
sudo apt install ./wkhtmltox_0.12.1.3-1~bionic_amd64.deb -y
echo -e "\n---- Installing odoo 12 community edition via clone ----"
# source go to https://github.com/Yenthe666/InstallScript
sudo wget https://raw.githubusercontent.com/Yenthe666/InstallScript/12.0/odoo_install.sh
sudo chmod +x odoo_install.sh
sudo ./odoo_install.sh
#!/bin/bash
# This script is part 3. Run part 1/3 first, then run script 2/3, and this run this 3/3 IF you have more than 1 domain name
# change value of DOMAIN1 to your new domain name
# nano extradomain.sh
# Copy everything in this script and paste it in, save file and exit
# chmod +x extradomain.sh
# ./extradomain.sh
DOMAIN1=thuani.com
echo -e "\n---- Copy template nginx file to your domain name ----"
cd /etc/nginx/sites-available
sudo cp template $DOMAIN1
cd /etc/nginx/sites-enabled
echo -e "\n---- Create template nginx file called template ----"
cd /etc/nginx/sites-available
sudo cp template $DOMAIN1
echo -e "\n---- Setting up redirect www to non www and fixing up server name----"
echo -e "\n---- Doing on domain1 ----"
cd /etc/nginx/sites-available
echo "server {" >> $DOMAIN1
echo "listen 80;" >> $DOMAIN1
echo "server_name www.$DOMAIN1;" >> $DOMAIN1
echo "return 301 \$scheme://$DOMAIN1\$request_uri;" >> $DOMAIN1
echo "}" >> $DOMAIN1
sed -i "/server_name _;/c\server_name $DOMAIN1;" $DOMAIN1
sudo service nginx restart
echo -e "\n---- Enable the domains ngix file from available to enable ----"
sudo ln -s /etc/nginx/sites-available/$DOMAIN1 /etc/nginx/sites-enabled/$DOMAIN1
nginx -t
sudo service nginx restart
echo -e "\n---- EVERYTHING COMPLETED!!! ----"
echo -e "\n---- will push www to non www; ----"
echo -e "\n---- use default website port 80, so no need to put port number 8069 at the end for odoo ----"
echo -e "\n---- Gooooood Luck to you!!! ----"
#!/bin/bash
# This script is part 2. Run part 1/2 first, then run this script 2/2
# install lets encrypt
# nano odoongixmultinonw2.sh
# Copy everything in this script and paste it in, save file and exit
# chmod +x odoongixmultinonw2.sh
# ./odoongixmultinonw2.sh
DOMAIN1=thuani.com
ODOOCFOLDER=/etc
ODOOCFILE=odoo-server.conf
echo -e "\n---- Update odoo conf file for mutliple database ----"
cd $ODOOCFOLDER
# echo "db_host = False" >> $ODOOCFILE
# echo "db_port = False" >> $ODOOCFILE
# echo "db_user = odoo" >> $ODOOCFILE
echo "dbfilter = %d" >> $ODOOCFILE
# sudo sed -i 's/dbfilter = /dbfilter = ^%h\$/g' $ODOOCFILE
sudo service odoo-server restart
echo -e "\n---- apt-get update and upgrade ----"
cd
sudo apt-get update
sudo apt-get upgrade -y
echo -e "\n---- Install nginx, and set up ----"
sudo apt install nginx -y
echo -e "\n---- Setting up basic firewall Nginx Full and OpenSSH ----"
sudo ufw enable
sudo ufw allow 'Nginx Full'
sudo ufw allow 'OpenSSH'
echo -e "\n---- Setting up nginx conf for your first domain ----"
cd /etc/nginx/sites-available
sudo sed -i '$ d' default
sudo sed -i '$ d' default
sudo sed -i '$ d' default
sudo sed -i 's|# First attempt to serve request as file, then|proxy_pass http://localhost:8069;|g' default
sudo sed -i 's|# as directory, then fall back to displaying a 404.|proxy_http_version 1.1;|g' default
sudo sed -i 's|try_files $uri $uri/ =404;|proxy_set_header Upgrade $http_upgrade;|g' default
sudo sed -i "/proxy_set_header Upgrade \$http_upgrade;/a proxy_set_header Connection 'upgrade';" default
sudo sed -i "/proxy_set_header Connection 'upgrade';/a proxy_set_header Host \$host;" default
sudo sed -i "/proxy_set_header Host \$host;/a proxy_cache_bypass \$http_upgrade;" default
echo -e "\n---- Removing default_server in default nginx file----"
cd /etc/nginx/sites-available
sudo sed -i 's/listen 80 default_server;/listen 80;/g' default
sudo sed -i "s|listen \[::\]:80 default_server;|listen \[::\]:80;|g" default
echo -e "\n---- Rename default nginx file to your domain name and delete enabled default file ----"
cd /etc/nginx/sites-available
sudo cp default $DOMAIN1
cd /etc/nginx/sites-enabled
echo -e "\n---- Create template nginx file called template ----"
cd /etc/nginx/sites-available
sudo cp $DOMAIN1 template
echo -e "\n---- Setting up redirect www to non www and fixing up server name----"
echo -e "\n---- Doing on domain1 ----"
cd /etc/nginx/sites-available
echo "server {" >> $DOMAIN1
echo "listen 80;" >> $DOMAIN1
echo "server_name www.$DOMAIN1;" >> $DOMAIN1
echo "return 301 \$scheme://$DOMAIN1\$request_uri;" >> $DOMAIN1
echo "}" >> $DOMAIN1
sed -i "/server_name _;/c\server_name $DOMAIN1;" $DOMAIN1
sudo service nginx restart
echo -e "\n---- Enable the domains ngix file from available to enable ----"
sudo ln -s /etc/nginx/sites-available/$DOMAIN1 /etc/nginx/sites-enabled/$DOMAIN1
nginx -t
sudo service nginx restart
echo -e "\n---- Installing Lets Encrypt only ----"
sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get install software-properties-common -y
sudo add-apt-repository ppa:certbot/certbot
sudo apt-get update
apt install python-certbot-nginx -y
sudo apt-get install software-properties-common python-software-properties
apt-get install python-certbot-nginx -y
sudo nginx -t
systemctl reload nginx.service
echo -e "\n---- EVERYTHING COMPLETED!!! ----"
echo -e "\n---- Both domains: ----"
echo -e "\n---- will push www to non www; ----"
echo -e "\n---- push to https ssl ----"
echo -e "\n---- use default website port 80, so no need to put port number 8069 at the end for odoo ----"
echo -e "\n---- Gooooood Luck to you!!! ----"
#!/bin/bash
# This script is to install lets encrypt SSL to your domain
# nano letsencryptssl.sh
# Copy everything in this script and paste it in, save file and exit
# chmod +x letsencryptssl.sh
# ./letsencryptssl.sh
# (when script is running, press enter to continue, put your important email for ssl renewal notices, 2 for redirect to non www)
DOMAIN1=thuani.com
ODOOCFOLDER=/etc
ODOOCFILE=odoo-server.conf
echo -e "\n---- Setting up SSL on domain2 ----"
certbot --nginx -d $DOMAIN1
sudo nginx -t
systemctl reload nginx.service
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment