Hi so I am trying to deploy my portfolio to Ubuntu Server 16.04 but I keep getting internal server error.
To walk through what i have done i created the instance and changed the HTTP and HTTPs security settings to anywhere.
After that i launched the instance then running these commands
ubuntu@ip-172-31-41-27:~ sudo apt-get update
ubuntu@ip-172-31-41-27:~$ sudo apt-get install python-pip python-dev
nginx git
ubuntu@ip-172-31-41-27:~$ sudo apt-get update
ubuntu@ip-172-31-41-27:~$ sudo pip install virtualenv
ubuntu@ip-172-31-41-27:~/portfolio$ virtualenv venv --python=python3
ubuntu@ip-172-31-41-27:~/portfolio$ source venv/bin/activate
(venv)ubuntu@ip-172-31-41-27:~/portfolio$ pip install -r
requirements.txt
(venv) ubuntu@ip-172-31-41-27:~/portfolio$ pip install django bcrypt
django-extensions
(venv) ubuntu@ip-172-31-41-27:~/portfolio$ pip install gunicorn
i edited the settings.py
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False
ALLOWED_HOSTS = ['52.14.89.55']
STATIC_ROOT = os.path.join(BASE_DIR, "static/")
then run,
(venv) ubuntu@ip-172-31-41-27:~/portfolio$ python manage.py
collectstatic
followed by,
ubuntu@ip-172-31-41-27:~/portfolio$ sudo vim
/etc/systemd/system/gunicorn.service
where I add
[Unit]
Description=gunicorn daemon
After=network.target
[Service]
User=ubuntu
Group=www-data
WorkingDirectory=/home/ubuntu/portfolio
ExecStart=/home/ubuntu/portfolio/venv/bin/gunicorn --workers 3 --bind
unix:/home/ubuntu/portfolio/portfolio.sock portfolio.wsgi:application
[Install]
WantedBy=multi-user.target
followed by a gunicorn reboot
ubuntu@ip-172-31-41-27:~/portfolio$ sudo systemctl daemon-reload
ubuntu@ip-172-31-41-27:~/portfolio$ sudo systemctl start gunicorn
ubuntu@ip-172-31-41-27:~/portfolio$ sudo systemctl enable gunicorn
finally,
ubuntu@54.162.31.253:~$ sudo vim /etc/nginx/sites-
available/portfolio
adding
server {
listen 80;
server_name 52.14.89.55;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
root /home/ubuntu/portfolio;
}
location / {
include proxy_params;
proxy_pass http://unix:/home/ubuntu/portfolio/portfolio.sock;
}
}
creating the link
ubuntu@ip-172-31-41-27:/etc/nginx/sites-enabled$ sudo ln -s
/etc/nginx/sites-available/portfolio /etc/nginx/sites-enabled
ubuntu@ip-172-31-41-27:/etc/nginx/sites-enabled$ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
deleting the default
then restarting
ubuntu@ip-172-31-41-27:/etc/nginx/sites-enabled$ sudo service nginx
restart
EDIT**
I changed the following codes to match exactly what I have done.