<?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>Development Archives - ServerStadium</title>
	<atom:link href="https://serverstadium.com/knowledge-base/category/development/feed/" rel="self" type="application/rss+xml" />
	<link>https://serverstadium.com/knowledge-base/category/development/</link>
	<description>Public Cloud Solution by ServerStadium</description>
	<lastBuildDate>Tue, 30 May 2023 21:16:55 +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>Development Archives - ServerStadium</title>
	<link>https://serverstadium.com/knowledge-base/category/development/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Building Your First Application with the MEAN Stack on ServerStadium VM Instances</title>
		<link>https://serverstadium.com/knowledge-base/building-mean-stack-app-serverstadium-vm-instances/</link>
		
		<dc:creator><![CDATA[Brian K]]></dc:creator>
		<pubDate>Tue, 30 May 2023 21:16:55 +0000</pubDate>
				<guid isPermaLink="false">https://serverstadium.com/?post_type=epkb_post_type_1&#038;p=11690</guid>

					<description><![CDATA[<p>Once you have the MEAN Stack set up on your ServerStadium VM instance, you can start building your first application. This guide will walk you through the process of creating a simple application. Before we dive in, make sure you&#8217;ve followed our previous guide on Setting up a MEAN Stack on ServerStadium VM Instances. Step&#8230;</p>
<p>The post <a href="https://serverstadium.com/knowledge-base/building-mean-stack-app-serverstadium-vm-instances/">Building Your First Application with the MEAN Stack on ServerStadium VM Instances</a> appeared first on <a href="https://serverstadium.com">ServerStadium</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Once you have the MEAN Stack set up on your ServerStadium VM instance, you can start building your first application. This guide will walk you through the process of creating a simple application.</p>
<p>Before we dive in, make sure you&#8217;ve followed our previous guide on <a href="https://serverstadium.com/knowledge-base/mean-stack-setup-serverstadium-vm-instances" target="_new" rel="noopener">Setting up a MEAN Stack on ServerStadium VM Instances</a>.</p>
<h2>Step 1: Create an Express.js Server</h2>
<p>Start by creating a new directory for your project and navigating into it:</p>
<pre><code class="!whitespace-pre hljs language-bash"><span class="hljs-built_in">mkdir</span> mean-app
<span class="hljs-built_in">cd</span> mean-app
</code></pre>
<p>Initialize a new Node.js application:</p>
<div class="bg-black rounded-md mb-4">
<pre class="p-4 overflow-y-auto"><code class="!whitespace-pre hljs language-bash">npm init -y
</code></pre>
</div>
<p>Install Express.js:</p>
<div class="bg-black rounded-md mb-4">
<pre class="p-4 overflow-y-auto"><code class="!whitespace-pre hljs language-bash">npm install express
</code></pre>
</div>
<p>Create a new file named <code>server.js</code>:</p>
<div class="bg-black rounded-md mb-4">
<pre class="p-4 overflow-y-auto"><code class="!whitespace-pre hljs language-bash"><span class="hljs-built_in">touch</span> server.js
</code></pre>
</div>
<p>Open <code>server.js</code> in your text editor and add the following code to create a basic Express.js server:</p>
<div class="bg-black rounded-md mb-4">
<pre class="p-4 overflow-y-auto"><code class="!whitespace-pre hljs language-javascript"><span class="hljs-keyword">const</span> express = <span class="hljs-built_in">require</span>(<span class="hljs-string">'express'</span>);
<span class="hljs-keyword">const</span> app = <span class="hljs-title function_">express</span>();
<span class="hljs-keyword">const</span> port = <span class="hljs-number">3000</span>;

app.<span class="hljs-title function_">get</span>(<span class="hljs-string">'/'</span>, <span class="hljs-function">(<span class="hljs-params">req, res</span>) =&gt;</span> {
  res.<span class="hljs-title function_">send</span>(<span class="hljs-string">'Hello World!'</span>);
});

app.<span class="hljs-title function_">listen</span>(port, <span class="hljs-function">() =&gt;</span> {
  <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(<span class="hljs-string">`Server is running at http://localhost:<span class="hljs-subst">${port}</span>`</span>);
});</code></pre>
<p>Run your server with <code>node server.js</code>. You should see &#8220;Server is running at http://localhost:3000&#8221; in your console. You can visit this URL in your browser to see your server in action.</p>
<h2>Step 2: Connect to MongoDB</h2>
<p>Install the MongoDB driver for Node.js:</p>
<div class="bg-black rounded-md mb-4">
<pre class="p-4 overflow-y-auto"><code class="!whitespace-pre hljs language-bash">npm install mongodb
</code></pre>
</div>
<p>Update <code>server.js</code> to connect to your MongoDB database:</p>
<div class="bg-black rounded-md mb-4">
<pre class="p-4 overflow-y-auto"><code class="!whitespace-pre hljs language-javascript"><span class="hljs-keyword">const</span> express = <span class="hljs-built_in">require</span>(<span class="hljs-string">'express'</span>);
<span class="hljs-keyword">const</span> mongodb = <span class="hljs-built_in">require</span>(<span class="hljs-string">'mongodb'</span>);
<span class="hljs-keyword">const</span> app = <span class="hljs-title function_">express</span>();
<span class="hljs-keyword">const</span> port = <span class="hljs-number">3000</span>;

mongodb.<span class="hljs-property">MongoClient</span>.<span class="hljs-title function_">connect</span>(<span class="hljs-string">'mongodb://localhost:27017'</span>, <span class="hljs-function">(<span class="hljs-params">err, client</span>) =&gt;</span> {
  <span class="hljs-keyword">if</span> (err) {
    <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">error</span>(err);
    <span class="hljs-keyword">return</span>;
  }

  <span class="hljs-keyword">const</span> db = client.<span class="hljs-title function_">db</span>(<span class="hljs-string">'mydb'</span>);

  app.<span class="hljs-title function_">get</span>(<span class="hljs-string">'/'</span>, <span class="hljs-function">(<span class="hljs-params">req, res</span>) =&gt;</span> {
    res.<span class="hljs-title function_">send</span>(<span class="hljs-string">'Connected to MongoDB!'</span>);
  });

  app.<span class="hljs-title function_">listen</span>(port, <span class="hljs-function">() =&gt;</span> {
    <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(<span class="hljs-string">`Server is running at http://localhost:<span class="hljs-subst">${port}</span>`</span>);
  });
});
</code></pre>
</div>
<h2>Step 3: Create an Angular App</h2>
<p>Navigate to a different directory where you want to create your Angular app:</p>
<div class="bg-black rounded-md mb-4">
<pre class="p-4 overflow-y-auto"><code class="!whitespace-pre hljs language-bash"><span class="hljs-built_in">cd</span> ..
ng new mean-angular-app
<span class="hljs-built_in">cd</span> mean-angular-app
</code></pre>
</div>
<p>Serve your Angular app:</p>
<div class="bg-black rounded-md mb-4">
<div class="p-4 overflow-y-auto"><code class="!whitespace-pre hljs language-bash">ng serve<br />
</code></div>
</div>
<p>You should see &#8220;Angular Live Development Server is listening on localhost:4200&#8221; in your console. You can visit this URL in your browser to see your Angular app.</p>
<h2>Step 4: Connect Angular to Express.js</h2>
<p>First, install the <code>http</code> package in your Angular app:</p>
<div class="bg-black rounded-md mb-4">
<pre class="p-4 overflow-y-auto"><code class="!whitespace-pre hljs language-bash">npm install @angular/common/http</code></pre>
<p>Update the <code>app.component.ts</code> file in your Angular app to make a GET request to your Express.js server</p>
<div class="bg-black rounded-md mb-4">
<pre class="p-4 overflow-y-auto"><code class="!whitespace-pre hljs language-typescript"><span class="hljs-keyword">import</span> { <span class="hljs-title class_">HttpClient</span> } <span class="hljs-keyword">from</span> <span class="hljs-string">'@angular/common/http'</span>;

<span class="hljs-keyword">export</span> <span class="hljs-keyword">class</span> <span class="hljs-title class_">AppComponent</span> {
  title = <span class="hljs-string">'mean-angular-app'</span>;
  message = <span class="hljs-string">''</span>;

  <span class="hljs-title function_">constructor</span>(<span class="hljs-params"><span class="hljs-keyword">private</span> http: HttpClient</span>) {
    <span class="hljs-variable language_">this</span>.<span class="hljs-property">http</span>.<span class="hljs-title function_">get</span>(<span class="hljs-string">'http://localhost:3000'</span>).<span class="hljs-title function_">subscribe</span>(<span class="hljs-function">(<span class="hljs-params">data: <span class="hljs-built_in">any</span></span>) =&gt;</span> {
      <span class="hljs-variable language_">this</span>.<span class="hljs-property">message</span> = data;
    });
  }
}
</code></pre>
</div>
<p>Update the <code>app.component.html</code> file in your Angular app to display the message from your Express.js server:</p>
<pre class="p-4 overflow-y-auto"><code class="!whitespace-pre hljs language-html"><span class="hljs-tag">&lt;<span class="hljs-name">h1</span>&gt;</span>{{ message }}<span class="hljs-tag">&lt;/<span class="hljs-name">h1</span>&gt;</span></code></pre>
<h2>Conclusion</h2>
<p>Congratulations! You&#8217;ve just created your first MEAN Stack application on a ServerStadium VM instance. This guide only scratches the surface of what you can do with the MEAN Stack. To further your knowledge, explore our <a href="https://serverstadium.com/knowledge-base/" target="_new" rel="noopener">Knowledge Base</a> for more tutorials and guides.</p>
<p>Remember, our team at ServerStadium is always ready to assist you with your needs. Feel free to <a href="https://serverstadium.com/contact" target="_new" rel="noopener">reach out</a> to us if you have any questions or need further assistance.</p>
</div>
</div>
<p>The post <a href="https://serverstadium.com/knowledge-base/building-mean-stack-app-serverstadium-vm-instances/">Building Your First Application with the MEAN Stack on ServerStadium VM Instances</a> appeared first on <a href="https://serverstadium.com">ServerStadium</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Step-by-Step MEAN Stack Setup on ServerStadium VM Instances</title>
		<link>https://serverstadium.com/knowledge-base/mean-stack-setup-serverstadium-vm-instances/</link>
		
		<dc:creator><![CDATA[Brian K]]></dc:creator>
		<pubDate>Tue, 30 May 2023 21:02:29 +0000</pubDate>
				<guid isPermaLink="false">https://serverstadium.com/?post_type=epkb_post_type_1&#038;p=11688</guid>

					<description><![CDATA[<p>Setting up a MEAN Stack (MongoDB, Express.js, Angular, Node.js) can sometimes be complex, especially for newcomers. However, with ServerStadium&#8217;s VM instances, the process is straightforward. In this tutorial, we&#8217;ll guide you step by step through the entire process. Before we get started, be sure to visit our comprehensive Knowledge Base for a wealth of other&#8230;</p>
<p>The post <a href="https://serverstadium.com/knowledge-base/mean-stack-setup-serverstadium-vm-instances/">Step-by-Step MEAN Stack Setup on ServerStadium VM Instances</a> appeared first on <a href="https://serverstadium.com">ServerStadium</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Setting up a MEAN Stack (MongoDB, Express.js, Angular, Node.js) can sometimes be complex, especially for newcomers. However, with ServerStadium&#8217;s VM instances, the process is straightforward. In this tutorial, we&#8217;ll guide you step by step through the entire process.</p>
<p>Before we get started, be sure to visit our comprehensive <a href="https://serverstadium.com/knowledge-base/" target="_new" rel="noopener">Knowledge Base</a> for a wealth of other useful tutorials and guides.</p>
<h2>Step 1: Register Your Account</h2>
<p>To kick off, you&#8217;ll need to register an account on our <a href="https://cp.serverstadium.com/register-user" target="_new" rel="noopener">Registration Page</a>. Fill out your details, and create your account. Following registration, you&#8217;ll gain access to your personal Cloud Dashboard.</p>
<h2 data-id="articleTOC_1">Step 2: Choose Your Cloud Instance</h2>
<p>From your Cloud Dashboard, go to the ‘Add VM’ section. Here, you’ll find a variety of cloud instance options. Select the one that suits your needs. If you need help deciding, our <a href="https://serverstadium.com/pricing/" target="_new" rel="noopener">Instance Pricing Guide</a> can help you.</p>
<h2>Step 3: Install Node.js and NPM</h2>
<p>Node.js is a JavaScript runtime built on Chrome&#8217;s V8 JavaScript engine. It&#8217;s designed to build scalable network applications. Node.js uses an event-driven, non-blocking I/O model that is lightweight and efficient.</p>
<p>NPM (Node Package Manager) is the default package manager for Node.js. It&#8217;s used for installing, sharing, and distributing code, managing dependencies in your projects, and much more.</p>
<p>To install Node.js and NPM, you can run the following commands:</p>
<div class="bg-black rounded-md mb-4">
<div class="p-4 overflow-y-auto"><code class="!whitespace-pre hljs language-bash">sudo apt update</code></div>
<div class="p-4 overflow-y-auto"><code class="!whitespace-pre hljs language-bash">sudo apt install nodejs npm<br />
</code></div>
</div>
<p>You can verify the installation with <code>nodejs -v</code> and <code>npm -v</code>.</p>
<h2>Step 4: Install MongoDB</h2>
<p>MongoDB is a source-available cross-platform document-oriented database program. It&#8217;s classified as a NoSQL database program, which means it doesn&#8217;t use the traditional tabular relational database structure. Instead, it uses JSON-like documents with optional schemas.</p>
<p>To install MongoDB, run the following commands:</p>
<div class="bg-black rounded-md mb-4">
<div class="p-4 overflow-y-auto"><code class="!whitespace-pre hljs language-bash">sudo apt install mongodb</code></div>
<div class="p-4 overflow-y-auto"><code class="!whitespace-pre hljs language-bash">sudo systemctl status mongodb<br />
</code></div>
</div>
<p>The first command will install MongoDB, and the second will check the status of MongoDB to ensure it&#8217;s running correctly.</p>
<h2>Step 5: Install Express.js</h2>
<p>Express.js, or simply Express, is a web application framework for Node.js, designed for building web applications and APIs. It&#8217;s minimalistic and flexible and provides a robust set of features for web and mobile applications.</p>
<p>To install Express.js, you must create a project directory, navigate to it, and initialize a new Node.js application using NPM. After that, you can install Express.js:</p>
<div class="bg-black rounded-md mb-4">
<div class="p-4 overflow-y-auto"><code class="!whitespace-pre hljs language-bash"><span class="hljs-built_in">mkdir</span></code><code class="!whitespace-pre hljs language-bash">myapp</code></div>
<div class="p-4 overflow-y-auto"><code class="!whitespace-pre hljs language-bash"><span class="hljs-built_in">cd</span> myapp</code></div>
<div class="p-4 overflow-y-auto"><code class="!whitespace-pre hljs language-bash">npm init</code></div>
<div class="p-4 overflow-y-auto"><code class="!whitespace-pre hljs language-bash">npm install express<br />
</code></div>
</div>
<h2>Step 6: Install Angular</h2>
<p>Angular is a platform for building web applications. It provides a way to create single-page applications requiring only HTML, CSS, and JavaScript on the client side.</p>
<p>To install Angular, you need to install Angular CLI (Command Line Interface), a command line tool used to scaffold and build Angular apps using node.js style (commonJs) modules. Not only does it provide you with scaffolding for your apps, but it also helps you manage your entire Angular project.</p>
<p>Install Angular CLI globally using NPM:</p>
<div class="bg-black rounded-md mb-4">
<div class="p-4 overflow-y-auto"><code class="!whitespace-pre hljs language-bash">npm install -g @angular/cli<br />
</code></div>
</div>
<p>You can verify the installation with <code>ng version</code>.</p>
<h2>Step 7: Create Your Application</h2>
<p>Now that your MEAN Stack is set up, you can start building your application. This involves creating an Express.js server, setting up routes for your application, connecting your application to your MongoDB database, and building your front-end with Angular.</p>
<p>If you&#8217;re new to the MEAN Stack, check out our introductory <a href="https://serverstadium.com/knowledge-base/mean-stack-intro" target="_new" rel="noopener">MEAN Stack tutorial</a> to get a detailed walk-through of how to create your first MEAN Stack application.</p>
<h2>Conclusion</h2>
<p>Congratulations! You now have a MEAN Stack set up in your ServerStadium VM instance! You&#8217;re ready to dive into web application development and harness the powerful capabilities of ServerStadium&#8217;s VM instances.</p>
<p>Remember, our <a href="https://serverstadium.com/knowledge-base/" target="_new" rel="noopener">Knowledge Base</a> is a treasure trove of tutorials, guides, and helpful tips. If you ever need assistance, don&#8217;t hesitate to contact our support team.</p>
<p>The post <a href="https://serverstadium.com/knowledge-base/mean-stack-setup-serverstadium-vm-instances/">Step-by-Step MEAN Stack Setup on ServerStadium VM Instances</a> appeared first on <a href="https://serverstadium.com">ServerStadium</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>How to Deploy Django App on ServerStadium VM Using Gunicorn, Supervisor, and Nginx</title>
		<link>https://serverstadium.com/knowledge-base/how-to-deploy-django-app-on-serverstadium-vm-using-gunicorn-supervisor-and-nginx/</link>
		
		<dc:creator><![CDATA[Brian K]]></dc:creator>
		<pubDate>Sat, 11 Jun 2022 07:11:17 +0000</pubDate>
				<guid isPermaLink="false">https://cloudraya.com/knowledge-base/?p=2084</guid>

					<description><![CDATA[<p>A basic guide on deploying the Django app using Gunicorn, Supervisor, and Nginx stack on your ServerStadium VM instance. In this article, I will use Ubuntu 22.04 LTS as the deployment server, Python 3.8, and Django 4.0. TLDR Create a standard user called apps Install supervisor and Nginx Install your App&#8217;s Python version. Install pip&#8230;</p>
<p>The post <a href="https://serverstadium.com/knowledge-base/how-to-deploy-django-app-on-serverstadium-vm-using-gunicorn-supervisor-and-nginx/">How to Deploy Django App on ServerStadium VM Using Gunicorn, Supervisor, and Nginx</a> appeared first on <a href="https://serverstadium.com">ServerStadium</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">A basic guide on deploying the Django app using Gunicorn, Supervisor, and Nginx stack on your ServerStadium VM instance.</p>



<p class="wp-block-paragraph">In this article, I will use Ubuntu 22.04 LTS as the deployment server, Python 3.8, and Django 4.0.</p>



<h2 class="has-vivid-cyan-blue-color has-text-color wp-block-heading">TLDR</h2>



<ol class="wp-block-list">
<li>Create a standard user called <strong>apps</strong></li>
<li>Install supervisor and Nginx</li>
</ol>



<pre class="wp-block-code"><code>sudo apt install supervisor nginx -y</code></pre>



<ol class="wp-block-list" start="3">
<li>Install your App&#8217;s Python version.</li>
<li>Install <code>pip</code></li>
<li>Install <code>pipenv</code> globally.</li>
</ol>



<pre class="wp-block-code"><code>sudo pip install pipenv</code></pre>



<ol class="wp-block-list" start="3">
<li>Add your server IP and/or FQDN address to ALLOWED_HOSTS in <code>settings.py</code> file</li>
</ol>



<pre class="wp-block-code"><code>ALLOWED_HOSTS = [ "xx.yy.dd.zz", "your.domain.tld" ]</code></pre>



<ol class="wp-block-list" start="4">
<li>Copy the Django app to <code>/home/apps/django-app</code></li>
<li>Go to the app folder and run:</li>
</ol>



<pre class="wp-block-code"><code>cd /home/apps/django-app
python3.8 -m pipenv install --deploy</code></pre>



<ol class="wp-block-list" start="6">
<li>Install Gunicorn using pipenv on the same directory</li>
</ol>



<pre class="wp-block-code"><code>python3.8 -m pipenv install gunicorn</code></pre>



<ol class="wp-block-list" start="7">
<li>Create supervisor config file under <code>/etc/supervisor/conf.d/django-app.conf</code></li>
</ol>



<pre class="wp-block-code"><code>[program:django-app]
user=apps
directory=/home/apps/django-app/djangoapp/
command=/usr/local/bin/pipenv run gunicorn --workers=3 djangoapp.wsgi

autostart=true
autorestart=true
stdout_logfile=/home/apps/logs/django-app.log
stderr_logfile=/home/apps/logs/django-app.err.log</code></pre>



<ol class="wp-block-list" start="8">
<li>Create the required files and folder:</li>
</ol>



<pre class="wp-block-code"><code>mkdir /home/apps/logs/
touch /home/apps/django-app{,.err}.log</code></pre>



<ol class="wp-block-list" start="9">
<li>Restart supervisor to recognize the app</li>
</ol>



<pre class="wp-block-code"><code>sudo systemctl restart supervisor</code></pre>



<ol class="wp-block-list" start="10">
<li>Create nginx server block file for the app under <code>/etc/nginx/sites-available/django-app.conf</code></li>
</ol>



<pre class="wp-block-code"><code>server {
    listen 80;
    
    location / {
        include proxy_params;
        proxy_pass http://localhost:8000;
    }
}</code></pre>



<ol class="wp-block-list" start="11">
<li>Activate the config and reload nginx</li>
</ol>



<pre class="wp-block-code"><code>sudo ln -s <span style="background-color: inherit; font-family: monospace; font-size: inherit;">/etc/nginx/sites-available/django-app.conf</span> /etc/nginx/sites-enabled
sudo unlink /etc/nginx/sites-enabled/default
sudo nginx -t
sudo nginx -s reload</code></pre>



<ol class="wp-block-list" start="12">
<li>Access the app from your browser: <code>http://your-ip</code> or <code>http://your-domain.tld</code> and DONE!</li>
</ol>



<h2 class="has-vivid-cyan-blue-color has-text-color wp-block-heading">Step-by-step Guide</h2>



<h3 class="has-vivid-cyan-blue-color has-text-color wp-block-heading">Django App Peparation</h3>



<p class="wp-block-paragraph">I will assume that your Django App is ready to be deployed. This means it has Pipfile or requirements.txt. For this tutorial, I&#8217;m going to use <code>pipenv</code> as the virtual environment tool and here&#8217;s the directory structure of the app:</p>



<pre class="wp-block-code"><code>├── djangoapp
│   ├── db.sqlite3
│   ├── djangoapp
│   │   ├── asgi.py
│   │   ├── __init__.py
│   │   ├── settings.py
│   │   ├── urls.py
│   │   └── wsgi.py
│   └── manage.py
├── Pipfile
└── Pipfile.lock</code></pre>



<p class="wp-block-paragraph">Make sure the app runs successfully in our local environment by running the below command on the app directory:</p>



<pre class="wp-block-code"><code>pipenv run djangoapp/manage.py runserver</code></pre>


<div class="wp-block-image">
<figure class="aligncenter size-full is-resized"><img fetchpriority="high" decoding="async" class="wp-image-2147" src="https://serverstadium.com/wp-content/uploads/2022/06/carbon-1.png" alt="" width="768" height="380" srcset="https://serverstadium.com/wp-content/uploads/2022/06/carbon-1.png 1024w, https://serverstadium.com/wp-content/uploads/2022/06/carbon-1-300x149.png 300w, https://serverstadium.com/wp-content/uploads/2022/06/carbon-1-768x380.png 768w" sizes="(max-width: 768px) 100vw, 768px" /></figure>
</div>


<p class="wp-block-paragraph">Then access your browser with <code>http://127.0.0.1:8000</code></p>


<div class="wp-block-image">
<figure class="aligncenter size-full is-resized"><img decoding="async" class="wp-image-2148" src="https://serverstadium.com/wp-content/uploads/2022/06/image-1.png" alt="" width="886" height="645" /></figure>
</div>


<p class="wp-block-paragraph">Add your server IP and/or domain to ALLOWED_HOST entry in the <code>settings.py</code> file, then save it.</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img decoding="async" width="289" height="103" class="wp-image-2158" src="https://serverstadium.com/wp-content/uploads/2022/06/image-6.png" alt="" />
<figcaption>Allowed hosts configuration</figcaption>
</figure>
</div>


<p class="wp-block-paragraph">Good, now we are ready to do the deployment.</p>



<h3 class="has-vivid-cyan-blue-color has-text-color wp-block-heading">Server Preparation</h3>



<p class="wp-block-paragraph">We will need a specific user that we will use to serve the app, and it should be a non administrative user. To simplify, we will create <strong>apps</strong> user</p>



<pre class="wp-block-code"><code>sudo useradd --create-home --shell /bin/bash apps</code></pre>



<p class="wp-block-paragraph">We will also want to install supervisor and nginx from now</p>



<pre class="wp-block-code"><code>sudo apt update &amp;&amp; sudo apt install supervisor nginx</code></pre>



<p class="wp-block-paragraph">As mentioned earlier, we will be using Python 3.8, which isn&#8217;t available by default, so please take a look at this article on <a href="#" target="_blank" rel="noreferrer noopener">how to install Python 3.8 on Ubuntu 22.04 Jammy</a>. Don&#8217;t forget to install pip as well.</p>



<p class="wp-block-paragraph">Then install <code>pipenv</code> globally:</p>



<pre class="wp-block-code"><code>sudo pip install pipenv</code></pre>


<div class="wp-block-image">
<figure class="aligncenter size-full is-resized"><img loading="lazy" decoding="async" class="wp-image-2151" src="https://serverstadium.com/wp-content/uploads/2022/06/image-2.png" alt="" width="776" height="435" srcset="https://serverstadium.com/wp-content/uploads/2022/06/image-2.png 1034w, https://serverstadium.com/wp-content/uploads/2022/06/image-2-300x168.png 300w, https://serverstadium.com/wp-content/uploads/2022/06/image-2-1024x574.png 1024w, https://serverstadium.com/wp-content/uploads/2022/06/image-2-768x431.png 768w" sizes="(max-width: 776px) 100vw, 776px" />
<figcaption>Installing pipenv</figcaption>
</figure>
</div>


<h3 class="has-vivid-cyan-blue-color has-text-color wp-block-heading">Copy App Files</h3>



<p class="wp-block-paragraph">Copy or clone (using git if it&#8217;s supported) the app files to <code>/home/apps/django-app</code>. You can use FTP, SFTP, SCP or any other means of transferring local files to the remote server. On the remote server, the apps directory should look like follows:</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="705" height="531" class="wp-image-2150" src="https://serverstadium.com/wp-content/uploads/2022/06/carbon-2.png" alt="" srcset="https://serverstadium.com/wp-content/uploads/2022/06/carbon-2.png 705w, https://serverstadium.com/wp-content/uploads/2022/06/carbon-2-300x226.png 300w" sizes="(max-width: 705px) 100vw, 705px" />
<figcaption>django-app folder structure</figcaption>
</figure>
</div>


<h3 class="has-vivid-cyan-blue-color has-text-color wp-block-heading">Install Required Dependencies</h3>



<p class="wp-block-paragraph">A good thing about <code>pipenv</code> is that it will automatically create a virtual environment upon installing any required dependencies listed in the Pipfile. So, on the django-app folder run:</p>



<pre class="wp-block-code"><code># make sure it's on /home/apps/django-app
python3.8 -m pipenv install --deploy</code></pre>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1131" height="258" class="wp-image-2152" src="https://serverstadium.com/wp-content/uploads/2022/06/image-3.png" alt="" srcset="https://serverstadium.com/wp-content/uploads/2022/06/image-3.png 1131w, https://serverstadium.com/wp-content/uploads/2022/06/image-3-300x68.png 300w, https://serverstadium.com/wp-content/uploads/2022/06/image-3-1024x234.png 1024w, https://serverstadium.com/wp-content/uploads/2022/06/image-3-768x175.png 768w" sizes="(max-width: 1131px) 100vw, 1131px" /></figure>



<p class="wp-block-paragraph">Next, we will install gunicorn:</p>



<pre class="wp-block-code"><code>python3.8 -m pipenv install gunicorn</code></pre>



<p class="wp-block-paragraph">Then, we will try to serve the app using gunicorn to test, but make sure you run the gunicorn from the app folder where <code>manage.py</code> resides:</p>



<pre class="wp-block-code"><code>cd djangoapp/
python3.8 -m pipenv run gunicorn djangoapp.wsgi</code></pre>



<p class="wp-block-paragraph">It should return something like this:</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="729" height="77" class="wp-image-2155" src="https://serverstadium.com/wp-content/uploads/2022/06/image-4.png" alt="" srcset="https://serverstadium.com/wp-content/uploads/2022/06/image-4.png 729w, https://serverstadium.com/wp-content/uploads/2022/06/image-4-300x32.png 300w" sizes="(max-width: 729px) 100vw, 729px" />
<figcaption>Serving django via gunicorn</figcaption>
</figure>
</div>


<p class="wp-block-paragraph">Awesome. Now we can setup <code>supervisor</code> to handle gunicorn process(es).</p>



<h3 class="has-vivid-cyan-blue-color has-text-color wp-block-heading">Install and Configure Supervisor</h3>



<p class="wp-block-paragraph">For <strong>Debian-based</strong> distros, run:</p>



<pre class="wp-block-code"><code>sudo apt install supervisor</code></pre>



<p class="wp-block-paragraph">For <strong>RHEL-based</strong> distros, run:</p>



<pre class="wp-block-code"><code>sudo dnf install supervisor
# or
sudo yum install supervisor</code></pre>



<p class="wp-block-paragraph">Then, we will create a config file for the django app in <code>/etc/supervisor/conf.d/</code> and name it as <code>django-app.conf</code>. Write or just copy the following lines to the file:</p>



<pre class="wp-block-code"><code>[program:django-app]
user=apps
directory=/home/apps/django-app/djangoapp
command=/usr/local/bin/pipenv run gunicorn --workers=3 djangoapp.wsgi

autostart=true
autorestart=true
stdout_logfile=/home/apps/logs/django-app.log
stderr_logfile=/home/apps/logs/django-app.err.log</code></pre>



<p class="wp-block-paragraph">Don&#8217;t forget to create the <code>./logs/</code> folder to store the app&#8217;s logs:</p>



<pre class="wp-block-code"><code># as the apps user
mkdir /home/apps/logs</code></pre>



<p class="wp-block-paragraph">Then restart supervisor:</p>



<pre class="wp-block-code"><code>sudo systemctl restart supervisor</code></pre>



<p class="wp-block-paragraph">Make sure it&#8217;s running by checking supervisor status:</p>



<pre class="wp-block-code"><code>sudo systemctl status supervisor</code></pre>


<div class="wp-block-image">
<figure class="aligncenter size-full is-resized"><img loading="lazy" decoding="async" class="wp-image-2156" src="https://serverstadium.com/wp-content/uploads/2022/06/image-5.png" alt="" width="792" height="311" srcset="https://serverstadium.com/wp-content/uploads/2022/06/image-5.png 1056w, https://serverstadium.com/wp-content/uploads/2022/06/image-5-300x118.png 300w, https://serverstadium.com/wp-content/uploads/2022/06/image-5-1024x401.png 1024w, https://serverstadium.com/wp-content/uploads/2022/06/image-5-768x301.png 768w" sizes="(max-width: 792px) 100vw, 792px" />
<figcaption>Supervisor status</figcaption>
</figure>
</div>


<p class="wp-block-paragraph">Next, we will install and configure Nginx so it proxies the connection.</p>



<h3 class="has-vivid-cyan-blue-color has-text-color wp-block-heading">Install and Configure NGINX</h3>



<p class="wp-block-paragraph">Here, nginx will proxy HTTP connections to the gunicorn workers. This will also make SSL setup easier, but I won&#8217;t explain it here. Install nginx and make sure it&#8217;s started on boot:</p>



<pre class="wp-block-code"><code>sudo apt install nginx
sudo systemctl enable nginx --now</code></pre>



<p class="wp-block-paragraph">Then create a new config file in <code>/etc/nginx/sites-available</code> for Ubuntu-based distros, RHEL-based ones should be in <code>/etc/nginx/conf.d</code></p>



<pre class="wp-block-code"><code>server {
    listen 80;
    
    location / {
        include proxy_params;
        proxy_pass http://localhost:8000;
    }
}</code></pre>



<p class="wp-block-paragraph">Save it as <code>django-app.conf</code>. Then for Ubuntu-based distro only, create a symlink in <code>/etc/nginx/sites-enabled/</code> for the config file:</p>



<pre class="wp-block-code"><code>sudo ln -s /etc/nginx/sites-available/django-app.conf /etc/nginx/sites-enabled/django-app.conf</code></pre>



<p class="wp-block-paragraph">Remove the default site config</p>



<pre class="wp-block-code"><code>sudo unlink /etc/nginx/sites-enabled/default</code></pre>



<p class="wp-block-paragraph">For RHEL-based distros, one might need to remove the default config or rename the extension to <code>.bak</code> or something else. Then, test nginx and reload it</p>



<pre class="wp-block-code"><code>sudo nginx -t
sudo nginx -s reload</code></pre>



<h3 class="has-vivid-cyan-blue-color has-text-color wp-block-heading">Access Test</h3>



<p class="wp-block-paragraph">Finally, test it from your browser via <code>http://YOUR-IP</code> or <code>http://YOUR-DOMAIN.TLD</code></p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1040" height="541" class="wp-image-2159" src="https://serverstadium.com/wp-content/uploads/2022/06/image-7.png" alt="" srcset="https://serverstadium.com/wp-content/uploads/2022/06/image-7.png 1040w, https://serverstadium.com/wp-content/uploads/2022/06/image-7-300x156.png 300w, https://serverstadium.com/wp-content/uploads/2022/06/image-7-1024x533.png 1024w, https://serverstadium.com/wp-content/uploads/2022/06/image-7-768x400.png 768w" sizes="(max-width: 1040px) 100vw, 1040px" /></figure>



<p class="wp-block-paragraph">Yay! You&#8217;re now able to deploy your Django app!</p>



<p class="wp-block-paragraph"><strong>IMPORTANT NOTE:</strong> This is a basic setup that is insecure. For a complete documentation on how to configure your Django so it fits production deployment, please refer to <a href="https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/" target="_blank" rel="noreferrer noopener nofollow">this official documentation</a></p>



<h2 class="has-vivid-cyan-blue-color has-text-color wp-block-heading">Conclusion</h2>



<p class="wp-block-paragraph">We just learned how to deploy a django application using Pipenv as the virtual environment tool, Gunicorn as the Web Server Gateway, Supervisor as the process manager, and NGINX as the reverse proxy.</p>



<p class="wp-block-paragraph">Find more tutorial articles in ServerStadium&#8217;s <a href="https://serverstadium.com/knowledge-base/" target="_blank" rel="noreferrer noopener">Knowledge Base</a>,  <a href="https://cp.serverstadium.com/regist-user" target="_blank" rel="noreferrer noopener"> Register now</a> for free in ServerStadium&#8217;s panel to try our cloud VMs.</p>
<p>The post <a href="https://serverstadium.com/knowledge-base/how-to-deploy-django-app-on-serverstadium-vm-using-gunicorn-supervisor-and-nginx/">How to Deploy Django App on ServerStadium VM Using Gunicorn, Supervisor, and Nginx</a> appeared first on <a href="https://serverstadium.com">ServerStadium</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>How to Install Node.js and Launch Your First Node App</title>
		<link>https://serverstadium.com/knowledge-base/how-to-install-node-js-and-launch-your-first-node-app/</link>
		
		<dc:creator><![CDATA[Brian K]]></dc:creator>
		<pubDate>Thu, 15 Apr 2021 03:42:50 +0000</pubDate>
				<guid isPermaLink="false">https://cloudraya.com/knowledge-base/?p=718</guid>

					<description><![CDATA[<p>The popularity of Node.js has increased recently, which makes &#8216;how to install node.js&#8217; a hot topic around the internet. But let&#8217;s discuss what Node.js is. Node.js is a server-side Javascript that makes dev can write the front-end and back-end of web applications in Javascript more easily and efficiently. Node.js is an open-source application under MIT&#8230;</p>
<p>The post <a href="https://serverstadium.com/knowledge-base/how-to-install-node-js-and-launch-your-first-node-app/">How to Install Node.js and Launch Your First Node App</a> appeared first on <a href="https://serverstadium.com">ServerStadium</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">The popularity of Node.js has increased recently, which makes &#8216;how to install node.js&#8217; a hot topic around the internet. But let&#8217;s discuss what Node.js is.<br /><br />Node.js is a server-side Javascript that makes dev can write the front-end and back-end of web applications in Javascript more easily and efficiently. Node.js is an open-source application under MIT License.<br /><br />This tutorial will teach us how to install node.js using the Ubuntu repository, PPA, or NVM. <br />And we will learn how to launch your simple app using node.js.</p>



<ol class="wp-block-list" type="1">
<li>Using Ubuntu repository. We will install using stable nodejs with command apt</li>
<li>Install nodejs using PPA (Personal Package Archive) repository.</li>
<li>Use and install multiple nodejs using NVM (NodeJS Version Manager).</li>
</ol>



<h2 class="has-vivid-cyan-blue-color has-text-color wp-block-heading">Install Node.js using Ubuntu Repository</h2>



<p class="wp-block-paragraph">Please ssh your server on Cloudraya and make sure you have created a security profile to allow accessing your server.</p>



<p class="wp-block-paragraph">After you login into your server, run the command below:</p>



<pre class="wp-block-preformatted"># apt update</pre>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="663" height="186" class="wp-image-743" src="https://serverstadium.com/wp-content/uploads/2021/01/image-6.png" alt="" srcset="https://serverstadium.com/wp-content/uploads/2021/01/image-6.png 663w, https://serverstadium.com/wp-content/uploads/2021/01/image-6-300x84.png 300w" sizes="(max-width: 663px) 100vw, 663px" /></figure>



<pre class="wp-block-preformatted"># apt install nodejs</pre>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="556" height="239" class="wp-image-745" src="https://serverstadium.com/wp-content/uploads/2021/01/image-8.png" alt="" srcset="https://serverstadium.com/wp-content/uploads/2021/01/image-8.png 556w, https://serverstadium.com/wp-content/uploads/2021/01/image-8-300x129.png 300w" sizes="(max-width: 556px) 100vw, 556px" /></figure>



<p class="wp-block-paragraph">Run the command below to find nodejs version:</p>



<pre class="wp-block-preformatted"># nodejs -v</pre>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="269" height="35" class="wp-image-746" src="https://serverstadium.com/wp-content/uploads/2021/01/image-9.png" alt="" /></figure>



<p class="wp-block-paragraph">If you want to find some module or package of nodejs, we can use NPM (NodeJS Package Manager). You can install it using the command :</p>



<pre class="wp-block-preformatted">#apt install npm</pre>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="615" height="47" class="wp-image-748" src="https://serverstadium.com/wp-content/uploads/2021/01/image-11.png" alt="" srcset="https://serverstadium.com/wp-content/uploads/2021/01/image-11.png 615w, https://serverstadium.com/wp-content/uploads/2021/01/image-11-300x23.png 300w" sizes="(max-width: 615px) 100vw, 615px" /></figure>



<pre class="wp-block-preformatted"># npm -v</pre>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="257" height="30" class="wp-image-750" src="https://serverstadium.com/wp-content/uploads/2021/01/image-13.png" alt="" /></figure>



<p class="wp-block-paragraph">Now your server is ready to use nodejs.</p>



<h2 class="has-vivid-cyan-blue-color has-text-color wp-block-heading">Install Node.js Using PPA (Personal Package Archive) Repository</h2>



<p class="wp-block-paragraph">If we want to use nodejs with the latest version, we can use nodejs using PPA Repository that is maintained by NodeSource.</p>



<p class="wp-block-paragraph">We can find version nodejs on <a href="https://github.com/nodesource/distributions">https://github.com/nodesource/distributions</a>.<br />Run the command below to install nodejs v.12.</p>



<pre class="wp-block-preformatted"># curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
sudo apt-get install -y nodejs</pre>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="659" height="104" class="wp-image-751" src="https://serverstadium.com/wp-content/uploads/2021/01/image-14.png" alt="" srcset="https://serverstadium.com/wp-content/uploads/2021/01/image-14.png 659w, https://serverstadium.com/wp-content/uploads/2021/01/image-14-300x47.png 300w" sizes="(max-width: 659px) 100vw, 659px" /></figure>



<p class="wp-block-paragraph">If we use nodejs from PPA, npm is automatically installed on your server.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="284" height="62" class="wp-image-753" src="https://serverstadium.com/wp-content/uploads/2021/01/image-16.png" alt="" /></figure>



<p class="wp-block-paragraph">&nbsp;</p>



<h2 class="has-vivid-cyan-blue-color has-text-color wp-block-heading">Install Node.js Using NVM (NodeJS Version Manager)</h2>



<p class="wp-block-paragraph">Nodejs allow us to install multiple nodejs versions on the server.<br />We recommend you use nodejs with NodeJs Version Manager (NVM). After we install nodejs using NVM, we can change the default nodejs version if we install multiple nodejs on the server.</p>



<p class="wp-block-paragraph">Below is how to install nodejs using NVM:</p>



<pre class="wp-block-preformatted"># apt install build-essential libssl-dev</pre>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="528" height="212" class="wp-image-754" src="https://serverstadium.com/wp-content/uploads/2021/01/image-17.png" alt="" srcset="https://serverstadium.com/wp-content/uploads/2021/01/image-17.png 528w, https://serverstadium.com/wp-content/uploads/2021/01/image-17-300x120.png 300w" sizes="(max-width: 528px) 100vw, 528px" /></figure>



<pre class="wp-block-preformatted"># curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash</pre>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="740" height="299" class="wp-image-755" src="https://serverstadium.com/wp-content/uploads/2021/01/image-18.png" alt="" srcset="https://serverstadium.com/wp-content/uploads/2021/01/image-18.png 740w, https://serverstadium.com/wp-content/uploads/2021/01/image-18-300x121.png 300w" sizes="(max-width: 740px) 100vw, 740px" /></figure>



<p class="wp-block-paragraph">After the installation is completed, please allow NVM to run on bash profile user .</p>



<pre class="wp-block-preformatted"># source ~/.profile</pre>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="344" height="40" class="wp-image-756" src="https://serverstadium.com/wp-content/uploads/2021/01/image-19.png" alt="" srcset="https://serverstadium.com/wp-content/uploads/2021/01/image-19.png 344w, https://serverstadium.com/wp-content/uploads/2021/01/image-19-300x35.png 300w" sizes="(max-width: 344px) 100vw, 344px" /></figure>



<p class="wp-block-paragraph">List the nodejs version using the command below:</p>



<pre class="wp-block-preformatted"># nvm ls-remote</pre>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="421" height="331" class="wp-image-765" src="https://serverstadium.com/wp-content/uploads/2021/01/image-26.png" alt="" srcset="https://serverstadium.com/wp-content/uploads/2021/01/image-26.png 421w, https://serverstadium.com/wp-content/uploads/2021/01/image-26-300x236.png 300w" sizes="(max-width: 421px) 100vw, 421px" /></figure>



<p class="wp-block-paragraph">In this article, we will use nodejs LTS version with version 14.</p>



<pre class="wp-block-preformatted"># nvm install 14.15.3</pre>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="616" height="125" class="wp-image-758" src="https://serverstadium.com/wp-content/uploads/2021/01/image-21.png" alt="" srcset="https://serverstadium.com/wp-content/uploads/2021/01/image-21.png 616w, https://serverstadium.com/wp-content/uploads/2021/01/image-21-300x61.png 300w" sizes="(max-width: 616px) 100vw, 616px" /></figure>



<p class="wp-block-paragraph">As we know, using NVM we can run multiple nodejs version on the server.<br />Now we will install nodejs version 8.</p>



<pre class="wp-block-preformatted"># nvm install 8.17.0</pre>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="619" height="111" class="wp-image-759" src="https://serverstadium.com/wp-content/uploads/2021/01/image-22.png" alt="" srcset="https://serverstadium.com/wp-content/uploads/2021/01/image-22.png 619w, https://serverstadium.com/wp-content/uploads/2021/01/image-22-300x54.png 300w" sizes="(max-width: 619px) 100vw, 619px" /></figure>



<p class="wp-block-paragraph">Please run the command below to find nodejs version that is installed on the server.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="297" height="228" class="wp-image-762" src="https://serverstadium.com/wp-content/uploads/2021/01/image-24.png" alt="" /></figure>



<p class="wp-block-paragraph">We can see if the default nodejs on the server is nodejs version 14.<br />If we want to change the nodejs version 8, we can use the command below:</p>



<pre class="wp-block-preformatted"># nvm use 8</pre>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="295" height="63" class="wp-image-763" src="https://serverstadium.com/wp-content/uploads/2021/01/image-25.png" alt="" /></figure>



<p class="wp-block-paragraph">&nbsp;</p>



<h2 class="has-vivid-cyan-blue-color has-text-color wp-block-heading"><strong>Launch </strong>Y<strong>our First Node App</strong></h2>



<p class="wp-block-paragraph">After we know how to install nodejs on the server using many different ways. Now we can learn how to launch your first node App on the server.</p>



<p class="wp-block-paragraph">Create folder nodejsapp and create a file as app.js</p>



<pre class="wp-block-preformatted">#mkdir nodejsapp
#cd nodejsapp
#nano app.js</pre>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="363" height="46" class="wp-image-766" src="https://serverstadium.com/wp-content/uploads/2021/01/image-27.png" alt="" srcset="https://serverstadium.com/wp-content/uploads/2021/01/image-27.png 363w, https://serverstadium.com/wp-content/uploads/2021/01/image-27-300x38.png 300w" sizes="(max-width: 363px) 100vw, 363px" /></figure>



<p class="wp-block-paragraph">Append the code below on file app.js</p>



<pre class="wp-block-preformatted">console.log('This NodeJS Application in Cloudraya');</pre>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="404" height="109" class="wp-image-767" src="https://serverstadium.com/wp-content/uploads/2021/01/image-28.png" alt="" srcset="https://serverstadium.com/wp-content/uploads/2021/01/image-28.png 404w, https://serverstadium.com/wp-content/uploads/2021/01/image-28-300x81.png 300w" sizes="(max-width: 404px) 100vw, 404px" /></figure>



<p class="wp-block-paragraph">Press Ctrl + x to save and quit from the editor.</p>



<p class="wp-block-paragraph">Run the command below to execute the code of app.js</p>



<pre class="wp-block-preformatted">#chmod +x app.js
#nodejs app.js or node app.js (if you use NVM)</pre>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="394" height="48" class="wp-image-768" src="https://serverstadium.com/wp-content/uploads/2021/01/image-29.png" alt="" srcset="https://serverstadium.com/wp-content/uploads/2021/01/image-29.png 394w, https://serverstadium.com/wp-content/uploads/2021/01/image-29-300x37.png 300w" sizes="(max-width: 394px) 100vw, 394px" /></figure>



<h2 class="has-vivid-cyan-blue-color has-text-color wp-block-heading"><strong>Create Local Webserver</strong></h2>



<p class="wp-block-paragraph">Nodejs is a client-side server language which means we can run it without any webserver like nginx or apache. With nodejs we can create a local webserver on the server.<br /><br />First, we create a file server.js and append the code below on the file</p>



<pre class="wp-block-preformatted"># nano server.js</pre>



<pre class="wp-block-preformatted">var http = require('http');<br />var server = http.createServer(function (req, res) {<br />        res.writeHead(200,{'Content-Type': 'text/plain'});<br />        res.end('NodeJS App');<br />});<br />server.listen(5050);<br />console.log('Server is running at <a href="http://localhost:5050/">http://localhost:5050/</a>');</pre>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="440" height="180" class="wp-image-769" src="https://serverstadium.com/wp-content/uploads/2021/01/image-30.png" alt="" srcset="https://serverstadium.com/wp-content/uploads/2021/01/image-30.png 440w, https://serverstadium.com/wp-content/uploads/2021/01/image-30-300x123.png 300w" sizes="(max-width: 440px) 100vw, 440px" /></figure>



<p class="wp-block-paragraph">Exit from the edit by press Ctrl + x to save and quit.</p>



<p class="wp-block-paragraph">The code we have appended on the file means making a server connection on port 5050. Please run the command below to run the local webserver</p>



<pre class="wp-block-preformatted"># nodejs server.js / node server.js (NVM)</pre>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="382" height="76" class="wp-image-771" src="https://serverstadium.com/wp-content/uploads/2021/01/image-32.png" alt="" srcset="https://serverstadium.com/wp-content/uploads/2021/01/image-32.png 382w, https://serverstadium.com/wp-content/uploads/2021/01/image-32-300x60.png 300w" sizes="(max-width: 382px) 100vw, 382px" /></figure>



<p class="wp-block-paragraph">Now we can reach the node app via http://ip_address_server:5050 from any browser.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="502" height="283" class="wp-image-772" src="https://serverstadium.com/wp-content/uploads/2021/01/image-33.png" alt="" srcset="https://serverstadium.com/wp-content/uploads/2021/01/image-33.png 502w, https://serverstadium.com/wp-content/uploads/2021/01/image-33-300x169.png 300w" sizes="(max-width: 502px) 100vw, 502px" /></figure>



<p class="wp-block-paragraph">If you see the message above, you successfully launched the node app on the ServerStadium VM server.<br />Please submit your question to our Support if you need more assistance.</p>
<p>The post <a href="https://serverstadium.com/knowledge-base/how-to-install-node-js-and-launch-your-first-node-app/">How to Install Node.js and Launch Your First Node App</a> appeared first on <a href="https://serverstadium.com">ServerStadium</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>How to Setup Your Own Laravel with Nginx in Ubuntu 18.04</title>
		<link>https://serverstadium.com/knowledge-base/how-to-setup-your-own-laravel-with-nginx-in-ubuntu-18-04/</link>
		
		<dc:creator><![CDATA[Brian K]]></dc:creator>
		<pubDate>Thu, 07 Jan 2021 07:01:21 +0000</pubDate>
				<guid isPermaLink="false">https://cloudraya.com/knowledge-base/?p=685</guid>

					<description><![CDATA[<p>This tutorial will help you setup Laravel with Nginx in Ubuntu. In this tutorial, we will use Ubuntu 18 server to deploy Laravel. Laravel is a web application framework written in PHP language. To setup Laravel in your Ubuntu Server with Nginx, we need to install the following requirements below: The web server The database PHP&#8230;</p>
<p>The post <a href="https://serverstadium.com/knowledge-base/how-to-setup-your-own-laravel-with-nginx-in-ubuntu-18-04/">How to Setup Your Own Laravel with Nginx in Ubuntu 18.04</a> appeared first on <a href="https://serverstadium.com">ServerStadium</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">This tutorial will help you setup Laravel with <a href="https://serverstadium.com/knowledge-base/installing-lemp-stack-on-ubuntu-1804/">Nginx</a> in <a href="https://serverstadium.com/knowledge-base/installing-lamp-in-ubuntu/">Ubuntu</a>. In this tutorial, we will use Ubuntu 18 server to deploy Laravel. Laravel is a web application framework written in PHP language.</p>



<p class="wp-block-paragraph">To setup Laravel in your Ubuntu Server with Nginx, we need to install the following requirements below:</p>



<ul class="wp-block-list">
<li>The web server</li>
<li>The database</li>
<li>PHP 7.2</li>
<li>Composer</li>
<li>Laravel</li>
</ul>



<p class="wp-block-paragraph">In this case, we use Nginx as the web server software and Mariadb as the database software. Also, we only have to open the default port on ServerStadium Default Security Profile which is only open port 22, 80 and 443.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="803" height="387" class="wp-image-687" src="https://serverstadium.com/wp-content/uploads/2021/01/fw-img.png" alt="" srcset="https://serverstadium.com/wp-content/uploads/2021/01/fw-img.png 803w, https://serverstadium.com/wp-content/uploads/2021/01/fw-img-300x145.png 300w, https://serverstadium.com/wp-content/uploads/2021/01/fw-img-768x370.png 768w" sizes="(max-width: 803px) 100vw, 803px" /></figure>



<p class="wp-block-paragraph">Without further ado, here are the steps to setup Laravel with Nginx in Ubuntu 18.04.</p>



<h2 class="has-vivid-cyan-blue-color has-text-color wp-block-heading">Step 1 – Install Nginx</h2>



<p class="wp-block-paragraph">Firstly, you can run “sudo apt-get update” to download package information from all configured sources.</p>



<p class="wp-block-paragraph">Then to install nginx you can run the following command below:</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p>apt-get install nginx</p>
</blockquote>



<p class="wp-block-paragraph">After the installation process is complete, you can check nginx status by run:</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p>systemctl status nginx</p>
</blockquote>



<p class="wp-block-paragraph">And the output should be like this if nginx is active.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="994" height="257" class="wp-image-688" src="https://serverstadium.com/wp-content/uploads/2021/01/nginx-status-img.png" alt="" srcset="https://serverstadium.com/wp-content/uploads/2021/01/nginx-status-img.png 994w, https://serverstadium.com/wp-content/uploads/2021/01/nginx-status-img-300x78.png 300w, https://serverstadium.com/wp-content/uploads/2021/01/nginx-status-img-768x199.png 768w" sizes="(max-width: 994px) 100vw, 994px" /></figure>



<p class="wp-block-paragraph">Or you can check it by opening your server IP public on your browser, and the page will display Apache2 Ubuntu Default Page as below.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1422" height="812" class="wp-image-690" src="https://serverstadium.com/wp-content/uploads/2021/01/pict03.png" alt="" srcset="https://serverstadium.com/wp-content/uploads/2021/01/pict03.png 1422w, https://serverstadium.com/wp-content/uploads/2021/01/pict03-300x171.png 300w, https://serverstadium.com/wp-content/uploads/2021/01/pict03-1024x585.png 1024w, https://serverstadium.com/wp-content/uploads/2021/01/pict03-768x439.png 768w" sizes="(max-width: 1422px) 100vw, 1422px" /></figure>



<h2 class="has-vivid-cyan-blue-color has-text-color wp-block-heading">Step 2 – Install MariaDB</h2>



<p class="wp-block-paragraph">The second step is to install the database or MariaDB. To install it, you can use the following command:</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p>apt install mariadb-server</p>
</blockquote>



<p class="wp-block-paragraph">Since we use the default source, At the time of writing, the version of MariaDB is 10.1.47. To check mariadb status, you can run this command:</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p>systemctl status mariadb.service</p>
</blockquote>



<p class="wp-block-paragraph">The output will be like this if the service is running.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1033" height="336" class="wp-image-691" src="https://serverstadium.com/wp-content/uploads/2021/01/pict04.png" alt="" srcset="https://serverstadium.com/wp-content/uploads/2021/01/pict04.png 1033w, https://serverstadium.com/wp-content/uploads/2021/01/pict04-300x98.png 300w, https://serverstadium.com/wp-content/uploads/2021/01/pict04-1024x333.png 1024w, https://serverstadium.com/wp-content/uploads/2021/01/pict04-768x250.png 768w" sizes="(max-width: 1033px) 100vw, 1033px" /></figure>



<p class="wp-block-paragraph">With the following command above, the database is already installed, and you can login to the mysql without any password using root user. But if you want to setup the user for the mysql you can run the following command below and setup the password for root user.</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p>mysql_secure_installation</p>
</blockquote>



<h2 class="has-vivid-cyan-blue-color has-text-color wp-block-heading">Step 3 – Install PHP 7.2</h2>



<p class="wp-block-paragraph">PHP 7.2 is included in the default Ubuntu repository for 18.04. We can list each of the available PHP 7.2 packages with the following command:</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p>apt-cache pkgnames | grep php7.2</p>
</blockquote>



<p class="wp-block-paragraph">Next, we can install the packages that our application requires by typing:</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p>apt-get install php curl git unzip</p>
</blockquote>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p>apt-get install php-pear php-fpm php-dev php-zip php-curl php-xmlrpc php-gd php-mysql php-mbstring php-xml libapache2-mod-php</p>
</blockquote>



<p class="wp-block-paragraph">Finally, we can restart nginx to allow PHP to run:</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p>systemctl restart nginx</p>
</blockquote>



<p class="wp-block-paragraph">Then, we can confirm the PHP version by type:</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p>php –version</p>
</blockquote>



<p class="wp-block-paragraph">Here is the output of the checking command version above.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="679" height="79" class="wp-image-692" src="https://serverstadium.com/wp-content/uploads/2021/01/pict05.png" alt="" srcset="https://serverstadium.com/wp-content/uploads/2021/01/pict05.png 679w, https://serverstadium.com/wp-content/uploads/2021/01/pict05-300x35.png 300w" sizes="(max-width: 679px) 100vw, 679px" /></figure>



<h2 class="has-vivid-cyan-blue-color has-text-color wp-block-heading">Step 4 – Install composser</h2>



<p class="wp-block-paragraph">Since composer is already part of the repository, we can install it using the following command below.</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p>apt-get install composer</p>
</blockquote>



<p class="wp-block-paragraph">To ensure that the composer is already installed, we can check it by running command “composer” and it will show the manual as below.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1091" height="835" class="wp-image-693" src="https://serverstadium.com/wp-content/uploads/2021/01/pict06.png" alt="" srcset="https://serverstadium.com/wp-content/uploads/2021/01/pict06.png 1091w, https://serverstadium.com/wp-content/uploads/2021/01/pict06-300x230.png 300w, https://serverstadium.com/wp-content/uploads/2021/01/pict06-1024x784.png 1024w, https://serverstadium.com/wp-content/uploads/2021/01/pict06-768x588.png 768w" sizes="(max-width: 1091px) 100vw, 1091px" /></figure>



<h2 class="has-vivid-cyan-blue-color has-text-color wp-block-heading">Step 5 – Install Laravel using composer</h2>



<p class="wp-block-paragraph">When installing laravel or creating a laravel project, you must enter the directory where you want to save the project data, or you can create the project first and then move the data to the right locale where you want to save it.</p>



<p class="wp-block-paragraph">In this tutorial, I use /var/www/html as my data storage location, and my project name is testlaravel. Then to install laravel you can run this command below.</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p>composer create-project &#8211;prefer-dist laravel/laravel [projectName]</p>
</blockquote>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="607" height="586" class="wp-image-694" src="https://serverstadium.com/wp-content/uploads/2021/01/pict07.png" alt="" srcset="https://serverstadium.com/wp-content/uploads/2021/01/pict07.png 607w, https://serverstadium.com/wp-content/uploads/2021/01/pict07-300x290.png 300w" sizes="(max-width: 607px) 100vw, 607px" /></figure>



<p class="wp-block-paragraph">FYI, in the picture above, I give my project name &#8220;laraveltest&#8221; <br /><br />After laravel installation is complete, you can move the project folder to /var/www/html/ then change the owner of the project to www-data with the following command below.</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p>sudo mv [projectName] /var/www/html/</p>
</blockquote>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p>chown -R www-data:www-data /var/www/html/[projectName]/</p>
</blockquote>



<p class="wp-block-paragraph">Now the next step is to config the virtual host so we can access the website through our browser. You can use the following command below to edit the virtual host file.</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p>nano /etc/nginx/sites-available/vhostlaravel.conf</p>
</blockquote>



<p class="wp-block-paragraph">After the text editor is opened, we can use the simple config below. <br /><br />NB: <br />&#8211; If you have a different project location change the root document location with your project location.</p>



<pre class="wp-block-code"><code>server {
     listen 80;
     listen [::]:80 ipv6only=on;

     # Log files for Debugging
     access_log /var/log/nginx/vhostlaravel-access.log;
     error_log /var/log/nginx/vhostlaravel-error.log;

     # Webroot Directory for Laravel project
     root /var/www/html/laraveltest/public;
     index index.php index.html index.htm;

     # Your Domain Name
     server_name www.your_domain.com your_domain.com;

     location / {
             try_files $uri $uri/ /index.php?$query_string;
     }

     # PHP-FPM Configuration Nginx
     location ~ \.php$ {
             try_files $uri =404;
             fastcgi_split_path_info ^(.+\.php)(/.+)$;
             fastcgi_pass unix:/run/php/php7.2-fpm.sock;
             fastcgi_index index.php;
             fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
             include fastcgi_params;
     }
}</code></pre>



<p class="wp-block-paragraph">After we save the config, we need to create links file of the virtual host from /etc/nginx/sites-available to /etc/nginx/sites-enabled by using the following command below.</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p>ln -s /etc/nginx/sites-available/vhostlaravel.conf /etc/nginx/sites-enabled/</p>
</blockquote>



<p class="wp-block-paragraph">Then we must test the virtual host config using the simple command &#8220;nginx -t&#8221;. Accordingly, if your virtual host config is correct, it will give an output like this:</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="516" height="47" class="wp-image-695" src="https://serverstadium.com/wp-content/uploads/2021/01/pict09.png" alt="" srcset="https://serverstadium.com/wp-content/uploads/2021/01/pict09.png 516w, https://serverstadium.com/wp-content/uploads/2021/01/pict09-300x27.png 300w" sizes="(max-width: 516px) 100vw, 516px" /></figure>



<p class="wp-block-paragraph">After the output says that syntax is OK we can restart nginx to apply the virtual host using the following command below.</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p>systemctl restart nginx</p>
</blockquote>



<p class="wp-block-paragraph">To test our laravel project, we can change our local resolver file.<br />If you are on a Mac or Linux computer at home, you can edit the file needed by typing:</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p>nano /etc/hosts</p>
</blockquote>



<p class="wp-block-paragraph"><br />If you are using Windows desktop, you can edit file &#8220;hosts&#8221; from the notepad by accessing this folder:</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p>C:\Windows\System32\drivers\etc</p>
</blockquote>



<p class="wp-block-paragraph">Then assuming that your server’s public IP address is 97.22.10.9 , the lines we need to add to the &#8220;hosts&#8221; file would look something like this:</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p>97.22.10.9 www.your_domain.com your_domain.com</p>
</blockquote>



<p class="wp-block-paragraph">Finally, we can test to access our Laravel project through the browser, and the output will look like this.</p>



<figure class="wp-block-image size-large is-resized"><img loading="lazy" decoding="async" class="wp-image-697" src="https://serverstadium.com/wp-content/uploads/2021/01/laravel-home-page-1.png" alt="" width="580" height="310" srcset="https://serverstadium.com/wp-content/uploads/2021/01/laravel-home-page-1.png 1597w, https://serverstadium.com/wp-content/uploads/2021/01/laravel-home-page-1-300x161.png 300w, https://serverstadium.com/wp-content/uploads/2021/01/laravel-home-page-1-1024x548.png 1024w, https://serverstadium.com/wp-content/uploads/2021/01/laravel-home-page-1-768x411.png 768w, https://serverstadium.com/wp-content/uploads/2021/01/laravel-home-page-1-1536x822.png 1536w" sizes="(max-width: 580px) 100vw, 580px" /></figure>



<p class="wp-block-paragraph">&nbsp;</p>
<p>The post <a href="https://serverstadium.com/knowledge-base/how-to-setup-your-own-laravel-with-nginx-in-ubuntu-18-04/">How to Setup Your Own Laravel with Nginx in Ubuntu 18.04</a> appeared first on <a href="https://serverstadium.com">ServerStadium</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Install a Node.js and Launch a Node App on Ubuntu 18.04</title>
		<link>https://serverstadium.com/knowledge-base/install-a-nodejs-and-launch-a-node-app-on-ubuntu-1804/</link>
		
		<dc:creator><![CDATA[Brian K]]></dc:creator>
		<pubDate>Fri, 02 Oct 2020 08:45:47 +0000</pubDate>
				<guid isPermaLink="false">https://cloudraya.com/knowledge-base/?p=407</guid>

					<description><![CDATA[<p>In this article, we would like to discuss &#8220;how to install Node.js on Ubuntu 18.04&#8221;. This method can be performed on Dedicated Server/Bare metal and Virtual Private Servers or Virtual machines like ServerStadium Cloud. However, this article will guide you on installing Node.JS on Virtual Machine with Ubuntu 18.04 installed. Node.js is a JavaScript platform for&#8230;</p>
<p>The post <a href="https://serverstadium.com/knowledge-base/install-a-nodejs-and-launch-a-node-app-on-ubuntu-1804/">Install a Node.js and Launch a Node App on Ubuntu 18.04</a> appeared first on <a href="https://serverstadium.com">ServerStadium</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">In this article, we would like to discuss &#8220;how to install Node.js on Ubuntu 18.04&#8221;. This method can be performed on <a href="http://ServerStadium.com" target="_blank" rel="noreferrer noopener">Dedicated Server/Bare metal </a>and Virtual Private Servers or Virtual machines like <a href="https://serverstadium.com" target="_blank" rel="noreferrer noopener">ServerStadium Cloud</a>.</p>



<p class="wp-block-paragraph">However, this article will guide you on installing Node.JS on Virtual Machine with Ubuntu 18.04 installed.</p>



<p class="wp-block-paragraph">Node.js is a JavaScript platform for general-purpose programming that allows users to build network applications quickly. By leveraging JavaScript on both the front and backend, Node.js makes development more consistent and integrated.</p>



<h2 class="has-vivid-cyan-blue-color has-text-color wp-block-heading"><strong>Prerequisites</strong></h2>



<p class="wp-block-paragraph">Before we begin the tutorial, the following are the stack versions that we are going to install:</p>



<ul class="wp-block-list">
<li>OS: Ubuntu 18.04</li>
<li>Latest Node.js stable version for Ubuntu 18.04</li>
<li>Latest NPM</li>
</ul>



<h3 class="has-vivid-cyan-blue-color has-text-color wp-block-heading">Install Node.js</h3>



<pre class="wp-block-preformatted">apt update</pre>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="764" height="234" class="wp-image-462" src="https://serverstadium.com/wp-content/uploads/2020/09/image-51.png" alt="" srcset="https://serverstadium.com/wp-content/uploads/2020/09/image-51.png 764w, https://serverstadium.com/wp-content/uploads/2020/09/image-51-300x92.png 300w" sizes="(max-width: 764px) 100vw, 764px" /></figure>



<pre class="wp-block-preformatted">apt install nodejs</pre>



<p class="wp-block-paragraph">By default, from upstream, it will install Node.js 8.10.0 version</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="567" height="237" class="wp-image-463" src="https://serverstadium.com/wp-content/uploads/2020/09/image-52.png" alt="" srcset="https://serverstadium.com/wp-content/uploads/2020/09/image-52.png 567w, https://serverstadium.com/wp-content/uploads/2020/09/image-52-300x125.png 300w" sizes="(max-width: 567px) 100vw, 567px" /></figure>



<p class="wp-block-paragraph">Please type &#8220;y&#8221; to continue the installation process.</p>



<pre class="wp-block-preformatted">nodejs -v</pre>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="315" height="62" class="wp-image-464" src="https://serverstadium.com/wp-content/uploads/2020/09/image-53.png" alt="" srcset="https://serverstadium.com/wp-content/uploads/2020/09/image-53.png 315w, https://serverstadium.com/wp-content/uploads/2020/09/image-53-300x59.png 300w" sizes="(max-width: 315px) 100vw, 315px" /></figure>



<p class="wp-block-paragraph">Or, If you would like to install with another or specific Node.js version do you prefer you can use the following steps</p>



<p class="wp-block-paragraph"><strong>Node.js v14.x</strong>:</p>



<pre class="wp-block-preformatted"># Using Ubuntu
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
sudo apt-get install -y nodejs</pre>



<p class="wp-block-paragraph"><strong>Node.js v12.x</strong>:</p>



<pre class="wp-block-preformatted"># Using Ubuntu
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
sudo apt-get install -y nodejs
</pre>



<p class="wp-block-paragraph"><strong>Node.js v10.x</strong>:</p>



<pre class="wp-block-preformatted"># Using Ubuntu
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt-get install -y nodejs
</pre>



<p class="wp-block-paragraph"><strong>Node.js LTS (v12.x)</strong>:</p>



<pre class="wp-block-preformatted"># Using Ubuntu
curl -sL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
sudo apt-get install -y nodejs

# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_lts.x | bash -
apt-get install -y nodejs</pre>



<p class="wp-block-paragraph"><strong>Node.js Current (v14.x)</strong>:</p>



<pre class="wp-block-preformatted"># Using Ubuntu
curl -sL https://deb.nodesource.com/setup_current.x | sudo -E bash -
sudo apt-get install -y nodejs
</pre>



<h3 class="has-vivid-cyan-blue-color has-text-color wp-block-heading">Install NPM</h3>



<p class="wp-block-paragraph">Please run the following command to install NPM:</p>



<pre class="wp-block-preformatted">apt install npm</pre>



<figure class="wp-block-image size-large is-resized"><img loading="lazy" decoding="async" class="wp-image-465" src="https://serverstadium.com/wp-content/uploads/2020/09/image-54.png" alt="" width="750" height="333" srcset="https://serverstadium.com/wp-content/uploads/2020/09/image-54.png 1337w, https://serverstadium.com/wp-content/uploads/2020/09/image-54-300x134.png 300w, https://serverstadium.com/wp-content/uploads/2020/09/image-54-1024x456.png 1024w, https://serverstadium.com/wp-content/uploads/2020/09/image-54-768x342.png 768w" sizes="(max-width: 750px) 100vw, 750px" /></figure>



<p class="wp-block-paragraph">Many packages and libs will be required to be installed, and you can type &#8220;y&#8221; to continue the NPM installation. By default, from upstream, it will install NPM 3.5.2 version.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="291" height="48" class="wp-image-468" src="https://serverstadium.com/wp-content/uploads/2020/09/image-55.png" alt="" /></figure>



<h3 class="has-vivid-cyan-blue-color has-text-color wp-block-heading">Create Demo and Test Script</h3>



<p class="wp-block-paragraph">After installing Node.js and NPM, we test whether it was installed properly. We can create a test file and append the following simple test script:</p>



<pre class="wp-block-preformatted">var http = require('http');
http.createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n'); }).listen(3000, "0.0.0.0"); console.log('Server running at http://your_ip_address:3000/');</pre>



<p class="wp-block-paragraph">Please pay attention to the following syntax; please change with your Public IP that&#8217;s accessible from public and browser:</p>



<pre id="block-12dbe157-9132-40c8-9f90-9287c866f26f" class="wp-block-preformatted">http://your_ip_address:3000/</pre>



<p class="wp-block-paragraph">Please run the script that was just created by using the following command:</p>



<pre class="wp-block-preformatted">node server.js</pre>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="365" height="58" class="wp-image-472" src="https://serverstadium.com/wp-content/uploads/2020/09/image-56.png" alt="" srcset="https://serverstadium.com/wp-content/uploads/2020/09/image-56.png 365w, https://serverstadium.com/wp-content/uploads/2020/09/image-56-300x48.png 300w" sizes="(max-width: 365px) 100vw, 365px" /></figure>



<p class="wp-block-paragraph">Open your browser and copy the following URL, then paste it into your browser. You will see:</p>



<pre id="block-75706f7a-e35f-40b2-9893-1740c81ed0ee" class="wp-block-preformatted">http://your_ip_address:3000/</pre>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="514" height="143" class="wp-image-546" src="https://serverstadium.com/wp-content/uploads/2020/09/image-90.png" alt="" srcset="https://serverstadium.com/wp-content/uploads/2020/09/image-90.png 514w, https://serverstadium.com/wp-content/uploads/2020/09/image-90-300x83.png 300w" sizes="(max-width: 514px) 100vw, 514px" /></figure>



<p class="wp-block-paragraph">If you see the above message. Congratulation!! You have done the setup Node.JS on your Server.</p>
<p>The post <a href="https://serverstadium.com/knowledge-base/install-a-nodejs-and-launch-a-node-app-on-ubuntu-1804/">Install a Node.js and Launch a Node App on Ubuntu 18.04</a> appeared first on <a href="https://serverstadium.com">ServerStadium</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
