<?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>Node.jS Archives - ServerStadium</title>
	<atom:link href="https://serverstadium.com/knowledge-base/tag/node-js/feed/" rel="self" type="application/rss+xml" />
	<link>https://serverstadium.com/knowledge-base/tag/node-js/</link>
	<description>Public Cloud Solution by ServerStadium</description>
	<lastBuildDate>Thu, 19 Sep 2024 21:49:59 +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>Node.jS Archives - ServerStadium</title>
	<link>https://serverstadium.com/knowledge-base/tag/node-js/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Hosting Ghost CMS for High-Performance Blogging Platforms on Server Stadium Instant Dedicated Servers and Cloud VMs</title>
		<link>https://serverstadium.com/knowledge-base/hosting-ghost-cms-for-high-performance-blogging-platforms/</link>
		
		<dc:creator><![CDATA[Brian K]]></dc:creator>
		<pubDate>Thu, 19 Sep 2024 21:49:59 +0000</pubDate>
				<guid isPermaLink="false">https://serverstadium.com/?post_type=epkb_post_type_1&#038;p=12056</guid>

					<description><![CDATA[<p>Introduction In the competitive world of online content, having a high-performance blogging platform is crucial for engaging readers and boosting search engine rankings. Ghost CMS is a powerful, open-source platform designed for professional publishing. This guide will walk you through hosting Ghost CMS for high-performance blogging using Server Stadium&#8217;s robust infrastructure, leveraging our Cloud VMs&#8230;</p>
<p>The post <a href="https://serverstadium.com/knowledge-base/hosting-ghost-cms-for-high-performance-blogging-platforms/">Hosting Ghost CMS for High-Performance Blogging Platforms on Server Stadium Instant Dedicated Servers and Cloud VMs</a> appeared first on <a href="https://serverstadium.com">ServerStadium</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h3>Introduction</h3>
<p>In the competitive world of online content, having a high-performance blogging platform is crucial for engaging readers and boosting search engine rankings. <strong>Ghost CMS</strong> is a powerful, open-source platform designed for professional publishing. This guide will walk you through hosting Ghost CMS for high-performance blogging using <strong>Server Stadium&#8217;s</strong> robust infrastructure, leveraging our <a href="https://serverstadium.com/pricing/" target="_new" rel="noopener">Cloud VMs</a> and <a href="https://serverstadium.com/dedicated-server/" target="_new" rel="noopener">Instant Dedicated Servers</a> to deliver fast, reliable, and scalable blogging platforms.</p>
<h3>Why Choose Ghost CMS?</h3>
<p>Ghost CMS is a modern publishing platform built on Node.js, offering:</p>
<ul>
<li><strong>Performance</strong>: Optimized for speed, ensuring quick load times.</li>
<li><strong>SEO-Friendly</strong>: Built-in SEO features to improve search engine rankings.</li>
<li><strong>Customization</strong>: Extensive theming options and integrations.</li>
<li><strong>Simplicity</strong>: User-friendly interface for content creators.</li>
</ul>
<h3>Prerequisites</h3>
<ul>
<li>Access to Server Stadium <a href="https://serverstadium.com/pricing/" target="_new" rel="noopener">Cloud VMs</a> or <a href="https://serverstadium.com/dedicated-server/" target="_new" rel="noopener">Instant Dedicated Servers</a>. If you don&#8217;t have an account, <a href="https://cp.serverstadium.com/regist-user" target="_new" rel="noopener">sign up here</a>.</li>
<li>A domain name pointed to your server&#8217;s IP address.</li>
<li>Servers running Ubuntu 20.04 LTS or later.</li>
<li>Root or sudo access to the server.</li>
<li>Basic knowledge of command-line operations.</li>
</ul>
<h3>Step 1: Provision Your Server Infrastructure</h3>
<ol>
<li><strong>Choose Your Server Type</strong>:
<ul>
<li><strong>Cloud VMs</strong>: Ideal for small to medium blogs with moderate traffic.</li>
<li><strong>Instant Dedicated Servers</strong>: Best for high-traffic blogs requiring maximum performance. Instantly deploy your server without waiting times.</li>
</ul>
</li>
<li><strong>Select Server Specifications</strong>:
<ul>
<li><strong>CPU</strong>: Multi-core processors for handling multiple requests.</li>
<li><strong>Memory</strong>: At least 4GB RAM is recommended for Ghost CMS.</li>
<li><strong>Storage</strong>: SSD or NVMe drives for faster data access.</li>
<li><strong>Network</strong>: High bandwidth and low latency connections.</li>
</ul>
</li>
</ol>
<h3>Step 2: Update Your Server</h3>
<p>Keep your server up-to-date with the latest security patches.</p>
<div class="shortcode-code">
<p> sudo apt update sudo apt upgrade -y </p></div>
<h3>Step 3: Install Node.js and npm</h3>
<p>Ghost CMS requires Node.js version 20.x.</p>
<h4>1. Install Node.js</h4>
<div class="shortcode-code">
<p> curl -sL https://deb.nodesource.com/setup_20.x | sudo -E bash &#8211; sudo apt install -y nodejs </p></div>
<p>Verify the installation:</p>
<div class="shortcode-code">
<p> node -v npm -v </p></div>
<h3>Step 4: Install MySQL</h3>
<p>Ghost CMS uses MySQL as its database.</p>
<div class="shortcode-code">
<p> sudo apt install mysql-server -y </p></div>
<p>Secure the MySQL installation:</p>
<div class="shortcode-code">
<p> sudo mysql_secure_installation </p></div>
<p>Follow the prompts to set the root password and secure your database.</p>
<h3>Step 5: Create a MySQL Database and User for Ghost</h3>
<p>Log in to MySQL:</p>
<div class="shortcode-code">
<p> sudo mysql -u root -p </p></div>
<p>Inside the MySQL shell, run:</p>
<div class="shortcode-code">
<p> CREATE DATABASE ghost_db; CREATE USER &#039;ghost_user&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;your_strong_password&#039;; GRANT ALL PRIVILEGES ON ghost_db.* TO &#039;ghost_user&#039;@&#039;localhost&#039;; FLUSH PRIVILEGES; EXIT; </p></div>
<h3>Step 6: Install Nginx</h3>
<p>Nginx will serve as a reverse proxy for Ghost.</p>
<div class="shortcode-code">
<p> sudo apt install nginx -y </p></div>
<h3>Step 7: Install Ghost-CLI</h3>
<p>Ghost-CLI is a command-line tool that installs and manages Ghost.</p>
<div class="shortcode-code">
<p> sudo npm install -g ghost-cli@latest </p></div>
<h3>Step 8: Set Up Your Ghost Directory</h3>
<p>Create a directory for your Ghost installation and set the appropriate permissions.</p>
<div class="shortcode-code">
<p> sudo mkdir -p /var/www/ghost sudo chown $USER:$USER /var/www/ghost sudo chmod 775 /var/www/ghost cd /var/www/ghost </p></div>
<h3>Step 9: Install Ghost CMS</h3>
<p>Run the Ghost installation command.</p>
<div class="shortcode-code">
<p> ghost install </p></div>
<p>During the installation, you&#8217;ll be prompted for configuration options:</p>
<ul>
<li><strong>Blog URL</strong>: Enter your domain name (e.g., <code>https://yourdomain.com</code>).</li>
<li><strong>MySQL configuration</strong>: Use the database name, user, and password you set earlier.</li>
<li><strong>Set up Nginx</strong>: Yes.</li>
<li><strong>Set up SSL</strong>: Yes (recommended to use Let&#8217;s Encrypt).</li>
<li><strong>Set up systemd</strong>: Yes.</li>
<li><strong>Start Ghost</strong>: Yes.</li>
</ul>
<h3>Step 10: Adjust Firewall Settings</h3>
<p>Allow Nginx Full profile through the firewall.</p>
<div class="shortcode-code">
<p> sudo ufw allow &#039;Nginx Full&#039; sudo ufw enable </p></div>
<h3>Step 11: Access Your Ghost Blog</h3>
<p>Open your web browser and navigate to your domain to see your new Ghost blog.</p>
<p>To access the admin interface, go to:</p>
<div class="shortcode-code">
<p> https://yourdomain.com/ghost/ </p></div>
<h3>Benefits of Using Server Stadium for Hosting Ghost CMS</h3>
<ul>
<li><strong>High-Performance Hardware</strong>: Latest CPUs and fast NVMe storage for quick content delivery.</li>
<li><strong>Scalability</strong>: Easily scale resources as your blog grows.</li>
<li><strong>Instant Deployment</strong>: Get your dedicated servers up and running instantly.</li>
<li><strong>Global Network</strong>: Low-latency connections for faster page loads.</li>
<li><strong>24/7 Support</strong>: Expert assistance whenever you need it.</li>
</ul>
<h3>Optimizing Ghost CMS for High Performance</h3>
<h4>1. Enable Caching</h4>
<p>Use Nginx caching to improve load times.</p>
<h4>2. Use a Content Delivery Network (CDN)</h4>
<p>Integrate a CDN to serve static assets faster.</p>
<h4>3. Optimize Images</h4>
<p>Use image optimization tools or services to reduce image sizes without compromising quality.</p>
<h4>4. Regular Updates</h4>
<p>Keep Ghost CMS and all packages up-to-date for security and performance enhancements.</p>
<h3>Why Choose Ghost CMS for Blogging?</h3>
<ul>
<li><strong>SEO-Friendly</strong>: Built-in SEO tools help improve your search engine rankings.</li>
<li><strong>Responsive Design</strong>: Themes are mobile-friendly, enhancing user experience.</li>
<li><strong>Content Focused</strong>: Minimalistic design keeps the focus on your content.</li>
<li><strong>Community Support</strong>: Active community and extensive documentation.</li>
</ul>
<h3>Conclusion</h3>
<p>Hosting Ghost CMS on Server Stadium&#8217;s Instant Dedicated Servers or Cloud VMs provides a high-performance platform for your blogging needs. With our robust infrastructure and Ghost&#8217;s powerful features, you can efficiently deliver engaging content to your audience.</p>
<p><strong>Ready to launch your high-performance blog?</strong> Explore our <a href="https://serverstadium.com/pricing/" target="_new" rel="noopener">Cloud VM pricing</a> or <a href="https://serverstadium.com/dedicated-server/" target="_new" rel="noopener">Instant Dedicated Server options</a></p>
<p>The post <a href="https://serverstadium.com/knowledge-base/hosting-ghost-cms-for-high-performance-blogging-platforms/">Hosting Ghost CMS for High-Performance Blogging Platforms on Server Stadium Instant Dedicated Servers and Cloud VMs</a> appeared first on <a href="https://serverstadium.com">ServerStadium</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Setting Up Wiki.js on ServerStadium</title>
		<link>https://serverstadium.com/knowledge-base/setting-up-wiki-js-on-serverstadium/</link>
		
		<dc:creator><![CDATA[Brian K]]></dc:creator>
		<pubDate>Thu, 04 Jan 2024 06:00:47 +0000</pubDate>
				<guid isPermaLink="false">https://serverstadium.com/?post_type=epkb_post_type_1&#038;p=11828</guid>

					<description><![CDATA[<p>Introduction Wiki.js offers a sleek, user-friendly interface for creating and managing wikis and documentation. By setting up Wiki.js on ServerStadium&#8217;s infrastructure (VM Pricing, Dedicated Servers), you gain a powerful tool for collaborative content creation, whether for internal documentation, project wikis, or knowledge bases. Setting Up Wiki.js on ServerStadium Prerequisites A ServerStadium VM or dedicated server&#8230;</p>
<p>The post <a href="https://serverstadium.com/knowledge-base/setting-up-wiki-js-on-serverstadium/">Setting Up Wiki.js on ServerStadium</a> appeared first on <a href="https://serverstadium.com">ServerStadium</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h2>Introduction</h2>
<p>Wiki.js offers a sleek, user-friendly interface for creating and managing wikis and documentation. By setting up Wiki.js on ServerStadium&#8217;s infrastructure (<a href="https://serverstadium.com/pricing/" target="_new" rel="noopener">VM Pricing</a>, <a href="https://serverstadium.com/dedicated-server/" target="_new" rel="noopener">Dedicated Servers</a>), you gain a powerful tool for collaborative content creation, whether for internal documentation, project wikis, or knowledge bases.</p>
<h2>Setting Up Wiki.js on ServerStadium</h2>
<h3>Prerequisites</h3>
<ul>
<li>A ServerStadium VM or dedicated server (<a href="https://serverstadium.com/pricing/" target="_new" rel="noopener">VM Pricing</a>, <a href="https://serverstadium.com/dedicated-server/" target="_new" rel="noopener">Dedicated Servers</a>).</li>
<li>Basic knowledge of Node.js and MongoDB, as Wiki.js is built on these technologies.</li>
</ul>
<h3>Step 1: Select and Prepare Your ServerStadium Server</h3>
<ol>
<li><strong>Choose a Server</strong>: Pick a ServerStadium server based on your expected traffic and data storage needs.</li>
<li><strong>Server Setup</strong>:
<div class="shortcode-code">
<p> sudo apt update<br />
sudo apt upgrade </p></div></li>
</ol>
<h3>Step 2: Install Node.js and MongoDB</h3>
<p>Wiki.js requires Node.js for its server-side logic and MongoDB as its database:</p>
<ol>
<li><strong>Install Node.js</strong>:
<div class="shortcode-code">
<p> curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash &#8211;<br />
sudo apt-get install -y nodejs </p></div></li>
<li><strong>Install MongoDB</strong>:
<div class="shortcode-code">
<p> sudo apt install -y mongodb </p></div>
<p>Start and enable MongoDB:</p>
<div class="shortcode-code">
<p> sudo systemctl start mongodb<br />
sudo systemctl enable mongodb </p></div></li>
</ol>
<h3>Step 3: Install and Configure Wiki.js</h3>
<ol>
<li><strong>Download Wiki.js</strong>:
<p>Visit the <a href="https://js.wiki/get-started" target="_new" rel="noopener">Wiki.js download page</a> to get the latest release. Use wget to download it directly to your server.</p>
<div class="shortcode-code">
<p> wget https://github.com/Requarks/wiki/releases/download/2.5.170/wiki-js.tar.gz<br />
mkdir wiki<br />
tar xzf wiki-js.tar.gz -C ./wiki </p></div></li>
<li><strong>Configure Wiki.js</strong>:
<p>Navigate to the Wiki.js directory and run the configuration wizard:</p>
<div class="shortcode-code">
<p> cd wiki<br />
node wiki configure </p></div>
<p>Follow the prompts to configure Wiki.js, including setting up the database and the initial admin account.</li>
</ol>
<h3>Step 4: Run Wiki.js</h3>
<ol>
<li><strong>Start Wiki.js</strong>:
<div class="shortcode-code">
<p> node server </p></div>
<p>This command starts Wiki.js on the default port (3000).</li>
</ol>
<h3>Step 5: Accessing Wiki.js</h3>
<ol>
<li><strong>Access Wiki.js</strong>:
<p>Navigate to <code>http://your_server_ip:3000</code> in your web browser to access your Wiki.js instance.</li>
<li><strong>Complete Setup</strong>:
<p>Finalize the setup through the web interface and start creating content.</li>
</ol>
<h3>Conclusion</h3>
<p>Your Wiki.js instance is now operational on ServerStadium, providing a modern platform for your documentation and wiki needs. For additional support, visit 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/setting-up-wiki-js-on-serverstadium/">Setting Up Wiki.js on ServerStadium</a> appeared first on <a href="https://serverstadium.com">ServerStadium</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Setting Up a Node.js Application Using Docker and Nginx on ServerStadium</title>
		<link>https://serverstadium.com/knowledge-base/setting-up-a-node-js-application-using-docker-and-nginx-on-serverstadium/</link>
		
		<dc:creator><![CDATA[Brian K]]></dc:creator>
		<pubDate>Thu, 04 Jan 2024 02:28:28 +0000</pubDate>
				<guid isPermaLink="false">https://serverstadium.com/?post_type=epkb_post_type_1&#038;p=11762</guid>

					<description><![CDATA[<p>This tutorial guides you through creating a secure and scalable environment for a Node.js application using Docker and Nginx on ServerStadium&#8217;s infrastructure. Prerequisites A ServerStadium VM or dedicated server. Review the options at ServerStadium VM Pricing and Dedicated Servers. Basic knowledge of Docker, Nginx, and Node.js. Step 1: Prepare Your ServerStadium Environment Select and Set&#8230;</p>
<p>The post <a href="https://serverstadium.com/knowledge-base/setting-up-a-node-js-application-using-docker-and-nginx-on-serverstadium/">Setting Up a Node.js Application Using Docker and Nginx on ServerStadium</a> appeared first on <a href="https://serverstadium.com">ServerStadium</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>This tutorial guides you through creating a secure and scalable environment for a Node.js application using Docker and Nginx on ServerStadium&#8217;s infrastructure.</p>
<h3>Prerequisites</h3>
<ul>
<li>A ServerStadium VM or dedicated server. Review the options at <a href="https://serverstadium.com/pricing/" target="_new" rel="noopener">ServerStadium VM Pricing</a> and <a href="https://serverstadium.com/dedicated-server/" target="_new" rel="noopener">Dedicated Servers</a>.</li>
<li>Basic knowledge of Docker, Nginx, and Node.js.</li>
</ul>
<h3>Step 1: Prepare Your ServerStadium Environment</h3>
<ol>
<li><strong>Select and Set Up Your Server</strong>: Choose a VM or dedicated server from ServerStadium. A medium-sized VM should suffice for most Node.js applications.</li>
<li><strong>Server Setup</strong>: Access your server via SSH. Update the system:<br />
<div class="shortcode-code">
<p>sudo apt update<br />
sudo apt upgrade</p></div></li>
</ol>
<h3>Step 2: Install Docker</h3>
<ol>
<li><strong>Install Docker</strong>: Install Docker on your ServerStadium environment:<br />
<div class="shortcode-code">
<p>sudo apt install docker.io</p></div></li>
<li><strong>Start and Enable Docker</strong>:<br />
<div class="shortcode-code">
<p>sudo systemctl start docker<br />
sudo systemctl enable docker</p></div></li>
<li><strong>Verify Installation</strong>:<br />
<div class="shortcode-code">
<p>docker &#8211;version</p></div></li>
</ol>
<h3>Step 3: Create Your Node.js Application</h3>
<ol>
<li><strong>Application Setup</strong>: On your local machine, create a basic Node.js application. For example, an Express.js application.</li>
<li><strong>Dockerize the Application</strong>: Create a <code>Dockerfile</code> in your application directory:
<div class="shortcode-code">
<p>FROM node:14</p>
<p>WORKDIR /usr/src/app</p>
<p>COPY package*.json ./</p>
<p>RUN npm install</p>
<p>COPY . .</p>
<p>EXPOSE 8080</p>
<p>CMD &#091; &quot;node&quot;, &quot;app.js&quot; &#093;</p>
<p></p></div></li>
<li><strong>Build Your Docker Image</strong>:<br />
<div class="shortcode-code">
<p>docker build -t mynodeapp .</p></div></li>
<li><strong>Run the Docker Container</strong>:<br />
<div class="shortcode-code">
<p>docker run -d -p 8080:8080 mynodeapp</p></div></li>
</ol>
<h3>Step 4: Install and Configure Nginx as a Reverse Proxy</h3>
<ol>
<li><strong>Install Nginx</strong>:<br />
<div class="shortcode-code">
<p>sudo apt install nginx</p></div></li>
<li><strong>Configure Nginx</strong>:
<p>Create a new site configuration file:<br />
<div class="shortcode-code">
<p>sudo nano /etc/nginx/sites-available/mynodeapp</p></div><br />
Add the following configuration:</p>
<div class="shortcode-code">
<p>server {<br />
listen 80;</p>
<p>server_name your_domain.com;</p>
<p>location / {<br />
proxy_pass http://localhost:8080;<br />
proxy_http_version 1.1;<br />
proxy_set_header Upgrade $http_upgrade;<br />
proxy_set_header Connection &#039;upgrade&#039;;<br />
proxy_set_header Host $host;<br />
proxy_cache_bypass $http_upgrade;<br />
}<br />
}</p>
<p></p></div><br />
Enable the new site:<br />
<div class="shortcode-code">
<p>sudo ln -s /etc/nginx/sites-available/mynodeapp /etc/nginx/sites-enabled/<br />
sudo nginx -t<br />
sudo systemctl restart nginx</p></div></li>
<li><strong>Firewall Configuration</strong>: If you have a firewall enabled, allow Nginx traffic:<br />
<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></li>
</ol>
<h3>Step 5: Deploy Your Application</h3>
<ol>
<li><strong>Transfer Your Docker Image</strong>: Use <code>docker save</code> and <code>docker load</code> or a Docker registry to transfer your Docker image to your ServerStadium server.</li>
<li><strong>Run Your Docker Container</strong>: On the server, run your Docker container as before.</li>
</ol>
<h3>Step 6: Secure Your Application</h3>
<ol>
<li><strong>SSL Certificate</strong>: Obtain an SSL certificate for your domain (you can use Let&#8217;s Encrypt for a free certificate) and configure Nginx to use it.</li>
<li><strong>Environment Variables</strong>: Use environment variables for sensitive information like database passwords.</li>
</ol>
<h3>Conclusion</h3>
<p>You now have a scalable and secure Node.js application running in a Docker container, with Nginx as a reverse proxy on a ServerStadium server. This setup ensures efficient load handling and enhanced security for your application.</p>
<p>For additional assistance, visit 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/setting-up-a-node-js-application-using-docker-and-nginx-on-serverstadium/">Setting Up a Node.js Application Using Docker and Nginx on ServerStadium</a> appeared first on <a href="https://serverstadium.com">ServerStadium</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<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>Setting Up a Node.js Application on ServerStadium&#8217;s Cloud Instances</title>
		<link>https://serverstadium.com/knowledge-base/setting-up-a-node-js-application-on-serverstadiums-cloud-instances/</link>
		
		<dc:creator><![CDATA[Brian K]]></dc:creator>
		<pubDate>Fri, 26 May 2023 02:42:15 +0000</pubDate>
				<guid isPermaLink="false">https://serverstadium.com/?post_type=epkb_post_type_1&#038;p=11665</guid>

					<description><![CDATA[<p>Node.js is an open-source, back-end JavaScript runtime environment that runs on the V8 engine and executes JavaScript code outside a web browser. This tutorial will guide you on how to set up a Node.js application on your ServerStadium cloud instance. For additional tutorials and guides, check out our Knowledge Base. Step 1: Register Your Account&#8230;</p>
<p>The post <a href="https://serverstadium.com/knowledge-base/setting-up-a-node-js-application-on-serverstadiums-cloud-instances/">Setting Up a Node.js Application on ServerStadium&#8217;s Cloud Instances</a> appeared first on <a href="https://serverstadium.com">ServerStadium</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Node.js is an open-source, back-end JavaScript runtime environment that runs on the V8 engine and executes JavaScript code outside a web browser. This tutorial will guide you on how to set up a Node.js application on your ServerStadium cloud instance.</p>
<p>For additional tutorials and guides, check out our <a href="https://serverstadium.com/knowledge-base/" target="_new" rel="noopener">Knowledge Base</a>.</p>
<h2>Step 1: Register Your Account</h2>
<p>If you haven&#8217;t already, you&#8217;ll need to create an account on our <a href="https://cp.serverstadium.com/regist-user" target="_new" rel="noopener">Registration Page</a>. Once you&#8217;re registered, you&#8217;ll gain access to your personal <a href="https://cp.serverstadium.com/" target="_new" rel="noopener">Cloud Dashboard</a>.</p>
<h2>Step 2: Add Your Cloud Instance</h2>
<p>From your <a href="https://cp.serverstadium.com/" target="_new" rel="noopener">Cloud Dashboard</a>, click on the &#8216;Add VM&#8217; button. Here, you can choose a cloud instance that fits your needs and budget. For more information about our instance options, visit our <a href="https://serverstadium.com/pricing/" target="_new" rel="noopener">Pricing Page</a>.</p>
<h2>Step 3: Install Node.js</h2>
<p>With your cloud instance ready, connect to it via SSH and install Node.js with 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<br />
</code></div>
<div class="p-4 overflow-y-auto"><code class="!whitespace-pre hljs language-bash">sudo apt install nodejs<br />
</code></div>
<div class="p-4 overflow-y-auto"><code class="!whitespace-pre hljs language-bash">sudo apt install npm</code></div>
<div>To verify that Node.js is installed correctly, you can check its version by typing <code>nodejs --version</code>.</div>
<div>
<h2>Step 4: Create Your Node.js Application</h2>
<p>Now, you can create your Node.js application. We&#8217;ll create a simple &#8220;Hello World&#8221; application in this guide. First, create a new directory for your application and navigate into it:</p>
<div class="bg-black rounded-md mb-4">
<div class="flex items-center relative text-gray-200 bg-gray-800 px-4 py-2 text-xs font-sans justify-between rounded-t-md"></div>
<div class="p-4 overflow-y-auto"><code class="!whitespace-pre hljs language-bash"><span class="hljs-built_in">mkdir</span> myapp<br />
<span class="hljs-built_in">cd</span> myapp<br />
</code></div>
</div>
<p>Next, create a new file named <code>app.js</code>:</p>
<div class="bg-black rounded-md mb-4">
<div class="p-4 overflow-y-auto"><code class="!whitespace-pre hljs language-bash">nano app.js<br />
</code></div>
</div>
<p>In <code>app.js</code>, add the following code:</p>
<pre>const http = require('http');

const hostname = '127.0.0.1';
const port = 3000;

const server = http.createServer((req, res) =&gt; {
 res.statusCode = 200;
 res.setHeader('Content-Type', 'text/plain');
 res.end('Hello World\n');
});

server.listen(port, hostname, () =&gt; {
  console.log(`Server running at http://${hostname}:${port}/`);
});
</pre>
<p>Save and close the file.</p>
<h2>Step 5: Run Your Node.js Application</h2>
<p>You can now run your application with the following command:</p>
<div class="bg-black rounded-md mb-4">
<div class="p-4 overflow-y-auto"><code class="!whitespace-pre hljs language-bash">nodejs app.js<br />
</code></div>
</div>
<p>You should see the message &#8220;Server running at <a href="http://127.0.0.1:3000/" target="_new" rel="noopener">http://127.0.0.1:3000/</a>&#8221; in your terminal.</p>
<h2>Conclusion</h2>
<p>Congratulations, you&#8217;ve just set up a Node.js application on your ServerStadium cloud instance! You&#8217;re ready to start building your own Node.js applications on the cloud.</p>
<p>Visit our <a href="https://serverstadium.com/knowledge-base/" target="_new" rel="noopener">Knowledge Base</a> for more tutorials and guides.</p>
</div>
</div>
<p>The post <a href="https://serverstadium.com/knowledge-base/setting-up-a-node-js-application-on-serverstadiums-cloud-instances/">Setting Up a Node.js Application on ServerStadium&#8217;s Cloud Instances</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 fetchpriority="high" 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 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 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>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>
