├── README.md
└── install_odoo_ubuntu.sh
/README.md:
--------------------------------------------------------------------------------
1 | # Installation Script for Odoo Open Source
2 |
3 | This script will also give you the ability to define an xmlrpc_port in the .conf file that is generated under /etc/
4 | This script can be safely used in a multi-odoo code base server because the default Odoo port is changed BEFORE the Odoo is started.
5 |
6 | ## Installing Nginx
7 | If you set the parameter ```INSTALL_NGINX``` to ```True``` you should also configure workers. Without workers you will probably get connection loss issues. Look at [the deployment guide from Odoo](https://www.odoo.com/documentation/14.0/setup/deploy.html) on how to configure workers.
8 |
9 | ## Installation procedure
10 |
11 | ##### 1. Download the script:
12 | ```
13 | wget https://raw.githubusercontent.com/hrmuwanika/odoo/18.0/install_odoo_ubuntu.sh
14 | ```
15 | ##### 2. Modify the parameters as you wish.
16 | There are a few things you can configure, this is the most used list:
17 | ```OE_USER``` will be the username for the system user.
18 | ```GENERATE_RANDOM_PASSWORD``` if this is set to ```True``` the script will generate a random password, if set to ```False```we'll set the password that is configured in ```OE_SUPERADMIN```. By default the value is ```True``` and the script will generate a random and secure password.
19 | ```OE_PORT``` is the port where Odoo should run on, for example 8069.
20 | ```OE_VERSION``` is the Odoo version to install, for example ```14.0``` for Odoo V14.
21 | ```IS_ENTERPRISE``` will install the Enterprise version on top of ```18.0``` if you set it to ```True```, set it to ```False``` if you want the community version of Odoo 16.
22 | ```OE_SUPERADMIN``` is the master password for this Odoo installation.
23 | ```INSTALL_NGINX``` is set to ```True``` by default. Set this to ```False``` if you don't want to install Nginx.
24 | ```WEBSITE_NAME``` Set the website name here for nginx configuration
25 | ```ENABLE_SSL``` Set this to ```True``` to install [certbot](https://certbot.eff.org/lets-encrypt/ubuntufocal-nginx) and configure nginx with https using a free Let's Encrypted certificate
26 | ```ADMIN_EMAIL``` Email is needed to register for Let's Encrypt registration. Replace the default placeholder with an email of your organisation.
27 | ```INSTALL_NGINX``` and ```ENABLE_SSL``` must be set to ```True``` and the placeholder in ```ADMIN_EMAIL``` must be replaced with a valid email address for certbot installation
28 | _By enabling SSL though Let's Encrypt you agree to the following [policies](https://www.eff.org/code/privacy/policy)_
29 |
30 | #### 3. Make the script executable
31 | ```
32 | sudo chmod +x install_odoo_ubuntu.sh
33 | ```
34 | ##### 4. Execute the script:
35 | ```
36 | sudo ./install_odoo_ubuntu.sh
37 | ```
38 |
39 | The installation should take about 10 minutes to complete and then you will be able to access it from
40 | anywhere in the world by entering its ipaddress.
41 |
42 | For more information on hosting, upgrading to odoo enterprise, and changing your domain, contact me hrmuwanika@gmail.com
43 |
--------------------------------------------------------------------------------
/install_odoo_ubuntu.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | ################################################################################
4 | # Odoo 18 Installation Script for Ubuntu 24.04 (could be used for other version too)
5 | # Author: Henry Robert Muwanika
6 | #-------------------------------------------------------------------------------
7 | # This script will install Odoo on your Ubuntu server. It can install multiple Odoo instances
8 | # in one Ubuntu because of the different xmlrpc_ports
9 | #-------------------------------------------------------------------------------
10 | # crontab -e
11 | # 43 6 * * * certbot renew --post-hook "systemctl reload nginx"
12 | # Make a new file:
13 | # sudo nano install_odoo_ubuntu.sh
14 | # Place this content in it and then make the file executable:
15 | # sudo chmod +x install_odoo_ubuntu.sh
16 | # Execute the script to install Odoo:
17 | # ./install_odoo_ubuntu.sh
18 | ################################################################################
19 |
20 | OE_USER="odoo"
21 | OE_HOME="/opt/$OE_USER"
22 | OE_HOME_EXT="/opt/$OE_USER/${OE_USER}-server"
23 | # The default port where this Odoo instance will run under (provided you use the command -c in the terminal)
24 | # Set to true if you want to install it, false if you don't need it or have it already installed.
25 | INSTALL_WKHTMLTOPDF="True"
26 | # Set the default Odoo port (you still have to use -c /etc/odoo-server.conf for example to use this.)
27 | OE_PORT="8069"
28 | # Choose the Odoo version which you want to install. For example: 17.0, 16.0, 15.0 or 14.0. When using 'master' the master version will be installed.
29 | # IMPORTANT! This script contains extra libraries that are specifically needed for Odoo 14.0
30 | OE_VERSION="18.0"
31 | # Installs postgreSQL V16 instead of defaults (e.g V16 for Ubuntu 24.04) - this improves performance
32 | INSTALL_POSTGRESQL_SIXTEEN="True"
33 | # Set this to True if you want to install Nginx!
34 | INSTALL_NGINX="True"
35 | # Set the superadmin password - if GENERATE_RANDOM_PASSWORD is set to "True" we will automatically generate a random password, otherwise we use this one
36 | OE_SUPERADMIN="admin"
37 | # Set to "True" to generate a random password, "False" to use the variable in OE_SUPERADMIN
38 | GENERATE_RANDOM_PASSWORD="True"
39 | OE_CONFIG="${OE_USER}-server"
40 | # Set the website name
41 | WEBSITE_NAME="example.com"
42 | # Set the default Odoo longpolling port (you still have to use -c /etc/odoo-server.conf for example to use this.)
43 | LONGPOLLING_PORT="8072"
44 | # Set to "True" to install certbot and have ssl enabled, "False" to use http
45 | ENABLE_SSL="True"
46 | # Provide Email to register ssl certificate
47 | ADMIN_EMAIL="odoo@example.com"
48 |
49 | #--------------------------------------------------
50 | # Update and upgrade the system
51 | #--------------------------------------------------
52 | echo -e "=== Updating system packages ... ==="
53 | sudo apt update
54 | sudo apt upgrade -y
55 | sudo apt autoremove -y
56 |
57 | #----------------------------------------------------
58 | # Disabing password authentication
59 | #----------------------------------------------------
60 | echo "=== Disabling password authentication ... ==="
61 | sudo apt -y install openssh-server
62 | sudo sed -i 's/#ChallengeResponseAuthentication yes/ChallengeResponseAuthentication no/' /etc/ssh/sshd_config
63 | sudo sed -i 's/UsePAM yes/UsePAM no/' /etc/ssh/sshd_config
64 | sudo sed -i 's/#PasswordAuthentication yes/PasswordAuthentication no/' /etc/ssh/sshd_config
65 | sudo systemctl restart sshd
66 |
67 | #--------------------------------------------------
68 | # Setting up the timezones
69 | #--------------------------------------------------
70 | # set the correct timezone on ubuntu
71 | timedatectl set-timezone Africa/Kigali
72 | timedatectl
73 |
74 | #--------------------------------------------------
75 | # Installing PostgreSQL Server
76 | #--------------------------------------------------
77 | echo -e "=== Install and configure PostgreSQL ... ==="
78 | if [ $INSTALL_POSTGRESQL_SIXTEEN = "True" ]; then
79 | echo -e "=== Installing postgreSQL V16 due to the user it's choice ... ==="
80 | sudo apt -y install postgresql-16
81 | else
82 | echo -e "=== Installing the default postgreSQL version based on Linux version ... ==="
83 | sudo apt -y install postgresql postgresql-server-dev-all
84 | fi
85 |
86 | echo "=== Starting PostgreSQL service... ==="
87 | sudo systemctl start postgresql
88 | sudo systemctl enable postgresql
89 |
90 | echo -e "=== Creating the Odoo PostgreSQL User ... ==="
91 | sudo su - postgres -c "createuser -s $OE_USER" 2> /dev/null || true
92 |
93 | #--------------------------------------------------
94 | # Installing required packages
95 | #--------------------------------------------------
96 | echo "=== Installing required packages... ==="
97 | sudo apt install -y git wget python3-minimal python3-dev python3-pip python3-wheel libxml2-dev libxslt1-dev zlib1g-dev libsasl2-dev libldap2-dev build-essential \
98 | libssl-dev libffi-dev libmysqlclient-dev libjpeg-dev libpq-dev libjpeg8-dev liblcms2-dev libblas-dev libatlas-base-dev libzip-dev python3-setuptools node-less \
99 | python3-venv python3-cffi gdebi zlib1g-dev curl cython3 python3-openssl
100 |
101 | sudo pip3 install --upgrade pip --break-system-packages
102 | sudo pip3 install setuptools wheel --break-system-packages
103 |
104 | # Installing xfonts dependencies for wkhtmltopdf
105 | echo "=== Installing xfonts for wkhtmltopdf... ==="
106 | sudo apt -y install xfonts-75dpi xfonts-encodings xfonts-utils xfonts-base fontconfig
107 |
108 | # Install Node.js and npm
109 | echo "=== Installing Node.js and npm ... ==="
110 | sudo apt -y install nodejs npm
111 |
112 | sudo ln -s /usr/bin/nodejs /usr/bin/node
113 | sudo npm install -g less less-plugin-clean-css
114 |
115 | # Install rtlcss for RTL support
116 | echo "=== Installing rtlcss ... ==="
117 | sudo npm install -g rtlcss
118 |
119 | #--------------------------------------------------
120 | # Install Wkhtmltopdf if needed
121 | #--------------------------------------------------
122 | if [ $INSTALL_WKHTMLTOPDF = "True" ]; then
123 | echo "=== Install wkhtmltopdf and place shortcuts on correct place for Odoo 18 ... ==="
124 | sudo wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6.1-2/wkhtmltox_0.12.6.1-2.jammy_amd64.deb
125 | sudo dpkg -i wkhtmltox_0.12.6.1-2.jammy_amd64.deb
126 | sudo apt install -f
127 | sudo cp /usr/local/bin/wkhtmltoimage /usr/bin/wkhtmltoimage
128 | sudo cp /usr/local/bin/wkhtmltopdf /usr/bin/wkhtmltopdf
129 | else
130 | echo "Wkhtmltopdf isn't installed due to the choice of the user!"
131 | fi
132 |
133 | # Create Odoo system user
134 | echo "=== Create Odoo system user ==="
135 | sudo adduser --system --quiet --shell=/bin/bash --home=$OE_HOME --gecos 'Odoo' --group $OE_USER
136 |
137 | #The user should also be added to the sudo'ers group.
138 | sudo adduser $OE_USER sudo
139 |
140 | echo -e "=== Create Log directory ... ==="
141 | sudo mkdir /var/log/$OE_USER
142 | sudo chown -R $OE_USER:$OE_USER /var/log/$OE_USER
143 |
144 | #--------------------------------------------------
145 | # Install Odoo from source
146 | #--------------------------------------------------
147 | echo "=== Cloning Odoo 18 from GitHub ... ==="
148 | sudo git clone --depth 1 --branch $OE_VERSION https://www.github.com/odoo/odoo $OE_HOME_EXT/
149 | sudo pip3 install -r /$OE_HOME_EXT/requirements.txt --break-system-packages
150 |
151 | # Create custom addons directory
152 | echo "Creating custom addons directory..."
153 | sudo mkdir $OE_HOME/custom
154 | sudo mkdir $OE_HOME/custom/addons
155 |
156 | cd /usr/src/
157 | sudo git clone https://github.com/hrmuwanika/odooapps18.git
158 | cp -rf odooapps18/* $OE_HOME/custom/addons
159 |
160 | echo "Creating enterprise addons directory..."
161 | sudo mkdir $OE_HOME/enterprise
162 | sudo mkdir $OE_HOME/enterprise/addons
163 |
164 | echo "=== Setting permissions on home folder ==="
165 | sudo chown -R $OE_USER:$OE_USER $OE_HOME/
166 |
167 | # Create Odoo configuration file
168 | echo "=== Creating Odoo configuration file ... ==="
169 | sudo touch /etc/${OE_CONFIG}.conf
170 |
171 | # Generate admin password
172 | if [ $GENERATE_RANDOM_PASSWORD = "True" ]; then
173 | echo -e "\n========= Generating random admin password ==========="
174 | OE_SUPERADMIN=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 20 | head -n 1)
175 | fi
176 |
177 | sudo cat < /etc/${OE_CONFIG}.conf
178 | [options]
179 | admin_passwd = ${OE_SUPERADMIN}
180 | db_host = False
181 | db_port = False
182 | db_user = $OE_USER
183 | db_password = False
184 | logfile = /var/log/${OE_USER}/${OE_CONFIG}.log
185 | addons_path = ${OE_HOME_EXT}/addons, ${OE_HOME}/custom/addons, ${OE_HOME}/enterprise/addons
186 | http_port = ${OE_PORT}
187 | xmlrpc_port = ${OE_PORT}
188 | workers = 1
189 | list_db = True
190 | EOF
191 |
192 | sudo chown $OE_USER:$OE_USER /etc/${OE_CONFIG}.conf
193 | sudo chmod 640 /etc/${OE_CONFIG}.conf
194 |
195 | #--------------------------------------------------
196 | # Creating systemd service file for Odoo
197 | #--------------------------------------------------
198 | echo "=== Creating systemd service file... ==="
199 | sudo cat < /lib/systemd/system/$OE_USER.service
200 | [Unit]
201 | Description=Odoo Open Source ERP and CRM
202 | After=network.target
203 |
204 | [Service]
205 | Type=simple
206 | User=$OE_USER
207 | Group=$OE_USER
208 | ExecStart=$OE_HOME_EXT/odoo-bin --config /etc/${OE_CONFIG}.conf --logfile /var/log/${OE_USER}/${OE_CONFIG}.log
209 | KillMode=mixed
210 |
211 | [Install]
212 | WantedBy=multi-user.target
213 |
214 | EOF
215 |
216 | sudo chmod 755 /lib/systemd/system/$OE_USER.service
217 | sudo chown root: /lib/systemd/system/$OE_USER.service
218 |
219 | # Reload systemd and start Odoo service
220 | echo "=== Reloading systemd daemon ... ==="
221 | sudo systemctl daemon-reload
222 |
223 | sudo systemctl enable --now $OE_USER.service
224 | sudo systemctl start $OE_USER.service
225 |
226 | #--------------------------------------------------
227 | # Install Nginx if needed
228 | #--------------------------------------------------
229 | echo "==== Installing nginx ... ===="
230 | if [ $INSTALL_NGINX = "True" ]; then
231 | sudo apt install -y nginx
232 | sudo systemctl enable nginx
233 |
234 | echo "==== Configuring nginx ... ===="
235 | cat < /etc/nginx/sites-available/$OE_USER
236 |
237 | # odoo server
238 | upstream $OE_USER {
239 | server 127.0.0.1:$OE_PORT;
240 | }
241 |
242 | upstream ${OE_USER}chat {
243 | server 127.0.0.1:$LONGPOLLING_PORT;
244 | }
245 |
246 | server {
247 | listen 80;
248 | server_name $WEBSITE_NAME;
249 |
250 | # Specifies the maximum accepted body size of a client request,
251 | # as indicated by the request header Content-Length.
252 | client_max_body_size 500M;
253 |
254 | # log
255 | access_log /var/log/nginx/$OE_USER-access.log;
256 | error_log /var/log/nginx/$OE_USER-error.log;
257 |
258 | # add ssl specific settings
259 | keepalive_timeout 90;
260 |
261 | # increase proxy buffer to handle some Odoo web requests
262 | proxy_buffers 16 64k;
263 | proxy_buffer_size 128k;
264 |
265 | proxy_read_timeout 720s;
266 | proxy_connect_timeout 720s;
267 | proxy_send_timeout 720s;
268 |
269 | # Add Headers for odoo proxy mode
270 | proxy_set_header Host \$host;
271 | proxy_set_header X-Forwarded-Host \$host;
272 | proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
273 | proxy_set_header X-Forwarded-Proto \$scheme;
274 | proxy_set_header X-Real-IP \$remote_addr;
275 |
276 | # Redirect requests to odoo backend server
277 | location / {
278 | proxy_redirect off;
279 | proxy_pass http://$OE_USER;
280 | }
281 |
282 | # Redirect longpoll requests to odoo longpolling port
283 | location /longpolling {
284 | proxy_pass http://${OE_USER}chat;
285 | }
286 |
287 | # cache some static data in memory for 90mins
288 | # under heavy load this should relieve stress on the Odoo web interface a bit.
289 | location ~* /web/static/ {
290 | proxy_cache_valid 200 90m;
291 | proxy_buffering on;
292 | expires 864000;
293 | proxy_pass http://$OE_USER;
294 | }
295 |
296 | # common gzip
297 | gzip_types text/css text/less text/plain text/xml application/xml application/json application/javascript;
298 | gzip on;
299 | }
300 |
301 | EOF
302 |
303 | sudo mv ~/odoo /etc/nginx/sites-available/
304 | sudo ln -s /etc/nginx/sites-available/$OE_USER /etc/nginx/sites-enabled/$OE_USER
305 | sudo rm /etc/nginx/sites-enabled/default
306 | sudo rm /etc/nginx/sites-available/default
307 |
308 | sudo systemctl reload nginx
309 | sudo su root -c "printf 'proxy_mode = True\n' >> /etc/${OE_CONFIG}.conf"
310 | echo "Done! The Nginx server is up and running. Configuration can be found at /etc/nginx/sites-available/$OE_USER"
311 | else
312 | echo "===== Nginx isn't installed due to choice of the user! ========"
313 | fi
314 |
315 | #--------------------------------------------------
316 | # Enable ssl with certbot
317 | #--------------------------------------------------
318 | echo "==== Installing certbot certificate ... ===="
319 | if [ $INSTALL_NGINX = "True" ] && [ $ENABLE_SSL = "True" ] && [ $WEBSITE_NAME != "example.com" ];then
320 | sudo apt-get remove certbot
321 | sudo snap install core
322 | sudo snap refresh core
323 | sudo snap install --classic certbot
324 | sudo ln -s /snap/bin/certbot /usr/bin/certbot
325 | sudo certbot --nginx -d $WEBSITE_NAME
326 | sudo systemctl reload nginx
327 | echo "============ SSL/HTTPS is enabled! ==========="
328 | else
329 | echo "==== SSL/HTTPS isn't enabled due to choice of the user or because of a misconfiguration! ======"
330 | fi
331 |
332 | #--------------------------------------------------
333 | # UFW Firewall
334 | #--------------------------------------------------
335 | echo "=== Installation of UFW firewall ... ==="
336 | sudo apt install -y ufw
337 |
338 | sudo ufw allow 'Nginx Full'
339 | sudo ufw allow 'Nginx HTTP'
340 | sudo ufw allow 'Nginx HTTPS'
341 | sudo ufw allow 22/tcp
342 | sudo ufw allow 6010/tcp
343 | #sudo ufw allow 5432//tcp
344 | sudo ufw allow 8069/tcp
345 | sudo ufw allow 8072/tcp
346 | sudo ufw enable -y
347 |
348 | sudo apt install -y fail2ban
349 | sudo systemctl start fail2ban
350 | sudo systemctl enable fail2ban
351 |
352 | clear
353 |
354 | # Final message
355 | # Check Odoo service status
356 | echo "Checking Odoo service status..."
357 | sudo systemctl status $OE_USER
358 | echo "========================================================================"
359 | echo "Done! The odoo server is up and running. Specifications:"
360 | echo "Port: $OE_PORT"
361 | echo "User service: $OE_USER"
362 | echo "User PostgreSQL: $OE_USER"
363 | echo "Code location: $OE_USER"
364 | echo "Addons folder: $OE_USER/$OE_CONFIG/addons/"
365 | echo "Password superadmin (database): $OE_SUPERADMIN"
366 | echo "start odoo service: sudo systemctl start $OE_USER"
367 | echo "stop odoo service: sudo systemctl stop $OE_USER"
368 | echo "Restart Odoo service: sudo systemctl restart $OE_USER"
369 | echo "Odoo installation is complete. Access it at http://your-IP-address:8069"
370 | echo "========================================================================"
371 |
372 | if [ $INSTALL_NGINX = "True" ]; then
373 | echo "Nginx configuration file: /etc/nginx/sites-available/$OE_USER"
374 | fi
375 |
376 |
377 |
--------------------------------------------------------------------------------