1👍
you are not given proper explanation about your error.
required packages:
- Apache2
- libapache2-mod-wsgi
- Django
Create Empty Project
- cd /var/www
- sudo virtualenv foldername
- cd foldername
- sudo django-admin.py startproject projectname
- cd projectname
- sudo nano projectname.wsgi
projectname.wsgi file
import os
import sys
sys.path.append('/var/www/foldername/projectname')
os.environ['DJANGO_SETTINGS_MODULE'] = 'projectname.settings'
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
- cd /etc/apache2/sites-available
- sudo nano projectname.conf
projectname.conf file
<VirtualHost *:80>
ServerName www.example.com
ServerAlias www.example.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/foldername/projectname
WSGIScriptAlias / /var/www/foldername/projectname/projectname.wsgi
Alias /static /var/www/foldername/static/static_only
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
sudo nano /etc/hosts
you need to add following line into hosts file
your_ip www.example.com
Goto your project location and run python manage.py collectstatic
now your local files copies are inside the static_only folder
may be you are getting “Attempt to write a readonly database ” error ,this permission issue so you need to run following command .
chown www-data:www-data /var/www/foldername
chown www-data:www-data /var/www/foldername/projectname/db.sqlite3
now type www.example.com on your browser
Source:stackexchange.com