You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Open a new terminal or exit the virtual environment# Install nginx
sudo apt-get install nginx
# Configure nginxcd /etc/nginx/sites-available/
sudo touch eospace_nginx.conf
sudo vim eospace_nginx.conf
# Modify eospace_nginx.conf as follows:
# the upstream component nginx needs to connect toupstream django {# server unix:///path/to/your/mysite/mysite.sock; # for a file socketserver 127.0.0.1:8001; # for a web port socket (we'll use this first)}# configuration of the serverserver {# the port your site will be served onlisten 80;# the domain name it will serve forserver_name localhost; charset utf-8;# max upload sizeclient_max_body_size 75M; # adjust to taste# Django medialocation /media {alias /home/ubuntu/eo_space/media; **# Change this to eo_space project root directory + /media**}location /static {alias /home/ubuntu/eo_space/static; **# Change this to eo_space project root directory + /static**# Finally, send all non-media requests to the Django server.location / {uwsgi_pass django;include uwsgi_params; # the uwsgi_params file you installed}}
# Save eospace_nginx.conf and create a symbolic link for it
sudo ln -s /etc/nginx/sites-available/eospace_nginx.conf /etc/nginx/sites-enabled
cd .. # Return to the nginx configuration directory
sudo vim nginx.conf
# Modify nginx.conf as follows:
user ubuntu;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 768;
}
http {
sendfile on;
tcp_nopush on;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;# Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
gzip on;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
# Create or modify the uwsgi_params file in this directory:
# Return to the eo_space project directory, activate the virtual environmentcd /home/ubuntu/eo_space
source venv/bin/activate
# Install uwsgi
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple uwsgi
# Create a new uwsgi.ini file, and edit its content as follows:
[uwsgi]
chdir = /home/ubuntu/eo_space # Project root directorymodule = eo_space.wsgi:applicationsocket = :8001master = truebuffer-size = 30000vacuum = truedaemonize = /home/ubuntu/eo_space/uwsgi.log # Modify according to the project root directorypidfile = /home/ubuntu/eo_space/uwsgi.pid # Modify according to the project root directoryvirtualenv=/home/ubuntu/eo_space/venv # Modify according to the project root directorydisable-logging = true
sudo nginx -t # You can check if the nginx configuration syntax is correct
sudo service nginx start
uwsgi --ini uwsgi.ini
# Use IP+/ssrpg/SLSentiment as the URL to check if it works
Debug
# If it didn't work:cd /home/ubuntu/eo_space/eo_space
vim settings.py
# In settings.py, set ALLOWED_HOSTS=["*"] or change it to your local IP# Rerun the project:
sudo service nginx restart
uwsgi --reload uwsgi.pid
# If it still didn't work:# Check the uwsgi.log in the project root directory# Check the nginx error log located at /var/log/nginx/error.log# Edit settings.py, add the following code to enable Django logging for further inspection: