사용자 도구

사이트 도구


python:django:garam

설정을 위하여

garam.garamx.com

uWSGI

1.uwsgi.ini

garam/run/maro_uwsgi.ini
[uwsgi]
uid=foo
base=/home/%(uid)/garam
 
# the virtualenv (full path)
home=/home/%(uid)/.pyenv/versions/maro
chdir=/home/%(uid)/garam/maro
 
module=conf.wsgi:application
env=DJANGO_SETTINGS_MODULE=conf.settings.product
 
# process-related settings
# uWSGI 프로세스를 master로 돌아가게 해줍니다.
master=true
 
# maximum number of worker processes
processes=5
 
max-requests=5000
daemonize=/var/log/garam/maro/uwsgi.log
 
# UNIX socket 파일의 위치입니다. socket file의 위치를 잡아줘도 되며 localhost와 port를 명시해줘도 됩니다.
socket=/var/log/garam/maro.sock
# UNIX socket 소유자
chown-socket=%(uid):www-data
# UNIX socket에 대한 권한 설정입니다. 666을 해야 실행이 가능합니다.
chmod-socket=660
# uWSGI를 통해서 생성된 파일들은 삭제하는 옵션입니다.
vacuum=true
 
# thread 사용을 앱(uWSGI) 내에서 가능하게 해줍니다.
enable-threads = true
# 단일한 python interpreter를 사용하게 하는 옵션입니다.
single-interpreter = true
# master말고 각각의 worker에(master에서 spawn한 자식들) 앱을 로드하는 설정입니다.
lazy-apps = true

2.uwsgi service 등록

/etc/systemd/system/uwsgi.service
[Unit]
Description=uWSGI Emperor service
 
[Service]
ExecStart=/home/foo/.pyenv/shims/uwsgi \
        --emperor /home/foo/garam/run
User=foo
Group=www-data
Restart=on-failure
KillSignal=SIGQUIT
Type=notify
NotifyAccess=all
StandardError=syslog
 
[Install]
WantedBy=multi-user.target

nginx

/etc/nginx/sites-available/maro
##
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# https://www.nginx.com/resources/wiki/start/
# https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/
# https://wiki.debian.org/Nginx/DirectoryStructure
#
# In most cases, administrators will remove this file from sites-enabled/ and
# leave it as reference inside of sites-available where it will continue to be
# updated by the nginx packaging team.
#
# This file will automatically load configuration files provided by other
# applications, such as Drupal or Wordpress. These applications will be made
# available underneath a path with that package name, such as /drupal8.
#
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
##
 
upstream django {
    # server unix:///usr/local/share/pythonblog/config/pythonblog.sock;
    server unix:///var/log/garam/maro.sock;
}
 
# Default server configuration
#
server {
	listen 80 default_server;
	listen [::]:80 default_server;
 
	# SSL configuration
	#
	# listen 443 ssl default_server;
	# listen [::]:443 ssl default_server;
	#
	# Note: You should disable gzip for SSL traffic.
	# See: https://bugs.debian.org/773332
	#
	# Read up on ssl_ciphers to ensure a secure configuration.
	# See: https://bugs.debian.org/765782
	#
	# Self signed certs generated by the ssl-cert package
	# Don't use them in a production server!
	#
	# include snippets/snakeoil.conf;
 
	root /var/www/html;
 
	# Add index.php to the list if you are using PHP
	index index.html index.htm index.nginx-debian.html;
 
	server_name _;
 
	location / {
		# First attempt to serve request as file, then
		# as directory, then fall back to displaying a 404.
		try_files $uri $uri/ =404;
	}
 
	# pass PHP scripts to FastCGI server
	#
	#location ~ \.php$ {
	#	include snippets/fastcgi-php.conf;
	#
	#	# With php-fpm (or other unix sockets):
	#	fastcgi_pass unix:/run/php/php7.4-fpm.sock;
	#	# With php-cgi (or other tcp sockets):
	#	fastcgi_pass 127.0.0.1:9000;
	#}
 
	# deny access to .htaccess files, if Apache's document root
	# concurs with nginx's one
	#
	#location ~ /\.ht {
	#	deny all;
	#}
}
 
 
# Virtual Host configuration for example.com
#
# You can move that to a different file under sites-available/ and symlink that
# to sites-enabled/ to enable it.
#
#server {
#	listen 80;
#	listen [::]:80;
#
#	server_name example.com;
#
#	root /var/www/example.com;
#	index index.html;
#
#	location / {
#		try_files $uri $uri/ =404;
#	}
#}
 
server {
 
	# SSL configuration
	#
	# listen 443 ssl default_server;
	# listen [::]:443 ssl default_server;
	#
	# Note: You should disable gzip for SSL traffic.
	# See: https://bugs.debian.org/773332
	#
	# Read up on ssl_ciphers to ensure a secure configuration.
	# See: https://bugs.debian.org/765782
	#
	# Self signed certs generated by the ssl-cert package
	# Don't use them in a production server!
	#
	# include snippets/snakeoil.conf;
 
	root /var/www/html;
 
	# Add index.php to the list if you are using PHP
	index index.html index.htm index.nginx-debian.html;
    server_name garam.garamx.com; # managed by Certbot
 
	location / {
		return 301 /greed/;
	}
 
	location /naro {
		# First attempt to serve request as file, then
		# as directory, then fall back to displaying a 404.
		# try_files $uri $uri/ =404;
		uwsgi_pass django;
		include /etc/nginx/uwsgi_params;
	}
 
	location /static {
		# alias /home/mama/garam/maro/gov/static/;
		alias /var/garam/static;
	}
 
	location /greed {
		sub_filter_types text/xml text/css text/javascript;
	    #root /var/garam/greed;
		#index index.html;
		alias /var/garam/greed/;
		try_files $uri $uri/ /greed/index.html;
	}
 
	# pass PHP scripts to FastCGI server
	#
	#location ~ \.php$ {
	#	include snippets/fastcgi-php.conf;
	#
	#	# With php-fpm (or other unix sockets):
	#	fastcgi_pass unix:/run/php/php7.4-fpm.sock;
	#	# With php-cgi (or other tcp sockets):
	#	fastcgi_pass 127.0.0.1:9000;
	#}
 
	# deny access to .htaccess files, if Apache's document root
	# concurs with nginx's one
	#
	#location ~ /\.ht {
	#	deny all;
	#}
 
 
    listen [::]:443 ssl ipv6only=on; # managed by Certbot
    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/garam.garamx.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/garam.garamx.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
 
}
server {
    if ($host = garam.garamx.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot
 
	listen 80 ;
	listen [::]:80 ;
    server_name garam.garamx.com;
    return 404; # managed by Certbot
 
}
python/django/garam.txt · 마지막으로 수정됨: 2025/04/15 10:05 저자 127.0.0.1