By nicooda
was following this page to set up uwsgi https://www.digitalocean.com/community/tutorials/how-to-serve-django-applications-with-uwsgi-and-nginx-on-ubuntu-16-04
completed tutorial, and after I try to drag and drop my project and modified all url and allow host and sets Default to false. The server keeps showing django default page instead of my own project.
I tried to hit ip.address.name/contact ip.address.name/about django looks for admin/ only
setting.py# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False
ALLOWED_HOSTS = ['67.205.182.29', 'kai-peng.net', 'www.kai-peng.net']
# Application definition
INSTALLED_APPS = [
'personal',
'contact',
'posts',
'widget_tweaks',
'django_summernote',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'firstsite.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates'),],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'firstsite.wsgi.application'
# Database
# https://docs.djangoproject.com/en/2.0/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
# Password validation
# https://docs.djangoproject.com/en/2.0/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/2.0/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'EST'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.0/howto/static-files/
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static/')
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media/')
# sendmail setting
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
DEFAULT_FROM_EMAIL = 'kai.peng@uconn.edu'
EMAIL_HOST_USER = 'kai.peng@uconn.edu'
EMAIL_HOST_PASSWORD = ''
EMAIL_USE_TLS = False
EMAIL_PORT = "1025"
EMAIL_HOST = "smtp.mail.com"
from django.conf import settings
from django.conf.urls.static import static
from django.urls import include, path
from django.contrib import admin
urlpatterns = [
path('admin/', admin.site.urls),
path('', include('personal.urls')),
path('contact', include('contact.urls')),
path('posts/', include('posts.urls')),
path('summernote/', include('django_summernote.urls')),
]
if settings.DEBUG:
urlpatterns = urlpatterns + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
server {
listen 80;
listen [::]:80;
server_name 67.205.182.29 kai-peng.net www.kai-peng.net;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
root /home/kai/firstsite/;
}
location /media/ {
root /home/kai/firstsite/;
}
location / {
include uwsgi_params;
uwsgi_pass unix:/run/uwsgi/firstsite.sock;
}
}
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hi there,
In case anyone comes across this in the future, as you are able to only see the default Django page, it sounds like you might just have to restart the uwsgi service:
sudo systemctl restart uwsgi
Or if you are using Gunicorn: systemctl restart gunicorn:
Best,
Bobby
It’s possible that uWSGI is still serving the default Django project instead of your custom one.
Run the following command to restart uWSGI and ensure it loads the correct project:
sudo systemctl restart uwsgi
Make sure your firstsite.ini file correctly points to your Django project’s wsgi.py file.
Example of a valid /etc/uwsgi/sites/firstsite.ini:
[uwsgi]
project = firstsite
base = /home/kai
chdir = %(base)/%(project)
home = %(base)/venv
module = firstsite.wsgi:application
socket = /run/uwsgi/%(project).sock
chmod-socket = 664
vacuum = true
master = true
processes = 5
daemonize = /var/log/uwsgi/%(project).log
Make sure chdir points to your actual Django project folder!
If restarting uWSGI didn’t help, check its log for errors:
sudo journalctl -u uwsgi --no-pager | tail -50
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.