GithubHelp home page GithubHelp logo

protosite's Introduction

Simple nginx/django testing application

Development:

[Testing from Nginx]

Run website (static + dynamic) on localhost as specified in nginx.conf files

sudo nginx -t
sudo nginx -s reload
uwsgi --socket :8001 -b 10000 --module protosite.wsgi

will run on localhost:
-localhost/ff/
-localhost/js/main.js
-localhost/index.html
-localhost/

uwsgi_params file is necessary

currently reading from nginx.conf, not protosite_nginx.conf

[Testing from Django]

from web/protosite dir:

python manage.py collectstatic
# this will get files from STATICFILES_DIRS and put them in STATIC_ROOT, then serve when accessing STATIC_URL as the path

python manage.py runserver

Will run on localhost:8000/
-localhost:8000/static/index.html
-localhost:8000/static/js/main.js
-localhost:8000/ff

So, can run at same time as the nginx server

[Using nginx with the config file in protosite dir]

First, need to kill our existing nginx processes started with old config:

brew services stop nginx  # might not do anything? check up on it
sudo nginx -s stop

Start nginx with the config file in our protosite nginx config folder:

sudo nginx -c ~/Desktop/repos/web/nginx/protosite_nginx.conf

# restart uwsgi to listen on the port we set in protosite_nginx.conf:
sudo uwsgi --socket :8002 -b 10000 --module protosite.wsgi

Static & dynamic files will now serve on localhost

localhost/ff
localhost/
localhost/index.html

Now, can update & test nginx config as such:

sudo nginx -t -c ~/Desktop/repos/web/nginx/protosite_nginx.conf
sudo nginx -s reload -c ~/Desktop/repos/web/nginx/protosite_nginx.conf

Debug

[Nginx logs]

cat /usr/local/var/log/nginx/error.log

[Bad gateway error for dynamic files]

Static files will be served as long as nginx daemon is running; however dynamic files from django need the uwsgi daemon to run. Try start:

sudo uwsgi --socket :8002 -b 10000 --module protosite.wsgi

or if not working, check that nginx service is using the correct config in log (above).
If not, restart:

sudo nginx -s stop
sudo nginx -c ~/Desktop/repos/web/nginx/protosite_nginx.conf

[Which port is used?]

netstat -p tcp
lsof -i :8002
kill [PID]

ps ax | grep nginx

protosite's People

Contributors

zreactor avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.