Advertisement
sm4rtn0bit4

Apache2 python_CGI auto configure

Aug 4th, 2017
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.77 KB | None | 0 0
  1. #!/bin/bash
  2. #Setup apache with python-cgi without extension, Remove test file  
  3. xterm -title "PACKAGES FOR APACHE2"  -e apt-get install --yes python3 apache2 python-scgi pycsw-wsgi figlet
  4. figlet Apache
  5. rm /var/www/html/index.html
  6. touch /var/www/html/hello
  7. chmod a+x /var/www/html/hello
  8. firewall-cmd --add-service=http --permanent
  9. firewall-cmd --reload
  10. /lib/systemd/systemd-sysv-install enable apache2
  11. systemctl enable apache2
  12. systemctl start apache2.service
  13. echo "127.0.0.1 deb.example.com" >> /etc/hosts
  14. echo "<virtualhost *:80>" >> /etc/apache2/apache2.conf
  15. echo "servername deb.example.com" >> /etc/apache2/apache2.conf
  16. echo "documentroot /var/www/html/" >> /etc/apache2/apache2.conf
  17. echo "</virtualhost>" >> /etc/apache2/apache2.conf
  18. echo "<directory /var/www/html/*>" >> /etc/apache2/apache2.conf
  19. echo "require all granted" >> /etc/apache2/apache2.conf
  20. echo "options ExecCGI" >> /etc/apache2/apache2.conf
  21. echo "options all" >> /etc/apache2/apache2.conf
  22. echo "sethandler cgi-script" >> /etc/apache2/apache2.conf
  23. echo "AllowOverride None" >> /etc/apache2/apache2.conf
  24. echo "addhandler cgi-script .py" >> /etc/apache2/apache2.conf
  25. echo "addhandler mod_python .py" >> /etc/apache2/apache2.conf
  26. echo "</directory>" >> /etc/apache2/apache2.conf
  27. echo "<FilesMatch "^[^\.]+$ ">" >> /etc/apache2/apache2.conf
  28. echo "SetHandler cgi-script" >> /etc/apache2/apache2.conf
  29. echo "</FilesMatch>" >> /etc/apache2/apache2.conf
  30. ################
  31.  
  32. echo "#!/usr/bin/python3" >> /var/www/html/hello
  33. echo "print('Content-type:text/html')" >> /var/www/html/hello
  34. echo "print()" >> /var/www/html/hello
  35. echo "print('<HTML><BODY>HELLO</BODY></HTML>')" >> /var/www/html/hello
  36. a2enmod cgi
  37. systemctl restart apache2.service
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement