# Dependencies echo " yum -y update && yum -y upgrade yum -y install epel-release yum -y install vim nano gcc wget nginx libsqlite3x-devel.x86_64 postgresql-server postgresql-devel postgresql-contrib bzip2-devel zlib-devel libffi-devel openssl-devel policycoreutils-python.x86_64 0:2.5-22.el7 firewall-cmd --zone=public --add-port=80/tcp --permanent firewall-cmd --zone=public --add-port=443/tcp --permanent firewall-cmd --reload semanage permissive -a httpd_t " > dependsetup.sh # Python echo " wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tar.xz tar xf Python-3.7.0.tar.xz cd Python-3.7.0 ./configure --prefix /usr/src/python37 make make altinstall /usr/src/python37/bin/python3.7 -m pip install --upgrade pip /usr/src/python37/bin/python3.7 -m pip install virtualenv cd .. rm Python-3.7.0.tar.xz " > pythonsetup.sh # Django echo " mkdir /home/centos/mysite cd /home/centos/ /usr/src/python37/bin/python3.7 -m virtualenv mysite/venv source mysite/venv/bin/activate pip install django gunicorn psycopg2-binary cd mysite django-admin startproject mysite cd /home/centos/ sed -i 's/ALLOWED_HOSTS = \[\]/ALLOWED_HOSTS = \[\"centos.duco.net\"\]/' mysite/mysite/mysite/settings.py echo \"STATIC_ROOT = os.path.join(BASE_DIR, 'static')\" >> mysite/mysite/mysite/settings.py python mysite/mysite/manage.py collectstatic python mysite/mysite/manage.py makemigrations python mysite/mysite/manage.py migrate deactivate chown -R centos:centos mysite cd /root/" > djangosetup.sh # Gunicorn echo " echo \" [Unit] Description=gunicorn daemon After=network.target [Service] User=centos Group=nginx WorkingDirectory=/home/centos/mysite/mysite ExecStart=/home/centos/mysite/venv/bin/gunicorn --workers 3 --bind unix:/home/centos/mysite/mysite.sock mysite.wsgi:application [Install] WantedBy=multi-user.target\" > /etc/systemd/system/gunicorn.service systemctl start gunicorn systemctl status gunicorn" > gunicornsetup.sh # Nginx echo " echo \" server { listen 80; server_name centos.duco.net; location = /favicon.ico { access_log off; log_not_found off; } location /static/ { root /home/centos/mysite/mysite; } location / { proxy_set_header Host \\\\\$http_host; proxy_set_header X-Real-IP \\\\\$remote_addr; proxy_set_header X-Forwarded-For \\\\\$proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto \\\\\$scheme; proxy_pass http://unix:/home/centos/mysite/mysite.sock; } }\" > /etc/nginx/conf.d/mysite.conf sed -i 's/user nginx/user centos nginx/' /etc/nginx/nginx.conf systemctl restart nginx systemctl status nginx\" > nginxsetup.sh # Permissions chmod 700 dependsetup.sh chmod 700 pythonsetup.sh chmod 700 djangosetup.sh chmod 700 gunicornsetup.sh chmod 700 nginxsetup.sh " > master.sh sh dependsetup.sh sh pythonsetup.sh sh djangosetup.sh sh gunicornsetup.sh sh nginxsetup.sh