Instalasi Django web apps dengan Gunicorn dan Nginx.

Atur SELinux menjadi permissive.

Hapus default server Nginx.

Atur static root pada Django.

os.path.join(BASE_DIR, 'production/static/')
$ pip install gunicorn
$ gunicorn -b 0.0.0.0:8080 sample.wsgi

Atur konfigurasi Nginx dengan berkas ini.

# Configuration for Nginx
    server {

        # Running port
        listen 80;

        # Settings to serve static files
        location ^~ /static/  {

            # Example:
            # root /full/path/to/application/static/file/dir;
            root /home/xyz/Projects/xyz/production/;

        }

        # Serve a static file (ex. favico)
        # outside /static directory
        ##location = /favico.ico  {

        ##    root /app/favico.ico;

        ##}

        # Proxy connections to the application servers
        # app_servers
        location / {

            proxy_pass         http://127.0.0.1:8000;
            proxy_redirect     off;
            proxy_set_header   Host $http_host;
            proxy_set_header   X-Real-IP $remote_addr;
            proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header   X-Forwarded-Host $server_name;

        }
    }

Referensi

results matching ""

    No results matching ""