nginx.sh 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #!/bin/sh
  2. #move to script directory so all relative paths work
  3. cd "$(dirname "$0")"
  4. #includes
  5. . ./config.sh
  6. . ./colors.sh
  7. . ./environment.sh
  8. #send a message
  9. verbose "Installing the web server"
  10. #change the version of php for arm
  11. if [ ."$cpu_architecture" = ."arm" ]; then
  12. #set the version of php
  13. if [ ."$os_codename" = ."bullseye" ]; then
  14. php_version=7.4
  15. fi
  16. fi
  17. #set the version of php
  18. #if [ ."$os_codename" = ."bullseye" ]; then
  19. # php_version=7.4
  20. #fi
  21. if [ ."$os_codename" = ."buster" ]; then
  22. php_version=7.3
  23. fi
  24. if [ ."$os_codename" = ."stretch" ]; then
  25. php_version=7.1
  26. fi
  27. if [ ."$os_codename" = ."jessie" ]; then
  28. php_version=7.1
  29. fi
  30. #enable fusionpbx nginx config
  31. cp nginx/fusionpbx /etc/nginx/sites-available/fusionpbx
  32. #prepare socket name
  33. if [ ."$php_version" = ."5.6" ]; then
  34. sed -i /etc/nginx/sites-available/fusionpbx -e 's#unix:.*;#unix:/var/run/php5-fpm.sock;#g'
  35. fi
  36. if [ ."$php_version" = ."7.0" ]; then
  37. sed -i /etc/nginx/sites-available/fusionpbx -e 's#unix:.*;#unix:/var/run/php/php7.0-fpm.sock;#g'
  38. fi
  39. if [ ."$php_version" = ."7.1" ]; then
  40. sed -i /etc/nginx/sites-available/fusionpbx -e 's#unix:.*;#unix:/var/run/php/php7.1-fpm.sock;#g'
  41. fi
  42. if [ ."$php_version" = ."7.2" ]; then
  43. sed -i /etc/nginx/sites-available/fusionpbx -e 's#unix:.*;#unix:/var/run/php/php7.2-fpm.sock;#g'
  44. fi
  45. if [ ."$php_version" = ."7.3" ]; then
  46. sed -i /etc/nginx/sites-available/fusionpbx -e 's#unix:.*;#unix:/var/run/php/php7.3-fpm.sock;#g'
  47. fi
  48. if [ ."$php_version" = ."7.4" ]; then
  49. sed -i /etc/nginx/sites-available/fusionpbx -e 's#unix:.*;#unix:/var/run/php/php7.4-fpm.sock;#g'
  50. fi
  51. if [ ."$php_version" = ."8.1" ]; then
  52. sed -i /etc/nginx/sites-available/fusionpbx -e 's#unix:.*;#unix:/var/run/php/php8.1-fpm.sock;#g'
  53. fi
  54. ln -s /etc/nginx/sites-available/fusionpbx /etc/nginx/sites-enabled/fusionpbx
  55. #self signed certificate
  56. ln -s /etc/ssl/private/ssl-cert-snakeoil.key /etc/ssl/private/nginx.key
  57. ln -s /etc/ssl/certs/ssl-cert-snakeoil.pem /etc/ssl/certs/nginx.crt
  58. #remove the default site
  59. rm /etc/nginx/sites-enabled/default
  60. #update config if LetsEncrypt folder is unwanted
  61. # if [ .$letsencrypt_folder = .false ]; then
  62. # sed -i '151,155d' /etc/nginx/sites-available/fusionpbx
  63. # fi
  64. #add the letsencrypt directory
  65. if [ .$letsencrypt_folder = .true ]; then
  66. mkdir -p /var/www/letsencrypt/
  67. fi
  68. #flush systemd cache
  69. systemctl daemon-reload
  70. #restart nginx
  71. service nginx restart