<?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>Ubuntu Archives - ServerStadium</title>
	<atom:link href="https://serverstadium.com/knowledge-base/tag/ubuntu/feed/" rel="self" type="application/rss+xml" />
	<link>https://serverstadium.com/knowledge-base/tag/ubuntu/</link>
	<description>Public Cloud Solution by ServerStadium</description>
	<lastBuildDate>Tue, 12 Aug 2025 18:16:12 +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>Ubuntu Archives - ServerStadium</title>
	<link>https://serverstadium.com/knowledge-base/tag/ubuntu/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Easy Duplicati Backups on Ubuntu for Dedicated Servers</title>
		<link>https://serverstadium.com/knowledge-base/easy-duplicati-backups-on-ubuntu-for-dedicated-servers/</link>
		
		<dc:creator><![CDATA[Brian K]]></dc:creator>
		<pubDate>Tue, 12 Aug 2025 18:16:06 +0000</pubDate>
				<guid isPermaLink="false">https://serverstadium.com/?post_type=epkb_post_type_1&#038;p=12197</guid>

					<description><![CDATA[<p>Introduction This beginner-friendly guide walks you through installing Duplicati (open-source backup with a simple web UI) on Ubuntu 24.04 running on a ServerStadium dedicated server. You’ll set a secure admin password, reach the web UI from your network, schedule encrypted backups, and send email reports. If you don’t have a server yet, spin up an&#8230;</p>
<p>The post <a href="https://serverstadium.com/knowledge-base/easy-duplicati-backups-on-ubuntu-for-dedicated-servers/">Easy Duplicati Backups on Ubuntu for Dedicated Servers</a> appeared first on <a href="https://serverstadium.com">ServerStadium</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">Introduction</h2>



<p class="wp-block-paragraph">This beginner-friendly guide walks you through installing <strong>Duplicati</strong> (open-source backup with a simple web UI) on Ubuntu 24.04 running on a <a href="https://serverstadium.com/dedicated-server/?utm_source=kb&#038;utm_medium=article&#038;utm_campaign=dedicated_server">ServerStadium dedicated server</a>. You’ll set a secure admin password, reach the web UI from your network, schedule encrypted backups, and send email reports. If you don’t have a server yet, spin up an <a href="https://serverstadium.com/dedicated-server/?utm_source=kb&#038;utm_medium=article&#038;utm_campaign=dedicated_server">instant dedicated server</a> and follow along.</p>



<h2 class="wp-block-heading">Prerequisites</h2>



<ul class="wp-block-list">
  <li>A <a href="https://serverstadium.com/dedicated-server/?utm_source=kb&#038;utm_medium=article&#038;utm_campaign=dedicated_server">ServerStadium dedicated server</a> running Ubuntu 24.04 (or similar).</li>
  <li>SSH access with <code>sudo</code> privileges.</li>
  <li>A workstation on the same network (or VPN) to access the web UI.</li>
</ul>



<h2 class="wp-block-heading">Step 1 — Update and Basics</h2>



<p class="wp-block-paragraph">Update packages and install a few helpers.</p>


<pre><code>sudo apt-get update && sudo apt-get upgrade -y
sudo apt-get install -y curl gnupg ufw</code></pre>


<h2 class="wp-block-heading">Step 2 — Install Duplicati (.deb package)</h2>



<p class="wp-block-paragraph">Download a current stable Debian/Ubuntu package and install it (example below). Adjust the version if a newer stable build is available.</p>


<pre><code>cd /tmp
wget https://updates.duplicati.com/stable/duplicati-2.1.0.5_stable_2025-03-04-linux-x64-gui.deb
sudo apt-get install -y ./duplicati-2.1.0.5_stable_2025-03-04-linux-x64-gui.deb

sudo systemctl enable duplicati
sudo systemctl start duplicati
sudo systemctl status duplicati --no-pager</code></pre>


<p class="wp-block-paragraph">By default, Duplicati’s server listens on port <code>8200</code> and only on <code>localhost</code>. We’ll securely expose it next so you can reach it from your LAN.</p>



<h2 class="wp-block-heading">Step 3 — One-Time Secure Setup (password &amp; remote access)</h2>



<p class="wp-block-paragraph">Set an initial web password and temporarily allow access from your network so you can finish setup in the browser:</p>


<pre><code># Stop the service
sudo systemctl stop duplicati

# Start Duplicati manually one time with a strong password and LAN access
# Replace YOUR_STRONG_PASSWORD and YOUR_SERVER_IP
nohup /usr/bin/duplicati-server \
  --webservice-password=YOUR_STRONG_PASSWORD \
  --webservice-interface=any \
  --webservice-port=8200 \
  --server-datafolder=/var/lib/duplicati \
  >/var/log/duplicati-initial.log 2>&1 &

# From your workstation, browse to:
#   http://YOUR_SERVER_IP:8200
# Sign in with the password above, open Settings, enable remote access if prompted, and Save.

# Then return to the server and switch back to the service:
sudo pkill -f duplicati-server
sudo systemctl start duplicati
sudo systemctl status duplicati --no-pager</code></pre>


<h2 class="wp-block-heading">Step 4 — Lock Down the Port (UFW)</h2>



<p class="wp-block-paragraph">Allow only your admin IP (replace <code>198.51.100.10</code>) to reach the Duplicati UI on port 8200.</p>


<pre><code>sudo ufw allow from 198.51.100.10 to any port 8200 proto tcp
sudo ufw enable
sudo ufw status</code></pre>


<p class="wp-block-paragraph">For public exposure, consider placing Duplicati behind a reverse proxy with HTTPS. For most beginners, restricting to an admin IP is simplest and safest.</p>



<h2 class="wp-block-heading">Step 5 — First Backup (Web UI)</h2>



<ul class="wp-block-list">
  <li>In the Duplicati UI → <strong>Add backup</strong>.</li>
  <li>Choose <strong>Configure a new backup</strong>, set a <strong>Backup name</strong> and <strong>Passphrase</strong> (AES-256 encryption).</li>
  <li><strong>Destination</strong>: pick storage you control (local folder, SFTP, WebDAV, or any S3-compatible service you use).</li>
  <li><strong>Source data</strong>: select folders to protect (e.g., <code>/etc</code>, <code>/var/www</code>, <code>/home</code>).</li>
  <li><strong>Schedule</strong>: daily or hourly, with a practical retention (e.g., “smart” or 30–60 days).</li>
  <li><strong>Save</strong> and run your first backup.</li>
</ul>



<h2 class="wp-block-heading">Optional — Email Reports (Postfix + mailutils)</h2>



<p class="wp-block-paragraph">Install basic mail tools and, if needed, configure an SMTP relay. Then enable reports under <strong>Settings → Send reports</strong> in Duplicati.</p>


<pre><code>sudo apt-get install -y postfix mailutils
# During Postfix setup, choose "Internet Site" and set the server's hostname.
# If using an SMTP relay, edit /etc/postfix/main.cf accordingly, then reload:
sudo systemctl reload postfix</code></pre>


<h2 class="wp-block-heading">Troubleshooting</h2>



<ul class="wp-block-list">
  <li><strong>UI won’t open:</strong> Confirm Duplicati is listening on 8200 and the firewall rule is correct:
    <br><code>sudo systemctl status duplicati</code>
    <br><code>ss -ltnp | grep 8200</code>
  </li>
  <li><strong>Can’t reach from LAN:</strong> Make sure you launched once with <code>--webservice-interface=any</code> and saved remote access in Settings. Then:
    <br><code>sudo systemctl restart duplicati</code>
  </li>
  <li><strong>Forgot the password:</strong> Stop the service, start once with an empty password to clear it, set a new one in Settings, then return to the service:
    <br><code>sudo systemctl stop duplicati</code>
    <br><code>/usr/bin/duplicati-server --webservice-password=</code>
    <br><code>sudo pkill -f duplicati-server && sudo systemctl start duplicati</code>
  </li>
</ul>



<h2 class="wp-block-heading">Why Host Duplicati on ServerStadium?</h2>



<ul class="wp-block-list">
  <li><strong>Instant dedicated servers</strong> with predictable CPU, RAM, and disk for consistent backup windows.</li>
  <li><strong>Scalable storage</strong> options and private networking for secure replication between nodes.</li>
  <li>Easy to grow from one backup host to a fleet. Get started here: <a href="https://serverstadium.com/dedicated-server/?utm_source=kb&#038;utm_medium=article&#038;utm_campaign=dedicated_server">ServerStadium Dedicated Servers</a>.</li>
</ul>



<h2 class="wp-block-heading">Conclusion</h2>



<p class="wp-block-paragraph">With Duplicati running on your ServerStadium dedicated server, you’ve got encrypted, scheduled backups managed from a clean web UI. Add more destinations, tune retention, and enable email reports for peace of mind. For more help or information about ServerStadium services, visit our <a href="https://serverstadium.com/knowledge-base/?utm_source=kb&#038;utm_medium=article&#038;utm_campaign=dedicated_server">knowledge base</a> or the <a href="https://serverstadium.com/?utm_source=kb&#038;utm_medium=article&#038;utm_campaign=dedicated_server">ServerStadium website</a>.</p>

<p>The post <a href="https://serverstadium.com/knowledge-base/easy-duplicati-backups-on-ubuntu-for-dedicated-servers/">Easy Duplicati Backups on Ubuntu for Dedicated Servers</a> appeared first on <a href="https://serverstadium.com">ServerStadium</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>File Sharing Made Simple: Setting Up Samba on Ubuntu with ServerStadium</title>
		<link>https://serverstadium.com/knowledge-base/setting-up-samba-on-ubuntu/</link>
		
		<dc:creator><![CDATA[Brian K]]></dc:creator>
		<pubDate>Mon, 18 Sep 2023 19:52:05 +0000</pubDate>
				<guid isPermaLink="false">https://serverstadium.com/?post_type=epkb_post_type_1&#038;p=11738</guid>

					<description><![CDATA[<p>Sharing files between Linux and Windows systems can be challenging in a multi-platform environment. Samba, a file-sharing utility for Ubuntu, bridges this gap. With ServerStadium&#8217;s reliable infrastructure, setting up Samba becomes straightforward, allowing for effortless cross-platform file sharing. Why Samba? Samba facilitates file sharing between Linux and Windows and acts as a domain controller, offering&#8230;</p>
<p>The post <a href="https://serverstadium.com/knowledge-base/setting-up-samba-on-ubuntu/">File Sharing Made Simple: Setting Up Samba on Ubuntu with ServerStadium</a> appeared first on <a href="https://serverstadium.com">ServerStadium</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Sharing files between Linux and Windows systems can be challenging in a multi-platform environment. Samba, a file-sharing utility for Ubuntu, bridges this gap. With ServerStadium&#8217;s reliable infrastructure, setting up Samba becomes straightforward, allowing for effortless cross-platform file sharing.</p>
<p><strong>Why Samba?</strong> Samba facilitates file sharing between Linux and Windows and acts as a domain controller, offering services like authentication and name resolution. It&#8217;s an essential tool for businesses aiming for seamless operations in mixed OS environments.</p>
<p><strong>Step-by-Step Guide to Setting Up Samba on Ubuntu at ServerStadium</strong></p>
<ol>
<li><strong>Installation</strong>: Begin by updating your system and installing Samba:
<div class="bg-black rounded-md mb-4">
<div class="p-4 overflow-y-auto"><code class="!whitespace-pre hljs language-sql">sudo apt<span class="hljs-operator">-</span><span class="hljs-keyword">get</span> <span class="hljs-keyword">update</span><br />
sudo apt<span class="hljs-operator">-</span><span class="hljs-keyword">get</span> install samba<br />
</code></div>
</div>
</li>
<li><strong>Configuration</strong>: Backup the original Samba configuration file and then edit the new one:
<div class="bg-black rounded-md mb-4">
<div class="p-4 overflow-y-auto"><code class="!whitespace-pre hljs language-bash">sudo <span class="hljs-built_in">cp</span> /etc/samba/smb.conf /etc/samba/smb.conf.backup<br />
sudo nano /etc/samba/smb.conf<br />
</code></div>
</div>
<p>Add your desired configurations, specifying directories to share and permissions.</li>
<li><strong>User Setup</strong>: Samba requires a dedicated user. Create one and set a password:
<div class="bg-black rounded-md mb-4">
<div class="p-4 overflow-y-auto"><code class="!whitespace-pre hljs language-css">sudo smbpasswd -<span class="hljs-selector-tag">a</span> username<br />
</code></div>
</div>
</li>
<li><strong>Access and Permissions</strong>: Ensure the shared directories have the correct permissions. Adjust as needed using <code>chmod</code> and <code>chown</code>.</li>
<li><strong>Restart and Test</strong>: Restart the Samba service and test your setup:
<div class="bg-black rounded-md mb-4">
<div class="p-4 overflow-y-auto"><code class="!whitespace-pre hljs">sudo service smbd restart<br />
smbclient -L localhost -U username<br />
</code></div>
</div>
</li>
</ol>
<p><strong>Optimizing Samba on ServerStadium</strong></p>
<ol>
<li><strong>Security</strong>: Regularly update Samba to benefit from security patches. Consider firewall configurations to restrict access.</li>
<li><strong>Monitoring</strong>: Monitor Samba logs for any unusual activity or errors. This aids in proactive troubleshooting.</li>
<li><strong>Integration</strong>: Integrate Samba with other services on your <a href="https://serverstadium.com/all-products/" target="_new" rel="noopener">ServerStadium infrastructure</a>, like backups or cloud storage, for enhanced functionality.</li>
</ol>
<p><strong>Conclusion</strong> Samba on Ubuntu offers a world of cross-platform file-sharing possibilities. Whether you&#8217;re running a small business or a large enterprise, Samba ensures seamless file access across your network. With <a href="https://serverstadium.com/dedicated-server/" target="_new" rel="noopener">ServerStadium&#8217;s dedicated servers</a> and <a href="https://serverstadium.com/pricing/" target="_new" rel="noopener">cloud VM solutions</a>, you&#8217;re equipped with the perfect environment to harness Samba&#8217;s capabilities.</p>
<p>Ready to explore more server solutions? Navigate through <a href="https://serverstadium.com/knowledge-base/" target="_new" rel="noopener">ServerStadium&#8217;s knowledge base</a> for expert articles and guides, or <a href="https://serverstadium.com/contact/" target="_new" rel="noopener">contact our team</a> for tailored solutions.</p>
<p>The post <a href="https://serverstadium.com/knowledge-base/setting-up-samba-on-ubuntu/">File Sharing Made Simple: Setting Up Samba on Ubuntu with ServerStadium</a> appeared first on <a href="https://serverstadium.com">ServerStadium</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Automating Tasks on Ubuntu with Cron Jobs: A Comprehensive Guide with ServerStadium</title>
		<link>https://serverstadium.com/knowledge-base/automating-tasks-with-cron-on-ubuntu/</link>
		
		<dc:creator><![CDATA[Brian K]]></dc:creator>
		<pubDate>Mon, 18 Sep 2023 19:45:50 +0000</pubDate>
				<guid isPermaLink="false">https://serverstadium.com/?post_type=epkb_post_type_1&#038;p=11736</guid>

					<description><![CDATA[<p>In the dynamic world of server management, efficiency is key. One of the most powerful tools at an administrator&#8217;s disposal is the ability to automate tasks. Enter cron jobs, a scheduler for Unix-like operating systems, including Ubuntu. With ServerStadium&#8217;s robust infrastructure, setting up and managing cron jobs becomes a breeze. What are Cron Jobs? Cron&#8230;</p>
<p>The post <a href="https://serverstadium.com/knowledge-base/automating-tasks-with-cron-on-ubuntu/">Automating Tasks on Ubuntu with Cron Jobs: A Comprehensive Guide with ServerStadium</a> appeared first on <a href="https://serverstadium.com">ServerStadium</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>In the dynamic world of server management, efficiency is key. One of the most powerful tools at an administrator&#8217;s disposal is the ability to automate tasks. Enter cron jobs, a scheduler for Unix-like operating systems, including Ubuntu. With ServerStadium&#8217;s robust infrastructure, setting up and managing cron jobs becomes a breeze.</p>
<p><strong>What are Cron Jobs?</strong></p>
<p>Cron jobs are scheduled tasks that run automatically at specified intervals on your server. Whether it&#8217;s daily backups, regular system updates, or any repetitive tasks, cron jobs ensure your server operates smoothly without manual intervention.</p>
<p><strong>Setting Up Cron on Ubuntu with ServerStadium</strong></p>
<ol>
<li><strong>Installation</strong>: Most Ubuntu servers come with cron pre-installed. If not, install it with:
<div class="bg-black rounded-md mb-4">
<div class="p-4 overflow-y-auto"><code class="!whitespace-pre hljs language-sql">sudo apt<span class="hljs-operator">-</span><span class="hljs-keyword">get</span> <span class="hljs-keyword">update</span><br />
sudo apt<span class="hljs-operator">-</span><span class="hljs-keyword">get</span> install cron<br />
</code></div>
</div>
</li>
<li><strong>Configuration</strong>: Access the cron table to set up tasks:
<div class="bg-black rounded-md mb-4">
<div class="p-4 overflow-y-auto"><code class="!whitespace-pre hljs">crontab -e<br />
</code></div>
</div>
<p>This opens the user-specific cron table where you can add tasks.</li>
<li><strong>Scheduling Tasks</strong>: Cron uses a specific format to schedule tasks. For instance, to run a backup script daily at midnight, you&#8217;d add:
<div class="bg-black rounded-md mb-4">
<div class="p-4 overflow-y-auto"><code class="!whitespace-pre hljs language-javascript"><span class="hljs-number">0</span> <span class="hljs-number">0</span> * * * <span class="hljs-regexp">/path/</span>to/backup_script.<span class="hljs-property">sh</span><br />
</code></div>
</div>
<p>Familiarize yourself with the cron time format to schedule tasks as needed.</li>
</ol>
<p><strong>Best Practices for Cron Jobs on ServerStadium</strong></p>
<ol>
<li><strong>Logging</strong>: Ensure your cron jobs log outputs, especially errors. This helps in troubleshooting. For example:
<div class="bg-black rounded-md mb-4">
<div class="p-4 overflow-y-auto"><code class="!whitespace-pre hljs language-javascript"><span class="hljs-number">0</span> <span class="hljs-number">0</span> * * * <span class="hljs-regexp">/path/</span>to/script.<span class="hljs-property">sh</span> &gt;&gt; <span class="hljs-regexp">/path/</span>to/logfile.<span class="hljs-property">log</span> <span class="hljs-number">2</span>&gt;&amp;<span class="hljs-number">1</span><br />
</code></div>
</div>
</li>
<li><strong>Backup</strong>: Before making changes to the crontab, consider backing it up using:
<div class="bg-black rounded-md mb-4">
<div class="p-4 overflow-y-auto"><code class="!whitespace-pre hljs">crontab -l &gt; backup_crontab.txt </code></div>
</div>
</li>
<li><strong>Security</strong>: Ensure scripts called by cron jobs have appropriate permissions and are not accessible by unauthorized users.</li>
</ol>
<p><strong>Conclusion</strong> Cron jobs offer a world of automation possibilities, ensuring your server operations are efficient and timely. With <a href="https://serverstadium.com/dedicated-server/" target="_new" rel="noopener">ServerStadium&#8217;s dedicated servers</a> and <a href="https://serverstadium.com/pricing/" target="_new" rel="noopener">cloud VM solutions</a>, you have the perfect environment to harness the power of cron on Ubuntu.</p>
<p>Looking for more insights and guides on server management? Dive into <a href="https://serverstadium.com/knowledge-base/" target="_new" rel="noopener">ServerStadium&#8217;s knowledge base</a> for expert articles and tips.</p>
<p>The post <a href="https://serverstadium.com/knowledge-base/automating-tasks-with-cron-on-ubuntu/">Automating Tasks on Ubuntu with Cron Jobs: A Comprehensive Guide with ServerStadium</a> appeared first on <a href="https://serverstadium.com">ServerStadium</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Simple monitoring and alerting with Monit on Ubuntu 22.04 LTS</title>
		<link>https://serverstadium.com/knowledge-base/simple-monitoring-and-alerting-with-monit-on-ubuntu-22-04-lts/</link>
		
		<dc:creator><![CDATA[Brian K]]></dc:creator>
		<pubDate>Wed, 12 Oct 2022 05:17:48 +0000</pubDate>
				<guid isPermaLink="false">https://cloudraya.com/knowledge-base/?p=2767</guid>

					<description><![CDATA[<p>TLDR Guide On Ubuntu 22.04: Example config: Mailserver config example using Gmail in /etc/monit/monitrc: Then reload Monit: Introduction Monit is a utility to monitor your services, systems, and processes and can handle alarms. Not only that, monit is available on most official upstream repositories. Its lightweight web user interface allows you to review the monitored&#8230;</p>
<p>The post <a href="https://serverstadium.com/knowledge-base/simple-monitoring-and-alerting-with-monit-on-ubuntu-22-04-lts/">Simple monitoring and alerting with Monit on Ubuntu 22.04 LTS</a> appeared first on <a href="https://serverstadium.com">ServerStadium</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<h2 class="has-vivid-cyan-blue-color has-text-color wp-block-heading">TLDR Guide</h2>



<p class="wp-block-paragraph">On Ubuntu 22.04:</p>



<pre class="wp-block-code has-cyan-bluish-gray-background-color has-background"><code> sudo apt update
 sudo apt install monit -y
 sudo systemctl enable monit --now</code></pre>



<p class="wp-block-paragraph">Example config:</p>



<pre class="wp-block-code has-background" style="background-color: #ffecbf;"><code>check filesystem root with path /dev/sda1
    if space usage &gt; 90% for 5 cycles then alert</code></pre>



<p class="wp-block-paragraph">Mailserver config example using Gmail in <code>/etc/monit/monitrc</code>:</p>



<pre class="wp-block-code has-background" style="background-color: #ffecbf;"><code>set mailserver smtp.gmail.com port 587
    username "your-username" password "12-digit-app-password"
    using tlsv13
    with timeout 30 seconds

set alert your-username+alerting@gmail.com</code></pre>



<p class="wp-block-paragraph">Then reload Monit:</p>



<pre class="wp-block-code has-cyan-bluish-gray-background-color has-background"><code> sudo monit reload</code></pre>



<h2 class="has-vivid-cyan-blue-color has-text-color wp-block-heading">Introduction</h2>



<p class="wp-block-paragraph">Monit is a utility to monitor your services, systems, and processes and can handle alarms. Not only that, monit is available on most official upstream repositories. Its lightweight web user interface allows you to review the monitored components in a simple visual representation.</p>



<p class="wp-block-paragraph">So, in this article, I will show you how to install<strong> Monit</strong>, monitor things, and set the alerting for them as well. This time, I will use a Ubuntu 22.04 VM instance.</p>



<h2 class="has-vivid-cyan-blue-color has-text-color wp-block-heading">Installation Steps</h2>



<p class="wp-block-paragraph"><strong>Step 1.</strong> Do a repository update and install Monit:</p>



<pre class="wp-block-code has-cyan-bluish-gray-background-color has-background"><code>sudo apt update
sudo apt install monit -y</code></pre>



<p class="wp-block-paragraph"><strong>Step 2.</strong> Start monit service and enable it</p>



<pre class="wp-block-code has-cyan-bluish-gray-background-color has-background"><code>sudo systemctl enable monit --now</code></pre>



<p class="wp-block-paragraph"><strong>Step 3.</strong> Open the <code>/etc/monit/monitrc</code> file, then find the following lines and uncomment them to enable the Web UI (specify the SSL cert path if you have one):</p>



<pre class="wp-block-code has-background" style="background-color: #ffecbf;"><code>set httpd port 2812 and
    use address localhost  
    allow localhost        
    allow admin:monit</code></pre>



<p class="wp-block-paragraph"><strong>Step 4</strong>. Reload monit.</p>



<pre class="wp-block-code has-cyan-bluish-gray-background-color has-background"><code>sudo monit reload</code></pre>



<p class="wp-block-paragraph"><strong>Step 5.</strong> Test it by issuing <code>sudo monit status</code>, it should output something like this:</p>


<div class="wp-block-image">
<figure class="aligncenter size-full is-resized"><img fetchpriority="high" decoding="async" class="wp-image-2772" src="https://serverstadium.com/wp-content/uploads/2022/10/image-9.png" alt="" width="949" height="298" srcset="https://serverstadium.com/wp-content/uploads/2022/10/image-9.png 1265w, https://serverstadium.com/wp-content/uploads/2022/10/image-9-300x94.png 300w, https://serverstadium.com/wp-content/uploads/2022/10/image-9-1024x321.png 1024w, https://serverstadium.com/wp-content/uploads/2022/10/image-9-768x241.png 768w" sizes="(max-width: 949px) 100vw, 949px" />
<figcaption>Monit status output</figcaption>
</figure>
</div>


<p class="wp-block-paragraph">You can access the Web UI by tunneling port 2812 to any free local port on your PC/Laptop.</p>


<div class="wp-block-image">
<figure class="aligncenter size-full is-resized"><img decoding="async" class="wp-image-2774" src="https://serverstadium.com/wp-content/uploads/2022/10/image-10.png" alt="" width="977" height="546" srcset="https://serverstadium.com/wp-content/uploads/2022/10/image-10.png 1302w, https://serverstadium.com/wp-content/uploads/2022/10/image-10-300x168.png 300w, https://serverstadium.com/wp-content/uploads/2022/10/image-10-1024x573.png 1024w, https://serverstadium.com/wp-content/uploads/2022/10/image-10-768x429.png 768w" sizes="(max-width: 977px) 100vw, 977px" />
<figcaption>Monit&#8217;s Web UI</figcaption>
</figure>
</div>


<h2 class="has-vivid-cyan-blue-color has-text-color wp-block-heading">Monitoring things</h2>



<p class="wp-block-paragraph">Monit can monitor a variety of things, for instance:</p>



<ul class="wp-block-list">
<li>Monitor websites using HTTP or HTTPS protocol</li>
<li>Monitor TCP ports</li>
<li>Monitor remote hosts</li>
<li>Monitor popular protocols like SMTP, FTP, LDAP, etc.</li>
<li>Monitor SSL certificates</li>
<li>Monitor processes</li>
<li>Monitor files, directories, and disks</li>
<li>Monitor network interfaces</li>
<li>Monitor a program&#8217;s output</li>
<li>Etc.</li>
</ul>



<p class="wp-block-paragraph">This time, I&#8217;ll show an example of monitoring a remote host and local disk usage.</p>



<h3 class="has-vivid-cyan-blue-color has-text-color wp-block-heading">Monitor a remote host</h3>



<p class="wp-block-paragraph"><strong>Step 1.</strong> Go to <code>/etc/monit/conf.d</code> and create a new file. The name could be anything, but for example, name it simply &#8220;host&#8221;</p>



<p class="wp-block-paragraph"><strong>Step 2.</strong> Edit the file with the following content:</p>



<pre class="wp-block-code has-background" style="background-color: #ffecbf;"><code>check host myhost with address IP-ADDRESS
    if failed ping then alert</code></pre>



<p class="wp-block-paragraph">It means that we monitor a host at the specified IP-ADDRESS, and if it can&#8217;t be pinged, then send an alert. Pretty straightforward, right?</p>



<p class="wp-block-paragraph"><strong>Step 3.</strong> Do a <code>sudo monit reload</code> to allow Monit to reload its configurations without stopping the service.</p>



<p class="wp-block-paragraph"><strong>Step 4.</strong> Check the monitoring using <code>sudo monit status myhost</code></p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img decoding="async" width="571" height="247" class="wp-image-2775" src="https://serverstadium.com/wp-content/uploads/2022/10/image-11.png" alt="" srcset="https://serverstadium.com/wp-content/uploads/2022/10/image-11.png 571w, https://serverstadium.com/wp-content/uploads/2022/10/image-11-300x130.png 300w" sizes="(max-width: 571px) 100vw, 571px" />
<figcaption>Monitor status</figcaption>
</figure>
</div>


<h3 class="has-vivid-cyan-blue-color has-text-color wp-block-heading">Monitor a local disk</h3>



<p class="wp-block-paragraph"><strong>Step 1.</strong> Create a new config file in <code>/etc/monit/conf.d</code> and name it a &#8220;disk&#8221;</p>



<p class="wp-block-paragraph"><strong>Step 2.</strong> Fill in the file with the following configuration. You may change the disk to your actual disk path:</p>



<pre class="wp-block-code has-background" style="background-color: #ffecbf;"><code>check filesystem root with path /dev/sda1
    if space usage &gt; 90% then alert</code></pre>



<p class="wp-block-paragraph"><strong>Step 3.</strong> Reload monit: <code>sudo monit reload</code></p>



<p class="wp-block-paragraph"><strong>Step 4.</strong> Verify the monitor: <code>sudo monit status root</code></p>


<div class="wp-block-image">
<figure class="aligncenter size-full is-resized"><img loading="lazy" decoding="async" class="wp-image-2776" src="https://serverstadium.com/wp-content/uploads/2022/10/image-12.png" alt="" width="680" height="461" srcset="https://serverstadium.com/wp-content/uploads/2022/10/image-12.png 907w, https://serverstadium.com/wp-content/uploads/2022/10/image-12-300x203.png 300w, https://serverstadium.com/wp-content/uploads/2022/10/image-12-768x520.png 768w" sizes="(max-width: 680px) 100vw, 680px" />
<figcaption>Disk monitoring status</figcaption>
</figure>
</div>


<h2 class="has-vivid-cyan-blue-color has-text-color wp-block-heading">Configure email alerting</h2>



<p class="wp-block-paragraph"><strong>Step 1.</strong> Open <code>/etc/monit/monitrc</code></p>



<p class="wp-block-paragraph"><strong>Step 2.</strong> Add the following lines and adjust the data accordingly</p>



<pre class="wp-block-code has-background" style="background-color: #ffecbf;"><code>set maileserver your.smtp-server.com port the-port
    username "username" password "password"
    using tls 

set alert alert-recipient@example.com</code></pre>



<p class="wp-block-paragraph">However, if you only have a public mailing service like Gmail for instance, you can use the following configuration:</p>



<pre class="wp-block-code has-background" style="background-color: #ffecbf;"><code>set mailserver smtp.gmail.com port 587
    username "username-without-atgmailcom" password "the-password"
    using tls
    with timeout 30 seconds

set alert alert-recipient@example.com</code></pre>



<p class="wp-block-paragraph"><strong>Step 3.</strong> Test the alert by simply reloading the Monit. Example email:</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img decoding="async" class="wp-image-2778" src="https://serverstadium.com/wp-content/uploads/2022/10/image-13.png" alt="" />
<figcaption>Alert email from monit</figcaption>
</figure>
</div>


<p class="wp-block-paragraph">You can change the alerting format in the <code>monitrc</code> file; try looking around at the config.</p>



<h2 class="has-vivid-cyan-blue-color has-text-color wp-block-heading">Additional Notes</h2>



<p class="wp-block-paragraph">For more examples of how to add other monitoring types, please visit Monit&#8217;s official documentation here: <a href="https://mmonit.com/monit/documentation/monit.html" target="_blank" rel="noreferrer noopener">https://mmonit.com/monit/documentation/monit.html</a></p>



<h2 class="has-vivid-cyan-blue-color has-text-color wp-block-heading">Conclusion</h2>



<p class="wp-block-paragraph">It&#8217;s so easy to install and configure Monit and monitor things.</p>



<p class="wp-block-paragraph">Find more tips and tutorials article in ServerStadium&#8217;s <strong><a href="https://serverstadium.com/knowledge-base/" target="_blank" rel="noreferrer noopener">Knowledge Base</a>.</strong> Even better, you can<strong><a href="https://cp.serverstadium.com/regist-user" target="_blank" rel="noreferrer noopener"> register</a></strong> in ServerStadium and try our powerful VM.</p>
<p>The post <a href="https://serverstadium.com/knowledge-base/simple-monitoring-and-alerting-with-monit-on-ubuntu-22-04-lts/">Simple monitoring and alerting with Monit on Ubuntu 22.04 LTS</a> appeared first on <a href="https://serverstadium.com">ServerStadium</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Using the SSH key Feature in ServerStadium Dashboard</title>
		<link>https://serverstadium.com/knowledge-base/using-the-ssh-key-feature-in-serverstadium-dashboard/</link>
		
		<dc:creator><![CDATA[Brian K]]></dc:creator>
		<pubDate>Wed, 13 Apr 2022 03:58:44 +0000</pubDate>
				<guid isPermaLink="false">https://cloudraya.com/knowledge-base/?p=1911</guid>

					<description><![CDATA[<p>In ServerStadium, we have several ways to access our VM. If we want to securely access the VM, we can use the SSH key feature. It is really simple to generate the SSH key because ServerStadium will help us to generate and insert it into the VM. Below are the steps that we can follow:&#8230;</p>
<p>The post <a href="https://serverstadium.com/knowledge-base/using-the-ssh-key-feature-in-serverstadium-dashboard/">Using the SSH key Feature in ServerStadium Dashboard</a> appeared first on <a href="https://serverstadium.com">ServerStadium</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">In ServerStadium, we have several ways to access our VM. If we want to securely access the VM, we can use the SSH key feature.</p>



<p class="wp-block-paragraph">It is really simple to generate the SSH key because ServerStadium will help us to generate and insert it into the VM. Below are the steps that we can follow:</p>



<h2 class="has-vivid-cyan-blue-color has-text-color wp-block-heading"><strong>Create SSH Ke</strong>y</h2>



<p class="wp-block-paragraph">After <a href="https://cp.serverstadium.com/" target="_blank" rel="noreferrer noopener">login into the ServerStadium dashboard</a>, we can click <strong>Networking </strong>then Choose <strong>SSH</strong>. <br />Change the Location to &#8220;<strong>Surabaya</strong>&#8220;.<br />In the right pane, we can click the &#8220;<strong>Create SSH</strong>&#8221; key button to generate the SSH key.</p>



<figure class="wp-block-image size-full"><img decoding="async" class="wp-image-1912" src="https://serverstadium.com/wp-content/uploads/2022/04/image.png" alt="" /></figure>



<p class="wp-block-paragraph">Then, it will display a new screen and fill it as follow :</p>



<figure class="wp-block-image size-full"><img decoding="async" class="wp-image-2023" src="https://serverstadium.com/wp-content/uploads/2022/04/create-1.png" alt="" /></figure>



<p class="wp-block-paragraph">After we click Create New SSH key button, our SSH key will be listed on the SSH list.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1310" height="213" class="wp-image-2025" src="https://serverstadium.com/wp-content/uploads/2022/04/download-ssh.png" alt="" srcset="https://serverstadium.com/wp-content/uploads/2022/04/download-ssh.png 1310w, https://serverstadium.com/wp-content/uploads/2022/04/download-ssh-300x49.png 300w, https://serverstadium.com/wp-content/uploads/2022/04/download-ssh-1024x166.png 1024w, https://serverstadium.com/wp-content/uploads/2022/04/download-ssh-768x125.png 768w" sizes="(max-width: 1310px) 100vw, 1310px" /></figure>



<p class="wp-block-paragraph">Click the &#8220;Download&#8221; button and save the private key to your computer or server that we will use to connect to the VM in ServerStadium.</p>



<figure class="wp-block-image size-full"><img decoding="async" class="wp-image-1924" src="https://serverstadium.com/wp-content/uploads/2022/04/ssh-key.cr_.png" alt="" /></figure>



<p class="wp-block-paragraph">&nbsp;</p>



<p class="wp-block-paragraph">After downloading the SSH, the ServerStadium dashboard will display the SSH key name.</p>



<figure class="wp-block-image size-full"><img decoding="async" class="wp-image-1926" src="https://serverstadium.com/wp-content/uploads/2022/04/image-4.png" alt="" /></figure>



<h2 class="has-vivid-cyan-blue-color has-text-color wp-block-heading"><br /><strong>Create VM using SSH Key</strong></h2>



<p class="wp-block-paragraph">Next, we can continue creating the VM using the SSH key. <br />Click Add VM and in the right pane, choose the <strong>SSH Key</strong> with <strong>ssh-key-cr</strong>. <br />Choose the OS image; in this tutorial, we will use Ubuntu 20.04. <br />Click next until the VM is created.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1157" height="422" class="wp-image-1927" src="https://serverstadium.com/wp-content/uploads/2022/04/image-5.png" alt="" srcset="https://serverstadium.com/wp-content/uploads/2022/04/image-5.png 1157w, https://serverstadium.com/wp-content/uploads/2022/04/image-5-300x109.png 300w, https://serverstadium.com/wp-content/uploads/2022/04/image-5-1024x373.png 1024w, https://serverstadium.com/wp-content/uploads/2022/04/image-5-768x280.png 768w" sizes="(max-width: 1157px) 100vw, 1157px" /></figure>



<p class="wp-block-paragraph">After the VM has been created, we can see SSH key Name on the bottom right specification of the VM.</p>



<figure class="wp-block-image size-full"><img decoding="async" class="wp-image-1928" src="https://serverstadium.com/wp-content/uploads/2022/04/image-6.png" alt="" /></figure>



<p class="wp-block-paragraph">It means we are ready to access the VM using the SSH key.</p>



<p class="wp-block-paragraph"><strong>Access the server using the SSH key</strong></p>



<p class="wp-block-paragraph">Now, we will verify the Private key that we have downloaded previously.<br />Login to your PC or server, then copy the downloaded private key. Change the permission of the private key as follow</p>



<pre class="wp-block-preformatted"># chmod 400 ssh-key-cr</pre>



<p class="wp-block-paragraph">Connect your VM in ServerStadium using a command.</p>



<p class="wp-block-paragraph">ssh -i ssh-key-cr 199.180.xx.xx <br />or <br />ssh -i ssh-key-cr IP_Address_ServerStadium</p>



<figure class="wp-block-image size-full"><img decoding="async" class="wp-image-1934" src="https://serverstadium.com/wp-content/uploads/2022/04/CR.png" alt="" /></figure>



<p class="wp-block-paragraph">&nbsp;</p>



<h2 class="has-vivid-cyan-blue-color has-text-color wp-block-heading"><strong>Add SSH key before the SSH key feature displayed in the previous VM</strong></h2>



<p class="wp-block-paragraph">SSH key feature will be working on the new VM. We can still use the SSH key feature for the previous VM that was deployed. We can follow the steps below:</p>



<p class="wp-block-paragraph">Login to the VM where we will enable the SSH key, then edit /etc/cloud/cloud.cfg as follow:</p>



<figure class="wp-block-image size-full"><img decoding="async" class="wp-image-1943" src="https://serverstadium.com/wp-content/uploads/2022/04/cloud.cfg_.png" alt="" /></figure>



<p class="wp-block-paragraph">Save the file, then stop or shut down the VM. In Detail Information of the VM, click <strong>Reset SSH Key</strong>.</p>



<figure class="wp-block-image size-full"><img decoding="async" class="wp-image-1938" src="https://serverstadium.com/wp-content/uploads/2022/04/image-8.png" alt="" /></figure>



<p class="wp-block-paragraph">Choose the SSH key that we want to use &#8220;ssh-key-cr&#8221; and tick &#8220;It will perform reset VM root password too&#8221;. After that, click &#8220;Reset SSH&#8221;</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="495" height="428" class="wp-image-2017" src="https://serverstadium.com/wp-content/uploads/2022/04/reset.png" alt="" srcset="https://serverstadium.com/wp-content/uploads/2022/04/reset.png 495w, https://serverstadium.com/wp-content/uploads/2022/04/reset-300x259.png 300w" sizes="(max-width: 495px) 100vw, 495px" /></figure>



<p class="wp-block-paragraph">After all the setting has been configured, start the VM again to use the new configuration.<br />We can ensure the VM using a new configuration by file /root/.ssh/authorized_keys has the public key.</p>



<figure class="wp-block-image size-full"><img decoding="async" class="wp-image-1946" src="https://serverstadium.com/wp-content/uploads/2022/04/ssh.png" alt="" /></figure>



<p class="wp-block-paragraph">Now your VM in ServerStadium Cloud is using the SSH key. Please don&#8217;t hesitate to contact our support if you have difficulties using the SSH key.</p>



<p class="wp-block-paragraph">Find more tutorial articles in <strong><a href="https://serverstadium.com/knowledge-base/" target="_blank" rel="noreferrer noopener">ServerStadium&#8217;s Knowledge Base</a></strong>, </p>
<p>The post <a href="https://serverstadium.com/knowledge-base/using-the-ssh-key-feature-in-serverstadium-dashboard/">Using the SSH key Feature in ServerStadium Dashboard</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 install and secure MariaDB on Ubuntu 18.04 and 20.04 on ServerStadium</title>
		<link>https://serverstadium.com/knowledge-base/how-to-install-and-secure-mariadb-on-ubuntu-18-04-and-20-04/</link>
		
		<dc:creator><![CDATA[Brian K]]></dc:creator>
		<pubDate>Mon, 22 Mar 2021 05:43:31 +0000</pubDate>
				<guid isPermaLink="false">https://cloudraya.com/knowledge-base/?p=937</guid>

					<description><![CDATA[<p>In this article, we are going to show you how to install and secure MariaDB on Ubuntu 18.04 and 20.04 on ServerStadium, after previously talking about MongoDB. Read also: How to Install and Secure MongoDB on Ubuntu 18.04 and 20.04 But, before that, let&#8217;s define what MariaDB is. In short, MariaDB is an open-source, community-developed,&#8230;</p>
<p>The post <a href="https://serverstadium.com/knowledge-base/how-to-install-and-secure-mariadb-on-ubuntu-18-04-and-20-04/">How to install and secure MariaDB on Ubuntu 18.04 and 20.04 on ServerStadium</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 are going to show you how to install and secure MariaDB on Ubuntu 18.04 and 20.04 on ServerStadium, after previously talking about MongoDB.</p>



<p class="wp-block-paragraph">Read also: <a href="https://serverstadium.com/knowledge-base/how-to-install-and-securing-mongodb-on-ubuntu-18-04-and-20-04/" target="_blank" rel="noreferrer noopener">How to Install and Secure MongoDB on Ubuntu 18.04 and 20.04</a></p>



<p class="wp-block-paragraph">But, before that, let&#8217;s define what MariaDB is. In short, MariaDB is an open-source, community-developed, forever free relational database management system (RDBMS) forked from MySQL. However, it is highly compatible with MySQL as a drop-in replacement.</p>



<p class="wp-block-paragraph">So, check the steps below to install and secure <strong>MariaDB 10.5</strong> for <strong>Ubuntu 18.04</strong> and <strong>Ubuntu 20.04</strong> instances on ServerStadium.</p>



<h2 class="has-vivid-cyan-blue-color has-text-color wp-block-heading">TLDR</h2>



<p class="wp-block-paragraph">For those who need quick steps:</p>



<ol class="wp-block-list">
<li>Firstly, Enter the commands below</li>
<li>Secondly, allow remote connections to port 3306/TCP on the Security Profile.</li>
</ol>



<div class="wp-block-group"><div class="wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow">
<pre class="wp-block-code"><code>&lt;code&gt;sudo apt update &amp;amp;&amp;amp; sudo apt install apt-transport-https -y
curl -LsS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | sudo bash
sudo apt install mariadb-server -y
sudo mysql_secure_installation
# For remote connection, otherwise ignore these lines
sudo sed -Ei 's/(bind-address *=).*/\1 INTERFACE-IP/' /etc/mysql/mariadb.conf.d/50-server.cnf
sudo systemctl restart mariadb
sudo ufw allow 3306/tcp&lt;/code&gt;</code></pre>
</div></div>



<h2 class="has-vivid-cyan-blue-color has-text-color wp-block-heading">How to Install MariaDB</h2>



<p class="wp-block-paragraph">MariaDB hasn&#8217;t been shipped to Ubuntu 18.04 / 20.04 official repository yet. So you will have to download it directly from <a href="https://mariadb.com">https://mariadb.com</a>. After that, you can either do the following:</p>



<ol class="wp-block-list">
<li>Download the binary packages, or</li>
<li>Setup the repository via script</li>
</ol>



<p class="wp-block-paragraph">Hence, this tutorial will cover the second method.</p>



<h3 class="has-vivid-cyan-blue-color has-text-color wp-block-heading">Step 1. Install apt-transport-https</h3>



<p class="wp-block-paragraph">Firstly, the installer script needs <code>apt-transport-https</code> package.</p>



<pre class="wp-block-code"><code>sudo apt update
sudo apt install apt-transport-https -y</code></pre>



<h3 class="has-vivid-cyan-blue-color has-text-color wp-block-heading">Step 2. Pull the script and execute</h3>



<p class="wp-block-paragraph">You can download the script on</p>



<pre class="wp-block-preformatted"><code>https://downloads.mariadb.com/MariaDB/mariadb_repo_setup</code></pre>



<p class="wp-block-paragraph">and run it, but you can do it in one-liner like this instead:</p>



<pre class="wp-block-code"><code>curl -LsS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | sudo bash</code></pre>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p>A brief explanation about the <code>-LsS</code> flags on <code>curl </code>command: <br />&#8211; <code>L</code> Curl will follow any redirects <br />&#8211; <code>s</code> Silent all outputs <br />&#8211; <code>S</code> If used together with <code>s</code>, it will output error messages <em>only</em> on failure</p>
</blockquote>



<figure class="wp-block-image size-large is-resized"><img loading="lazy" decoding="async" class="wp-image-938" src="https://serverstadium.com/wp-content/uploads/2021/01/image-43.png" alt="" width="679" height="195" srcset="https://serverstadium.com/wp-content/uploads/2021/01/image-43.png 2048w, https://serverstadium.com/wp-content/uploads/2021/01/image-43-300x86.png 300w, https://serverstadium.com/wp-content/uploads/2021/01/image-43-1024x294.png 1024w, https://serverstadium.com/wp-content/uploads/2021/01/image-43-768x221.png 768w, https://serverstadium.com/wp-content/uploads/2021/01/image-43-1536x441.png 1536w" sizes="(max-width: 679px) 100vw, 679px" />
<figcaption>MariaDB repo setup script</figcaption>
</figure>



<h3 class="has-vivid-cyan-blue-color has-text-color wp-block-heading">Step 3. Install mariadb-server</h3>



<p class="wp-block-paragraph">You don&#8217;t have to update the repository, as the script has done it for you. So, proceed to install:</p>



<pre class="wp-block-code"><code>sudo apt install mariadb-server -y</code></pre>



<h2 class="has-vivid-cyan-blue-color has-text-color wp-block-heading">Configuration</h2>



<h3 class="has-vivid-cyan-blue-color has-text-color wp-block-heading">Step 4. Secure the installation</h3>



<p class="wp-block-paragraph">To secure the MariaDB installation, run:</p>



<pre class="wp-block-code"><code>sudo mysql_secure_installation</code></pre>



<p class="wp-block-paragraph">Then, answer every prompt with yes.</p>



<figure class="wp-block-image size-large is-resized"><img loading="lazy" decoding="async" class="wp-image-939" src="https://serverstadium.com/wp-content/uploads/2021/01/image-44.png" alt="" width="782" height="1446" srcset="https://serverstadium.com/wp-content/uploads/2021/01/image-44.png 1564w, https://serverstadium.com/wp-content/uploads/2021/01/image-44-162x300.png 162w, https://serverstadium.com/wp-content/uploads/2021/01/image-44-554x1024.png 554w, https://serverstadium.com/wp-content/uploads/2021/01/image-44-768x1420.png 768w, https://serverstadium.com/wp-content/uploads/2021/01/image-44-831x1536.png 831w, https://serverstadium.com/wp-content/uploads/2021/01/image-44-1108x2048.png 1108w" sizes="(max-width: 782px) 100vw, 782px" />
<figcaption>Securing MariaDB installation</figcaption>
</figure>



<h3 class="has-vivid-cyan-blue-color has-text-color wp-block-heading">Step 5. Enable remote access</h3>



<p class="wp-block-paragraph">The default setting for a fresh MariaDB installation is to allow only local connections. So, you can verify it via the below syntax:</p>



<pre class="wp-block-code"><code>sudo ss -tulpn | grep mariadb</code></pre>



<figure class="wp-block-image size-large is-resized"><img loading="lazy" decoding="async" class="wp-image-940" src="https://serverstadium.com/wp-content/uploads/2021/01/image-45.png" alt="" width="768" height="180" srcset="https://serverstadium.com/wp-content/uploads/2021/01/image-45.png 1024w, https://serverstadium.com/wp-content/uploads/2021/01/image-45-300x70.png 300w, https://serverstadium.com/wp-content/uploads/2021/01/image-45-768x180.png 768w" sizes="(max-width: 768px) 100vw, 768px" />
<figcaption>MariaDB is listening on 127.0.0.1</figcaption>
</figure>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p><code>ss -tulpn</code> will list all listening ports/sockets. <br />&#8211; <code>t</code> Display TCP sockets.<br />&#8211; <code>u</code> Display UDP sockets. <br />&#8211; <code>l</code> Display only listening sockets. <br />&#8211; <code>p</code> Show process using socket. <br />&#8211; <code>n</code> Do not try to resolve service names.</p>
</blockquote>



<p class="wp-block-paragraph">There, you will see that it listens to loopback IP (127.0.0.1), which means it will not accept remote connections.</p>



<p class="wp-block-paragraph">If you plan to build an app on the same server, then this is enough, and you can ignore the rest of the steps. But, if this is not the case, you can keep going.</p>



<p class="wp-block-paragraph">Then, Open <code>/etc/mysql/mariadb.conf.d/50-server.conf</code> and find the line <code>bind-address</code>. After that, change the IP address  <code>127.0.0.1</code> to your interface IP.</p>



<pre class="wp-block-code"><code>sudoedit /etc/mysql/mariadb.conf.d/50-server.conf
# find line 'bind-address = 127.0.0.1'
# change it to interface's IP</code></pre>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="900" height="276" class="wp-image-941" src="https://serverstadium.com/wp-content/uploads/2021/01/image-46.png" alt="" srcset="https://serverstadium.com/wp-content/uploads/2021/01/image-46.png 900w, https://serverstadium.com/wp-content/uploads/2021/01/image-46-300x92.png 300w, https://serverstadium.com/wp-content/uploads/2021/01/image-46-768x236.png 768w" sizes="(max-width: 900px) 100vw, 900px" />
<figcaption>Change bind-address</figcaption>
</figure>



<p class="wp-block-paragraph">If you are not sure which IP to set, then you can check it by using the below command:</p>



<pre class="wp-block-code"><code>ip -4 -br a s</code></pre>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="801" height="240" class="wp-image-942" src="https://serverstadium.com/wp-content/uploads/2021/01/image-47.png" alt="" srcset="https://serverstadium.com/wp-content/uploads/2021/01/image-47.png 801w, https://serverstadium.com/wp-content/uploads/2021/01/image-47-300x90.png 300w, https://serverstadium.com/wp-content/uploads/2021/01/image-47-768x230.png 768w" sizes="(max-width: 801px) 100vw, 801px" />
<figcaption>Display IP addresses</figcaption>
</figure>



<p class="wp-block-paragraph">After you have changed the bind-address, you need to restart the MariaDB service.</p>



<pre class="wp-block-code"><code>sudo systemctl restart mariadb
# check the status
sudo systemctl status mariadb</code></pre>



<figure class="wp-block-image size-large is-resized"><img loading="lazy" decoding="async" class="wp-image-943" src="https://serverstadium.com/wp-content/uploads/2021/01/image-48.png" alt="" width="768" height="461" srcset="https://serverstadium.com/wp-content/uploads/2021/01/image-48.png 1024w, https://serverstadium.com/wp-content/uploads/2021/01/image-48-300x180.png 300w, https://serverstadium.com/wp-content/uploads/2021/01/image-48-768x461.png 768w" sizes="(max-width: 768px) 100vw, 768px" />
<figcaption>MariaDB service status</figcaption>
</figure>



<h3 class="has-vivid-cyan-blue-color has-text-color wp-block-heading">Step 6. Allow port 3306/TCP on ufw</h3>



<p class="wp-block-paragraph">By default, both Ubuntu 18.04 and Ubuntu 20.04 are using <code>ufw</code>. But first, check if it&#8217;s active or not:</p>



<pre class="wp-block-code"><code>sudo ufw status</code></pre>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="822" height="298" class="wp-image-944" src="https://serverstadium.com/wp-content/uploads/2021/01/image-49.png" alt="" srcset="https://serverstadium.com/wp-content/uploads/2021/01/image-49.png 822w, https://serverstadium.com/wp-content/uploads/2021/01/image-49-300x109.png 300w, https://serverstadium.com/wp-content/uploads/2021/01/image-49-768x278.png 768w" sizes="(max-width: 822px) 100vw, 822px" />
<figcaption>Display UFW status</figcaption>
</figure>



<p class="wp-block-paragraph">If it&#8217;s inactive, then skip this step. Otherwise, you need to allow mariadb (3306/tcp).</p>



<pre class="wp-block-code"><code>sudo ufw allow 3306/tcp
# or
sudo ufw allow mysql</code></pre>



<p class="wp-block-paragraph">Then, verify by using <code>sudo ufw status</code></p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="850" height="378" class="wp-image-945" src="https://serverstadium.com/wp-content/uploads/2021/01/image-50.png" alt="" srcset="https://serverstadium.com/wp-content/uploads/2021/01/image-50.png 850w, https://serverstadium.com/wp-content/uploads/2021/01/image-50-300x133.png 300w, https://serverstadium.com/wp-content/uploads/2021/01/image-50-768x342.png 768w" sizes="(max-width: 850px) 100vw, 850px" /></figure>



<h3 class="has-vivid-cyan-blue-color has-text-color wp-block-heading">Step 7. Add Firewall Rule on the Security Profile on ServerStadium</h3>



<p class="wp-block-paragraph">Add TCP port 3306 (MySQL default port) to the Security Profile to allow remote public connections.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="826" height="346" class="wp-image-946" src="https://serverstadium.com/wp-content/uploads/2021/01/image-51.png" alt="" srcset="https://serverstadium.com/wp-content/uploads/2021/01/image-51.png 826w, https://serverstadium.com/wp-content/uploads/2021/01/image-51-300x126.png 300w, https://serverstadium.com/wp-content/uploads/2021/01/image-51-768x322.png 768w" sizes="(max-width: 826px) 100vw, 826px" />
<figcaption>Add Firewall Rule on the Security Profile</figcaption>
</figure>



<p class="wp-block-paragraph">All in all, that is how you install and secure MariaDB on Ubuntu 18.04 and 20.04. If you are eager for more information, you should check our previous article about installing and securing<a href="https://serverstadium.com/knowledge-base/how-to-install-and-securing-mongodb-on-ubuntu-18-04-and-20-04/" target="_blank" rel="noreferrer noopener"> MongoDB on Ubuntu</a>.</p>
<p>The post <a href="https://serverstadium.com/knowledge-base/how-to-install-and-secure-mariadb-on-ubuntu-18-04-and-20-04/">How to install and secure MariaDB on Ubuntu 18.04 and 20.04 on ServerStadium</a> appeared first on <a href="https://serverstadium.com">ServerStadium</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>How to Install and Securing MongoDB on Ubuntu 18.04 and 20.04</title>
		<link>https://serverstadium.com/knowledge-base/how-to-install-and-securing-mongodb-on-ubuntu-18-04-and-20-04/</link>
		
		<dc:creator><![CDATA[Brian K]]></dc:creator>
		<pubDate>Mon, 08 Mar 2021 11:41:29 +0000</pubDate>
				<guid isPermaLink="false">https://cloudraya.com/knowledge-base/?p=926</guid>

					<description><![CDATA[<p>Many wonder how to install and secure MongoDB, especially in Ubuntu 18.04 and 20.04. Before that, let&#8217;s define what MongoDB is. MongoDB is a general-purpose document database that stores its data in JSON-like documents. It also claimed this is the most natural way to think about data. MongoDB has features that traditional databases in Relational&#8230;</p>
<p>The post <a href="https://serverstadium.com/knowledge-base/how-to-install-and-securing-mongodb-on-ubuntu-18-04-and-20-04/">How to Install and Securing MongoDB on Ubuntu 18.04 and 20.04</a> appeared first on <a href="https://serverstadium.com">ServerStadium</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">Many wonder how to install and secure MongoDB, especially in Ubuntu 18.04 and 20.04. Before that, let&#8217;s define what MongoDB is.</p>



<p class="wp-block-paragraph">MongoDB is a general-purpose document database that stores its data in <a href="https://www.json.org/json-en.html" target="_blank" rel="noreferrer noopener">JSON</a>-like documents. It also claimed this is the most natural way to think about data.</p>



<pre class="wp-block-code"><code>
#JSON file example
{
  "os": "Ubuntu",
  "company": "Canonical Ltd.",
  "founder": {
    "name": "Mark Shuttleworth"
  },
  "age": "16",
  "flavours": [
    "👽︎ Kubuntu",
    "✔ Lubuntu",
    "MATE",
    "Xubuntu"
  ]
}</code></pre>



<p class="wp-block-paragraph">MongoDB has features that traditional databases in Relational Database Management (RDBMS), like MariaDB and PostgreSQL, don&#8217;t have or need additional steps to set up properly, such as:</p>



<ol class="wp-block-list">
<li>Expressive and Flexible means you can create a dynamic data structure, no database schema that you have to define first. Also, MongoDB supports schema-less databases, whereas, in RDBMS, you have to define the schema first and follow that schema.</li>
<li>MongoDB can be easily scaled out by adding a new server as a replica, adding more READ performance.</li>
<li>In High availability terms, the MongoDB cluster can automatically failover to an active node when a Master Node is down.</li>
</ol>



<pre class="wp-block-code"><code>## MySQL way
# initialization 
CREATE TABLE `JSON_in_RDBMS` (
   `os` VARCHAR(150) NOT NULL,
   `company` VARCHAR(150) NOT NULL,
   `founder` VARCHAR(150) NOT NULL,
   `age` INT, 
   `flavours` VARCHAR(150) NOT NULL)
ENGINE =  InnoDB;

# inserting the data
INSERT INTO `JSON_in_RDBMS` (`os`, `company`, `founder`, `age`, `flavours`) VALUES ('Ubuntu1', 'Canonical Ltd.', 'Mark Shuttleworth', '16', 'Kubuntu, Lubuntu, MATE, Xubuntu')</code></pre>



<p class="wp-block-paragraph">&nbsp;</p>



<h2 class="has-vivid-cyan-blue-color has-text-color wp-block-heading"><strong>Installing MongoDB on Ubuntu</strong></h2>



<p class="wp-block-paragraph">This tutorial will cover the installation of <em>MongoDB Community Edition</em> on <em>64-bit</em> <em><a href="http://ubuntu.com/">Ubuntu Linux</a> LTS</em> (long-term support) releases using the <em><a href="https://ubuntu.com/server/docs/package-management"><code>apt</code> package manage</a>r</em>, especially on the 18.04 (<a href="http://releases.ubuntu.com/bionic">Bionic</a>) and 20.04 (<a href="http://releases.ubuntu.com/focal">Focal</a>) LTS releases on <a href="https://en.wikipedia.org/wiki/X86-64">x86_64</a> architecture.</p>



<h3 class="has-vivid-cyan-blue-color has-text-color wp-block-heading">1. Import the public key used by the package management system.</h3>



<pre class="wp-block-code"><code># Make sure you have installed the gnupg package
sudo apt-get install gnupg
</code></pre>



<pre class="wp-block-code"><code># Import the MongoDB public GPG Key
wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add -</code></pre>



<h3 class="has-vivid-cyan-blue-color has-text-color wp-block-heading">2. Create a list file for MongoDB repository</h3>



<pre class="wp-block-code"><code># Create the /etc/apt/sources.list.d/mongodb-org-4.4.list file for Ubuntu
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu $(lsb_release -sc)/mongodb-org/4.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list</code></pre>



<pre id="block-750ee643-0f96-4ed1-bb3f-a01e102240c2" class="wp-block-code"><code># Then make sure the local package database reloaded
sudo apt-get update
</code></pre>



<h3 id="block-bf0deaec-35bd-4eeb-ae11-1c096c0829af" class="has-vivid-cyan-blue-color has-text-color wp-block-heading">3. Install MongoDB </h3>



<pre id="block-750ee643-0f96-4ed1-bb3f-a01e102240c2" class="wp-block-code"><code># Install the latest stable package
sudo apt-get install -y mongodb-org</code></pre>



<h3 id="block-bf0deaec-35bd-4eeb-ae11-1c096c0829af" class="has-vivid-cyan-blue-color has-text-color wp-block-heading">4. Run MongoDB</h3>



<pre class="wp-block-code"><code># Start the process on systemd init 
sudo systemctl start mongod</code></pre>



<h3 class="has-vivid-cyan-blue-color has-text-color wp-block-heading">5. MongoDB is up and running !</h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="910" height="192" class="wp-image-968" src="https://serverstadium.com/wp-content/uploads/2021/01/2021-01-28-08_45_47-0_1_bash-_galaxy_.png" alt="" srcset="https://serverstadium.com/wp-content/uploads/2021/01/2021-01-28-08_45_47-0_1_bash-_galaxy_.png 910w, https://serverstadium.com/wp-content/uploads/2021/01/2021-01-28-08_45_47-0_1_bash-_galaxy_-300x63.png 300w, https://serverstadium.com/wp-content/uploads/2021/01/2021-01-28-08_45_47-0_1_bash-_galaxy_-768x162.png 768w" sizes="(max-width: 910px) 100vw, 910px" /></figure>



<pre class="wp-block-code"><code># Enable Autostart the process 
sudo systemctl enable mongod</code></pre>



<pre class="wp-block-code"><code># Restart the process 
sudo systemctl restart mongod</code></pre>



<pre class="wp-block-code"><code># Stop the process
sudo systemctl stop mongod</code></pre>



<pre class="wp-block-code"><code># Verify the process running or stopped
sudo systemctl status mongod</code></pre>



<h2 class="wp-block-heading"><strong>Securing MongoDB on Ubuntu</strong></h2>



<h3 class="has-vivid-cyan-blue-color has-text-color wp-block-heading"><strong>1. Connect to the MongoDB</strong></h3>



<p class="wp-block-paragraph"># First, Connect to the Mongo instance<br />$ mongo<br />MongoDB shell version v4.4.3<br />connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&amp;gssapiServiceName=mongodb<br />Implicit session: session { &#8220;id&#8221; : UUID(&#8220;0cfcaad9-7c56-40ea-81f8-af273c014d5e&#8221;) }<br />MongoDB server version: 4.4.3<br />Welcome to the MongoDB shell.<br />&gt; </p>



<h3 class="has-vivid-cyan-blue-color has-text-color wp-block-heading"><strong>2. Create the user</strong></h3>



<p class="wp-block-paragraph"># Copy and paste this to Mongodb shell</p>



<p class="wp-block-paragraph">use ubi_db<br />db.createUser(<br />{<br />user: &#8220;ubi_user&#8221;,<br />pwd: &#8220;ub1_p4ss&#8221;,<br />roles: [ { role: &#8220;readWrite&#8221;, db: &#8220;ubi_db&#8221; },<br />{ role: &#8220;read&#8221;, db: &#8220;ubi_db_other&#8221; } ]<br />}<br />)</p>



<p class="wp-block-paragraph"><strong>If successfully created, it will show like this output.</strong></p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="518" height="429" class="wp-image-979" src="https://serverstadium.com/wp-content/uploads/2021/02/image.png" alt="" srcset="https://serverstadium.com/wp-content/uploads/2021/02/image.png 518w, https://serverstadium.com/wp-content/uploads/2021/02/image-300x248.png 300w" sizes="(max-width: 518px) 100vw, 518px" /></figure>



<h3 class="has-vivid-cyan-blue-color has-text-color wp-block-heading"><strong>3. Then connect &amp; authenticate as the user</strong></h3>



<p class="wp-block-paragraph"># Inline output on mongo shell command<br />. &gt; use ubi_db<br />switched to db ubi_db<br />. &gt; db.auth(&#8220;ubi_user&#8221;, &#8220;ub1_p4ss&#8221;)<br />db.foo.insert({x:1})<br />1<br />. &gt; db.foo.insert({x:1})<br />WriteResult({ &#8220;nInserted&#8221; : 1 })<br />. &gt; use ubi_db_other<br />switched to db ubi_db_other<br />. &gt; db.foo.find({})</p>



<p class="wp-block-paragraph">&nbsp;</p>
<p>The post <a href="https://serverstadium.com/knowledge-base/how-to-install-and-securing-mongodb-on-ubuntu-18-04-and-20-04/">How to Install and Securing MongoDB on Ubuntu 18.04 and 20.04</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>How to Deploy Container in ServerStadium using Docker</title>
		<link>https://serverstadium.com/knowledge-base/how-to-deploy-container-in-serverstadium-using-docker/</link>
		
		<dc:creator><![CDATA[Brian K]]></dc:creator>
		<pubDate>Mon, 04 Jan 2021 20:41:24 +0000</pubDate>
				<guid isPermaLink="false">https://cloudraya.com/knowledge-base/?p=621</guid>

					<description><![CDATA[<p>This article will explain how to deploy containers in ServerStadium using Docker. Before knowing how to deploy containers using docker, let&#8217;s understand the basic of it. What is Docker? Docker is a tool that allows developers, sys-admins, etc. to easily deploy their applications in a sandbox (called containers) to run on the host operating system, e.g.&#8230;</p>
<p>The post <a href="https://serverstadium.com/knowledge-base/how-to-deploy-container-in-serverstadium-using-docker/">How to Deploy Container in ServerStadium using Docker</a> appeared first on <a href="https://serverstadium.com">ServerStadium</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">This article will explain how to deploy containers in ServerStadium using Docker. Before knowing how to deploy containers using docker, let&#8217;s understand the basic of it.</p>



<h3 class="has-vivid-cyan-blue-color has-text-color wp-block-heading">What is Docker?</h3>



<p class="wp-block-paragraph">Docker is a tool that allows developers, sys-admins, etc. to easily deploy their applications in a sandbox (called <em>containers</em>) to run on the host operating system, e.g. Linux.</p>



<p class="wp-block-paragraph">Accordingly, the key benefit of Docker is that it allows users to <strong>package an application with all of its dependencies into a standardized unit</strong> for software development. Unlike virtual machines, containers do not have high overhead, enabling more efficient usage of the underlying system and resources.</p>



<h3 class="has-vivid-cyan-blue-color has-text-color wp-block-heading">What are containers?</h3>



<p class="wp-block-paragraph">To begin with, the industry standard today is to use Virtual Machines (VMs) to run software applications. VMs run applications inside a guest Operating System, which runs on virtual hardware powered by the server’s host OS.</p>



<p class="wp-block-paragraph">In addition, VMs are great at providing full process isolation for applications. There are very few ways a problem in the host operating system can affect the software running in the guest operating system and vice-versa. But this isolation comes at a great cost — the computational overhead spent virtualizing hardware for a guest OS to use is substantial.</p>



<p class="wp-block-paragraph">Furthermore, containers take a different approach. By leveraging the low-level mechanics of the host operating system, containers provide most of the isolation of virtual machines at a fraction of the computing power.</p>



<h3 class="has-vivid-cyan-blue-color has-text-color wp-block-heading"><strong>Prerequisites</strong></h3>



<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 (LTS)</li>
<li>Latest Docker Engine stable version for Ubuntu 18.04</li>
<li>Latest Docker Repository</li>
</ul>



<p class="wp-block-paragraph">In short, there are three tasks that we need to do:</p>



<ul class="wp-block-list">
<li>Open the necessary port on ServerStadium Security Profile</li>
<li>Install docker (Community Edition)</li>
<li>Deploy or Create a Web Server container with Nginx</li>
</ul>



<h3 class="has-vivid-cyan-blue-color has-text-color wp-block-heading">Open Necessary Port on ServerStadium frontend</h3>



<p class="wp-block-paragraph">Before we start further, open the necessary ports to your instances, go to <a href="https://cp.serverstadium.com/" target="_blank" rel="noreferrer noopener">https://cp.serverstadium.com/</a> &gt;&gt; Home &gt;&gt; networking &gt;&gt; Security Profile</p>



<p class="wp-block-paragraph">There are at least three ports that need to be opened 80, 443 (for HTTP and HTTPS), and 22 (for SSH)</p>



<figure class="wp-block-image size-large is-resized"><img loading="lazy" decoding="async" class="wp-image-809" src="https://serverstadium.com/wp-content/uploads/2021/01/image-36.png" alt="" width="575" height="223" /></figure>



<h3 class="has-vivid-cyan-blue-color has-text-color wp-block-heading">Install Docker</h3>



<p class="wp-block-paragraph">Please run the following command to ensure there is no old docker installed:</p>



<p class="wp-block-paragraph">$ <code>sudo apt-get remove docker docker-engine docker.io containerd runc</code></p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="671" height="215" class="wp-image-658" src="https://serverstadium.com/wp-content/uploads/2020/12/image.png" alt="" srcset="https://serverstadium.com/wp-content/uploads/2020/12/image.png 671w, https://serverstadium.com/wp-content/uploads/2020/12/image-300x96.png 300w" sizes="(max-width: 671px) 100vw, 671px" /></figure>



<p class="wp-block-paragraph">Additionally, it’s OK if <code>apt-get</code> reports that none of these packages are installed.</p>



<p class="wp-block-paragraph"><strong>Install using the repository</strong></p>



<p class="wp-block-paragraph">Before installing Docker Engine for the first time on a new host machine, you must set up the Docker repository. Afterward, you can install and update Docker from the repository.</p>



<p class="wp-block-paragraph">Setup The Repository</p>



<pre class="wp-block-preformatted"><code>$ sudo apt-get update</code></pre>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="689" height="131" class="wp-image-660" src="https://serverstadium.com/wp-content/uploads/2020/12/image-1.png" alt="" srcset="https://serverstadium.com/wp-content/uploads/2020/12/image-1.png 689w, https://serverstadium.com/wp-content/uploads/2020/12/image-1-300x57.png 300w" sizes="(max-width: 689px) 100vw, 689px" /></figure>



<pre class="wp-block-preformatted"><code>$ sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common</code></pre>



<figure class="wp-block-image size-large is-resized"><img loading="lazy" decoding="async" class="wp-image-661" src="https://serverstadium.com/wp-content/uploads/2020/12/image-2.png" alt="" width="800" height="262" srcset="https://serverstadium.com/wp-content/uploads/2020/12/image-2.png 897w, https://serverstadium.com/wp-content/uploads/2020/12/image-2-300x99.png 300w, https://serverstadium.com/wp-content/uploads/2020/12/image-2-768x253.png 768w" sizes="(max-width: 800px) 100vw, 800px" /></figure>



<p class="wp-block-paragraph">There will appear a confirmation prompt; please type &#8220;Y&#8221; to continue</p>



<p class="wp-block-paragraph">Add Docker’s official GPG key:</p>



<pre class="wp-block-preformatted"><code>$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -</code></pre>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="743" height="55" class="wp-image-662" src="https://serverstadium.com/wp-content/uploads/2020/12/image-3.png" alt="" srcset="https://serverstadium.com/wp-content/uploads/2020/12/image-3.png 743w, https://serverstadium.com/wp-content/uploads/2020/12/image-3-300x22.png 300w" sizes="(max-width: 743px) 100vw, 743px" /></figure>



<p class="wp-block-paragraph">To set up the <strong>stable</strong> repository:</p>



<pre class="wp-block-preformatted"><code>$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"</code></pre>



<figure class="wp-block-image size-large is-resized"><img loading="lazy" decoding="async" class="wp-image-663" src="https://serverstadium.com/wp-content/uploads/2020/12/image-4.png" alt="" width="750" height="123" srcset="https://serverstadium.com/wp-content/uploads/2020/12/image-4.png 955w, https://serverstadium.com/wp-content/uploads/2020/12/image-4-300x50.png 300w, https://serverstadium.com/wp-content/uploads/2020/12/image-4-768x127.png 768w" sizes="(max-width: 750px) 100vw, 750px" /></figure>



<p class="wp-block-paragraph"><strong>Install Docker Engine</strong></p>



<p class="wp-block-paragraph">To install the Docker Engine command, run:</p>



<pre class="wp-block-preformatted"><code>$ sudo apt-get install docker-ce docker-ce-cli containerd.io</code></pre>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="588" height="305" class="wp-image-664" src="https://serverstadium.com/wp-content/uploads/2020/12/image-5.png" alt="" srcset="https://serverstadium.com/wp-content/uploads/2020/12/image-5.png 588w, https://serverstadium.com/wp-content/uploads/2020/12/image-5-300x156.png 300w" sizes="(max-width: 588px) 100vw, 588px" /></figure>



<p class="wp-block-paragraph">Verify that Docker Engine is installed correctly by running the <code>hello-world</code> image.</p>



<pre class="wp-block-preformatted"><code>$ sudo docker run hello-world</code></pre>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="630" height="440" class="wp-image-665" src="https://serverstadium.com/wp-content/uploads/2020/12/image-6.png" alt="" srcset="https://serverstadium.com/wp-content/uploads/2020/12/image-6.png 630w, https://serverstadium.com/wp-content/uploads/2020/12/image-6-300x210.png 300w" sizes="(max-width: 630px) 100vw, 630px" /></figure>



<p class="wp-block-paragraph">There will be information that states as follows after verification is running properly:</p>



<pre class="wp-block-preformatted">Hello from Docker!
This message shows that your installation appears to be working correctly.</pre>



<h3 class="has-vivid-cyan-blue-color has-text-color wp-block-heading">Deploy or Create a Web Server container with Nginx</h3>



<p class="wp-block-paragraph">Now, we have to create a simple hosting static content command.</p>



<p class="wp-block-paragraph">Create a folder</p>



<pre class="wp-block-preformatted">mkdir -p <code>/var/www/html</code></pre>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="377" height="49" class="wp-image-807" src="https://serverstadium.com/wp-content/uploads/2021/01/image-34.png" alt="" srcset="https://serverstadium.com/wp-content/uploads/2021/01/image-34.png 377w, https://serverstadium.com/wp-content/uploads/2021/01/image-34-300x39.png 300w" sizes="(max-width: 377px) 100vw, 377px" /></figure>



<p class="wp-block-paragraph">Download, deploy the latest nginx image, and configure the web-root. We named it &#8220;test-nginx&#8221;</p>



<pre class="wp-block-preformatted"><code>docker run --name test-nginx -v /var/www/html:/usr/share/nginx/html:ro -d nginx</code></pre>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="855" height="191" class="wp-image-810" src="https://serverstadium.com/wp-content/uploads/2021/01/image-37.png" alt="" srcset="https://serverstadium.com/wp-content/uploads/2021/01/image-37.png 855w, https://serverstadium.com/wp-content/uploads/2021/01/image-37-300x67.png 300w, https://serverstadium.com/wp-content/uploads/2021/01/image-37-768x172.png 768w" sizes="(max-width: 855px) 100vw, 855px" /></figure>



<p class="wp-block-paragraph">After that, verify if the container is running:</p>



<pre class="wp-block-preformatted">docker container ls</pre>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="812" height="66" class="wp-image-813" src="https://serverstadium.com/wp-content/uploads/2021/01/image-39.png" alt="" srcset="https://serverstadium.com/wp-content/uploads/2021/01/image-39.png 812w, https://serverstadium.com/wp-content/uploads/2021/01/image-39-300x24.png 300w, https://serverstadium.com/wp-content/uploads/2021/01/image-39-768x62.png 768w" sizes="(max-width: 812px) 100vw, 812px" /></figure>



<p class="wp-block-paragraph">Verify whether port 80 it&#8217;s listening not by running the following command:</p>



<pre class="wp-block-preformatted">netstat -tulpn | grep 80</pre>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="718" height="58" class="wp-image-811" src="https://serverstadium.com/wp-content/uploads/2021/01/image-38.png" alt="" srcset="https://serverstadium.com/wp-content/uploads/2021/01/image-38.png 718w, https://serverstadium.com/wp-content/uploads/2021/01/image-38-300x24.png 300w" sizes="(max-width: 718px) 100vw, 718px" /></figure>



<p class="wp-block-paragraph">Then, create a test script:</p>



<pre class="wp-block-preformatted">nano /var/www/html/index.html</pre>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="469" height="32" class="wp-image-814" src="https://serverstadium.com/wp-content/uploads/2021/01/image-40.png" alt="" srcset="https://serverstadium.com/wp-content/uploads/2021/01/image-40.png 469w, https://serverstadium.com/wp-content/uploads/2021/01/image-40-300x20.png 300w" sizes="(max-width: 469px) 100vw, 469px" /></figure>



<p class="wp-block-paragraph">Append the following test script:</p>



<pre class="wp-block-preformatted">TEST WEBSERVER as CONTANIER</pre>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="295" height="56" class="wp-image-815" src="https://serverstadium.com/wp-content/uploads/2021/01/image-41.png" alt="" /></figure>



<p class="wp-block-paragraph">When it&#8217;s done. Save the modification by pressing &#8220;<strong>ctrl + x</strong>&#8220;, Choose &#8220;<strong>Y</strong>&#8221; then press &#8220;<strong>Enter</strong>&#8220;</p>



<p class="wp-block-paragraph">Please open a browser app such as Chrome, or Firefox and insert your Public IP instance: http://202.43.249.138/ and it will show the following display:</p>



<pre class="wp-block-preformatted">TEST WEBSERVER as CONTANIER</pre>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="415" height="118" class="wp-image-816" src="https://serverstadium.com/wp-content/uploads/2021/01/image-42.png" alt="" srcset="https://serverstadium.com/wp-content/uploads/2021/01/image-42.png 415w, https://serverstadium.com/wp-content/uploads/2021/01/image-42-300x85.png 300w" sizes="(max-width: 415px) 100vw, 415px" /></figure>



<h3 class="has-vivid-cyan-blue-color has-text-color wp-block-heading">Docker CheatSheet:</h3>



<p class="wp-block-paragraph"><strong>list all Docker containers</strong></p>



<pre class="wp-block-preformatted"><code>docker container ls -a</code></pre>



<p class="wp-block-paragraph"><strong>Stop a specific container</strong></p>



<pre class="wp-block-preformatted"><code>docker container stop [container_id]</code></pre>



<p class="wp-block-paragraph"><strong>Remove a stopped container</strong></p>



<pre class="wp-block-preformatted"><code>docker container rm [container_id]</code></pre>



<p class="wp-block-paragraph"><strong>Remove all stopped containers:</strong></p>



<pre class="wp-block-preformatted"><code>docker container rm $(docker container ls –aq)</code></pre>



<p class="wp-block-paragraph"><strong>List Docker image</strong></p>



<pre class="wp-block-preformatted"><code>docker image ls</code></pre>



<p class="wp-block-paragraph"><strong>Remove an image, or multiple images:</strong></p>



<pre class="wp-block-preformatted"><code>docker image rm [image_id1]</code></pre>



<pre class="wp-block-preformatted"><code>docker image rm [image_id1] [image_id2]</code></pre>



<h3 class="has-vivid-cyan-blue-color has-text-color wp-block-heading">Conclusion</h3>



<p class="wp-block-paragraph">To sum up, this article explains running NGINX official image, adding our custom HTML files, and creating a container based on the official image</p>



<p class="wp-block-paragraph">Last but not least, we hope this helps you. Thank you.</p>
<p>The post <a href="https://serverstadium.com/knowledge-base/how-to-deploy-container-in-serverstadium-using-docker/">How to Deploy Container in ServerStadium using Docker</a> appeared first on <a href="https://serverstadium.com">ServerStadium</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
