From 9cdbeac9ba6d9f90340d5a92e6d8d64aa7126d7d Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Tue, 20 Jul 2021 02:56:14 -0400 Subject: [PATCH] [FIX] production installation documentation with proxy nginx --- Makefile | 5 +++++ doc/PRODUCTION.md | 21 +++++++++++++++++++-- doc/RELEASE.md | 4 ++++ env_var.sh | 2 +- script/install_daemon.sh | 3 +++ script/install_production.sh | 2 -- script/install_production_nginx.sh | 19 +++++++++++++------ 7 files changed, 45 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index 0e23508..1b841ad 100644 --- a/Makefile +++ b/Makefile @@ -64,6 +64,11 @@ install_dev: install_os: ./script/install_dev.sh +.PHONY: install_production +install_production: + ./script/install_dev.sh + ./script/install_production.sh + .PHONY: install_docker_debian install_docker_debian: ./script/ install_debian_10_prod_docker.sh diff --git a/doc/PRODUCTION.md b/doc/PRODUCTION.md index c5971a3..db6d770 100644 --- a/doc/PRODUCTION.md +++ b/doc/PRODUCTION.md @@ -10,14 +10,31 @@ cd ERPLibre ### 2. Modify the parameters Modify the file env_var.sh for production installation. +Enable nginx if you need a proxy with `EL_INSTALL_NGINX`. +Redirect your DNS to the proxy's ip and add your A and AAAA into `WL_WEBSITE_NAME` with space between. ### 3. Execute the script: + +#### With proxy nginx production, install certbot before for SSL +```bash +# Snap installation +# https://snapcraft.io/docs/installing-snap-on-debian +sudo apt install -y snapd +sudo snap install core +sudo snap refresh core + +# https://certbot.eff.org/lets-encrypt/debianbuster-nginx +# Cerbot +sudo snap install --classic certbot +sudo ln -s /snap/bin/certbot /usr/bin/certbot +``` + #### Ubuntu 18.04 server ```bash ./script/install_dev.sh ./script/install_production.sh ``` -A service is running by systemd. You can access it with the DNS name found in env_var.sh +A service is running by SystemD. You can access it with the DNS name found in env_var.sh #### Ubuntu 20.04 server Apply fix libpng12-0: https://www.linuxuprising.com/2018/05/fix-libpng12-0-missing-in-ubuntu-1804.html @@ -26,7 +43,7 @@ Apply fix libpng12-0: https://www.linuxuprising.com/2018/05/fix-libpng12-0-missi ./script/install_dev.sh ./script/install_production.sh ``` -A service is running by systemd, you can access with the DNS name found in env_var.sh +A service is running by SystemD, you can access with the DNS name found in env_var.sh ### 4. SSL: Generate a ssl certificate diff --git a/doc/RELEASE.md b/doc/RELEASE.md index faf8d47..69cc3d0 100644 --- a/doc/RELEASE.md +++ b/doc/RELEASE.md @@ -36,6 +36,10 @@ Run `make image_db_create_all`, this will generate image in directory `./image_d Run `make docker_build` to generate a docker. +### Test production Ubuntu environment + +Follow instruction into [PRODUCTION.md](./PRODUCTION.md). + ## Generate new prod and release Generate production manifest and freeze all repos versions. diff --git a/env_var.sh b/env_var.sh index 6d58466..25febf8 100755 --- a/env_var.sh +++ b/env_var.sh @@ -19,7 +19,7 @@ EL_MINIMAL_ADDONS="False" # Set this to True if you want to install Nginx! EL_INSTALL_NGINX="True" # Set the website name -EL_WEBSITE_NAME="" +EL_WEBSITE_NAME="localhost" EL_GITHUB_TOKEN="" EL_MANIFEST_PROD="./default.xml" EL_MANIFEST_DEV="./manifest/default.dev.xml" diff --git a/script/install_daemon.sh b/script/install_daemon.sh index 1255400..0b7b912 100755 --- a/script/install_daemon.sh +++ b/script/install_daemon.sh @@ -68,9 +68,12 @@ echo "User service: ${EL_USER}" echo "User PostgreSQL: ${EL_USER}" echo "Code location: ${EL_USER}" echo "Addons folder: ${EL_USER}/${EL_CONFIG}/addons/" +echo "SystemD file ERPLibre: /etc/systemd/system/${EL_CONFIG}.service" echo "Start ERPLibre service: sudo systemctl start ${EL_CONFIG}" echo "Stop ERPLibre service: sudo systemctl stop ${EL_CONFIG}" echo "Restart ERPLibre service: sudo systemctl restart ${EL_CONFIG}" +echo "Status ERPLibre service: sudo systemctl status ${EL_CONFIG}" +echo "Logs ERPLibre service: sudo journalctl -feu ${EL_CONFIG}" echo "-----------------------------------------------------------" echo -e "* Starting ERPLibre Service" diff --git a/script/install_production.sh b/script/install_production.sh index 3fb6eab..8f3d73e 100755 --- a/script/install_production.sh +++ b/script/install_production.sh @@ -2,8 +2,6 @@ . ./env_var.sh -./script/install_debian_dependency.sh - echo -e "\n---- Create ERPLIBRE system user ----" sudo adduser --system --quiet --shell=/bin/bash --home=/${EL_USER} --gecos 'ERPLIBRE' --group ${EL_USER} #The user should also be added to the sudo'ers group. diff --git a/script/install_production_nginx.sh b/script/install_production_nginx.sh index 84693ac..f38bcc8 100755 --- a/script/install_production_nginx.sh +++ b/script/install_production_nginx.sh @@ -2,12 +2,19 @@ . ./env_var.sh +TEMP_FILENAME_NGINX_AVAILABLE="localhost" +NEW_EL_WEBSITE_NAME="${EL_WEBSITE_NAME}" +if [[ -z "${EL_WEBSITE_NAME}" ]]; then + NEW_EL_WEBSITE_NAME=${TEMP_FILENAME_NGINX_AVAILABLE} +fi +TEMP_FILE_NGINX_AVAILABLE="/tmp/${TEMP_FILENAME_NGINX_AVAILABLE}" + #-------------------------------------------------- # Install Nginx if needed #-------------------------------------------------- if [ ${EL_INSTALL_NGINX} = "True" ]; then - echo -e "\n---- Installing and setting up Nginx ----" - cat < /tmp/nginx${EL_USER} + echo -e "\n---- Installing and setting up Nginx into ${TEMP_FILE_NGINX_AVAILABLE} ----" + cat <${TEMP_FILE_NGINX_AVAILABLE} upstream erplibre${EL_USER} { server 127.0.0.1:${EL_PORT}; } @@ -18,7 +25,7 @@ upstream erplibre${EL_USER}chat { server { listen 80; - server_name ${EL_WEBSITE_NAME}; + server_name ${NEW_EL_WEBSITE_NAME}; # Add Headers for erplibre proxy mode proxy_set_header X-Forwarded-Host \$host; @@ -80,11 +87,11 @@ server { } EOF - sudo mv -f /tmp/nginx${EL_USER} /etc/nginx/sites-available/${EL_WEBSITE_NAME} - sudo ln -fs /etc/nginx/sites-available/${EL_WEBSITE_NAME} /etc/nginx/sites-enabled/${EL_WEBSITE_NAME} + sudo mv -f ${TEMP_FILE_NGINX_AVAILABLE} /etc/nginx/sites-available/${NEW_EL_WEBSITE_NAME} + sudo ln -fs /etc/nginx/sites-available/${NEW_EL_WEBSITE_NAME} /etc/nginx/sites-enabled/${NEW_EL_WEBSITE_NAME} sudo rm -f /etc/nginx/sites-enabled/default /etc/nginx/sites-available/default sudo systemctl restart nginx - echo "Done! The Nginx server is up and running. Configuration can be found at /etc/nginx/sites-enabled/${EL_WEBSITE_NAME}" + echo "Done! The Nginx server is up and running. Configuration can be found at /etc/nginx/sites-enabled/${NEW_EL_WEBSITE_NAME}" echo "Run manually certbot : sudo certbot --nginx" else echo "Nginx isn't installed due to choice of the user!"