Skip to content

Instantly share code, notes, and snippets.

@hatamiarash7
Last active June 9, 2022 03:23
Show Gist options
  • Save hatamiarash7/55fb90800697cf1366d952b8f44ffbd6 to your computer and use it in GitHub Desktop.
Save hatamiarash7/55fb90800697cf1366d952b8f44ffbd6 to your computer and use it in GitHub Desktop.
CentOS + Apache + Django + WSGI + CWP + Python3.6
  • yum install python36u python36u-devel python36u-mod_wsgi
  • alias python='/usr/bin/python3.6'
  • curl -O https://bootstrap.pypa.io/get-pip.py
  • python get-pip.py
  • python -m pip install django mysqlclient
  • cp /etc/httpd/modules/mod_wsgi_python3.6.so /usr/local/apache/modules
  • create/clone/move project to another location ( not /home/user/public_html ) because there is not any access to top level directories
  • config apache
  • make & config database ( project/settings.py )
  • convert charset ALTER TABLE table CONVERT TO CHARACTER SET utf8;
  • python manage.py migrate
  • python manage.py createsuperuser
# vhost_start sub.domain.ir
<VirtualHost ip:8181>
ServerName sub.domain.ir
ServerAlias www.sub.domain.ir
ServerAdmin info@domain.ir
DocumentRoot /var/www/Site
UseCanonicalName On
ScriptAlias /cgi-bin/ /var/www/Site/cgi-bin/
# Custom settings are loaded below this line (if any exist)
# Include "/usr/local/apache/conf/userdata/arashhat/sub.domain.ir/*.conf
Alias /static/ "/var/www/Site/static/"
<Directory "/var/www/Site/static">
Require all granted
</Directory>
<Directory /var/www/Site/project_dir>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIDaemonProcess project_dir python-path=/var/www/Site:/usr/lib/python3.6/site-packages user=<cwp_username> threads=1 processes=32 maximum-requests=100 request-timeout=60
WSGIProcessGroup project_dir
WSGIApplicationGroup %{GLOBAL}
WSGIScriptAlias / /var/www/Site/project_dir/wsgi.py
ErrorLog /var/log/apache/django.log
</VirtualHost>
# vhost_end sub.domain.ir
#/usr/local/apache/conf/httpd.conf
LoadModule wsgi_module modules/mod_wsgi_python3.6.so
WSGISocketPrefix /var/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment