<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Production Deployment Archives - ServerStadium</title>
	<atom:link href="https://serverstadium.com/knowledge-base/tag/production-deployment/feed/" rel="self" type="application/rss+xml" />
	<link>https://serverstadium.com/knowledge-base/tag/production-deployment/</link>
	<description>Public Cloud Solution by ServerStadium</description>
	<lastBuildDate>Thu, 04 Jan 2024 01:36:42 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1.4</generator>

<image>
	<url>https://serverstadium.com/wp-content/uploads/2023/04/cropped-favicon-1-32x32.png</url>
	<title>Production Deployment Archives - ServerStadium</title>
	<link>https://serverstadium.com/knowledge-base/tag/production-deployment/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Making Your Django Project Production-Ready on Ubuntu 22.04: Gunicorn and Nginx Setup</title>
		<link>https://serverstadium.com/knowledge-base/making-your-django-project-production-ready-on-ubuntu-22-04-gunicorn-and-nginx-setup/</link>
		
		<dc:creator><![CDATA[Brian K]]></dc:creator>
		<pubDate>Thu, 04 Jan 2024 01:35:52 +0000</pubDate>
				<guid isPermaLink="false">https://serverstadium.com/?post_type=epkb_post_type_1&#038;p=11751</guid>

					<description><![CDATA[<p>This continuation of our guide will show you how to make your Django project production-ready on a ServerStadium VM using Gunicorn and Nginx. Step 8: Install and Configure Gunicorn Install Gunicorn with pip: Test Gunicorn&#8217;s ability to serve the project: Now, visit http://your_server_ip:8000 to confirm it’s serving your Django site correctly. Step 9: Create a&#8230;</p>
<p>The post <a href="https://serverstadium.com/knowledge-base/making-your-django-project-production-ready-on-ubuntu-22-04-gunicorn-and-nginx-setup/">Making Your Django Project Production-Ready on Ubuntu 22.04: Gunicorn and Nginx Setup</a> appeared first on <a href="https://serverstadium.com">ServerStadium</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>This continuation of our guide will show you how to make your Django project production-ready on a ServerStadium VM using Gunicorn and Nginx.</p>
<h3>Step 8: Install and Configure Gunicorn</h3>
<p>Install Gunicorn with pip:</p>
<div class="shortcode-code">
<p>pip3 install gunicorn</p></div>
<p>Test Gunicorn&#8217;s ability to serve the project:</p>
<div class="shortcode-code">
<p>gunicorn &#8211;workers 3 myproject.wsgi:application &#8211;&lt;span class=&quot;hljs-built_in&quot;&gt;bind&lt;/span&gt; 0.0.0.0:8000</p></div>
<p>Now, visit <code>http://your_server_ip:8000</code> to confirm it’s serving your Django site correctly.</p>
<h3>Step 9: Create a Gunicorn Systemd Service File</h3>
<p>Create a systemd service file for Gunicorn to manage your process:</p>
<div class="bg-black rounded-md">
<div class="p-4 overflow-y-auto"><div class="shortcode-code">
<p>sudo nano /etc/systemd/system/gunicorn.service</p></div></p></div>
<div></div>
</div>
<p>Add the following content, adjusting paths and usernames as necessary:</p>
<div class="bg-black rounded-md">
<div class="flex items-center relative text-gray-200 bg-gray-800 dark:bg-token-surface-primary px-4 py-2 text-xs font-sans justify-between rounded-t-md"></div>
<div class="p-4 overflow-y-auto">
<div class="shortcode-code">
<p>&#091;Unit&#093;<br />
Description=gunicorn daemon<br />
Requires=gunicorn.socket<br />
After=network.target</p>
<p>&#091;Service&#093;<br />
User=yourusername<br />
Group=www-data<br />
WorkingDirectory=/home/yourusername/mydjangoapp<br />
ExecStart=/home/yourusername/mydjangoapp/env/bin/gunicorn \<br />
&#8211;access-logfile &#8211; \<br />
&#8211;workers 3 \<br />
&#8211;bind unix:/run/gunicorn.sock \<br />
myproject.wsgi:application</p>
<p>&#091;Install&#093;<br />
WantedBy=multi-user.target</p>
<p></p></div>
</div>
</div>
<p>Enable and start the Gunicorn service:</p>
<div class="bg-black rounded-md">
<div class="p-4 overflow-y-auto"><div class="shortcode-code">
<p>sudo systemctl start gunicorn&lt;/div&gt;<br />
&lt;div class=&quot;p-4 overflow-y-auto&quot;&gt;sudo systemctl &lt;span class=&quot;hljs-built_in&quot;&gt;enable&lt;/span&gt; gunicorn</p></div></p></div>
</div>
<h3>Step 10: Install and Configure Nginx</h3>
<p>Install Nginx:</p>
<div class="bg-black rounded-md">
<div class="p-4 overflow-y-auto"><div class="shortcode-code">
<p>sudo apt install nginx</p></div></p></div>
<div></div>
</div>
<p>Configure Nginx to proxy pass to Gunicorn. Create a new server block:</p>
<div class="bg-black rounded-md">
<div class="p-4 overflow-y-auto"><div class="shortcode-code">
<p>sudo nano /etc/nginx/sites-available/mydjangoapp</p></div></p></div>
</div>
<p>Add the following configuration:</p>
<div class="bg-black rounded-md">
<div class="flex items-center relative text-gray-200 bg-gray-800 dark:bg-token-surface-primary px-4 py-2 text-xs font-sans justify-between rounded-t-md">
<div class="shortcode-code">
<p>server {<br />
listen 80;<br />
server_name your_server_ip;</p>
<p>location = /favicon.ico { access_log off; log_not_found off; }<br />
location /static/ {<br />
root /home/yourusername/mydjangoapp;<br />
}</p>
<p>location / {<br />
include proxy_params;<br />
proxy_pass http://unix:/run/gunicorn.sock;<br />
}<br />
}</p>
<p></p></div>
</div>
</div>
<div class="bg-black rounded-md">
<div class="flex items-center relative text-gray-200 bg-gray-800 dark:bg-token-surface-primary px-4 py-2 text-xs font-sans justify-between rounded-t-md">Link this file to the <code>sites-enabled</code> directory:</div>
<div></div>
<div class="p-4 overflow-y-auto"><div class="shortcode-code">
<p>sudo &lt;span class=&quot;hljs-built_in&quot;&gt;ln&lt;/span&gt; -s /etc/nginx/sites-available/mydjangoapp /etc/nginx/sites-enabled</p></div></p></div>
<div></div>
</div>
<p>Test your Nginx configuration:</p>
<div class="bg-black rounded-md">
<div class="p-4 overflow-y-auto"><div class="shortcode-code">
<p>sudo nginx -t</p></div></p></div>
<div></div>
</div>
<p>Restart Nginx:</p>
<div class="bg-black rounded-md">
<div class="p-4 overflow-y-auto"><div class="shortcode-code">
<p>sudo systemctl restart nginx</p></div></p></div>
</div>
<h3>Step 11: Secure Your Server with a Firewall</h3>
<p>Enable the Nginx Full profile on <code>ufw</code>:</p>
<div class="bg-black rounded-md">
<div class="p-4 overflow-y-auto"><div class="shortcode-code">
<p>sudo ufw allow &lt;span class=&quot;hljs-string&quot;&gt;&#039;Nginx Full&#039;&lt;/span&gt;</p></div></p></div>
</div>
<h3>Conclusion</h3>
<p>Your Django application is now configured with Gunicorn and Nginx on your <a href="https://cp.serverstadium.com/" target="_new" rel="noopener">ServerStadium VM</a>, ready for production.</p>
<p>For additional support, check out our <a href="https://serverstadium.com/knowledge-base/" target="_new" rel="noopener">knowledge base</a> or contact our support team.</p>
<p>The post <a href="https://serverstadium.com/knowledge-base/making-your-django-project-production-ready-on-ubuntu-22-04-gunicorn-and-nginx-setup/">Making Your Django Project Production-Ready on Ubuntu 22.04: Gunicorn and Nginx Setup</a> appeared first on <a href="https://serverstadium.com">ServerStadium</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
