<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Sonumishra on Medium]]></title>
        <description><![CDATA[Stories by Sonumishra on Medium]]></description>
        <link>https://medium.com/@sonumishra19091999?source=rss-3c6bf5ae723f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*OVzVWyzHECKv0lsfDK7XEA.png</url>
            <title>Stories by Sonumishra on Medium</title>
            <link>https://medium.com/@sonumishra19091999?source=rss-3c6bf5ae723f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 04:02:19 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sonumishra19091999/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Facing Issues While Installing Pritunl on Ubuntu 24.04? Here’s How to Resolve Them]]></title>
            <link>https://medium.com/@sonumishra19091999/facing-issues-while-installing-pritunl-on-ubuntu-24-04-heres-how-to-resolve-them-65d2e84ce33f?source=rss-3c6bf5ae723f------2</link>
            <guid isPermaLink="false">https://medium.com/p/65d2e84ce33f</guid>
            <dc:creator><![CDATA[Sonumishra]]></dc:creator>
            <pubDate>Wed, 11 Sep 2024 10:54:23 GMT</pubDate>
            <atom:updated>2024-09-11T10:54:23.258Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*RXBnTZP1eMIGQtwqEa4y-w.png" /></figure><p>If you’re setting up Pritunl on Ubuntu 24.04 and encountering installation issues, you’re not alone. Many users face challenges with package dependencies and repository configurations. In this blog post, we’ll walk through the common problems and provide a step-by-step guide to resolve them, ensuring a smooth installation of Pritunl and its dependencies.</p><h4>Introduction</h4><p>Pritunl is a popular VPN server solution, but installing it on Ubuntu 24.04 can sometimes be tricky due to dependency issues or repository configurations. If you’re running into problems, such as missing dependencies or issues with package repositories, this guide will help you navigate these hurdles.</p><h4>Step-by-Step Installation Guide</h4><p><strong>1. Adding the Pritunl Repository</strong></p><p>First, you need to add the Pritunl repository to your system. This repository provides the necessary packages for Pritunl. Run the following command to create a new source list file for Pritunl:</p><pre>sudo tee /etc/apt/sources.list.d/pritunl.list &lt;&lt; EOF<br>deb http://repo.pritunl.com/stable/apt jammy main<br>EOF</pre><p><strong>2. Import the Pritunl Signing Key</strong></p><p>To ensure the integrity of the packages, you need to add the Pritunl signing key. This can be done using a keyserver or by downloading the key file directly. Use one of the following commands:</p><ul><li>From the keyserver:</li></ul><pre>sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com --recv 7568D9BB55FF9E5287D586017AE645C0CF8E292A</pre><ul><li>Or, if the keyserver is offline, use the direct download method:</li></ul><pre>curl https://raw.githubusercontent.com/pritunl/pgp/master/pritunl_repo_pub.asc | sudo apt-key add -</pre><p><strong>3. Adding the MongoDB Repository</strong></p><p>Pritunl requires MongoDB as its backend. Add the MongoDB repository by creating another source list file:</p><pre>sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list &lt;&lt; EOF<br>deb https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/6.0 multiverse<br>EOF</pre><p><strong>4. Import the MongoDB Signing Key</strong></p><p>Just like with Pritunl, MongoDB packages need to be signed. Add the MongoDB key using:</p><pre>wget -qO - https://www.mongodb.org/static/pgp/server-6.0.asc | sudo apt-key add -</pre><p><strong>5. Update Package Lists</strong></p><p>With the repositories and keys added, update your package lists to include the new repositories:</p><pre>sudo apt update</pre><p><strong>6. Upgrade Installed Packages</strong></p><p>Before installing new software, it’s a good idea to upgrade your existing packages:</p><pre>sudo apt --assume-yes upgrade</pre><p><strong>7. Install WireGuard</strong></p><p>If you’re setting up a VPN, you might need WireGuard. Install it along with its tools:</p><pre>sudo apt -y install wireguard wireguard-tools</pre><p><strong>8. Disable UFW</strong></p><p>In some cases, the Uncomplicated Firewall (UFW) might interfere with VPN installations. Temporarily disable it if necessary:</p><pre>sudo ufw disable</pre><p><strong>9. Install Pritunl and MongoDB</strong></p><p>Now, you can install Pritunl and MongoDB:</p><pre>sudo apt -y install pritunl mongodb-org</pre><p><strong>10. Enable and Start Services</strong></p><p>Finally, enable and start the MongoDB and Pritunl services:</p><pre>sudo systemctl enable mongod pritunl<br>sudo systemctl start mongod pritunl</pre><h4>Troubleshooting Common Issues</h4><ul><li><strong>Unmet Dependencies</strong>: If you encounter issues with unmet dependencies, ensure all required repositories are added and updated. Sometimes, manually installing missing dependencies can help.</li><li><strong>Repository Errors</strong>: Check if the repository URLs are correct and accessible. If you encounter 404 errors, verify that the URLs are valid for your Ubuntu version.</li><li><strong>Service Start Issues</strong>: If services fail to start, check the logs for specific errors using journalctl -xe and ensure all configurations are correct.</li></ul><h4>Conclusion</h4><p>Installing Pritunl on Ubuntu 24.04 involves several steps, from configuring repositories to handling dependencies. By following this guide, you should be able to overcome common issues and successfully set up Pritunl and MongoDB. If you run into specific errors, refer to the logs and documentation for more detailed troubleshooting.</p><p>===============================================================</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=65d2e84ce33f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hosting a Static Website on Amazon S3 with CloudFront and Making it Private]]></title>
            <link>https://medium.com/@sonumishra19091999/hosting-a-static-website-on-amazon-s3-with-cloudfront-and-making-it-private-8fac5e09c0c5?source=rss-3c6bf5ae723f------2</link>
            <guid isPermaLink="false">https://medium.com/p/8fac5e09c0c5</guid>
            <dc:creator><![CDATA[Sonumishra]]></dc:creator>
            <pubDate>Thu, 22 Aug 2024 11:30:26 GMT</pubDate>
            <atom:updated>2024-08-22T12:27:14.568Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LHRQeVnvFR_GUPQSAH2GcA.png" /></figure><h3>Introduction</h3><p>In today’s digital landscape, hosting a website that is both fast and secure is essential. Whether you’re running a personal blog, a portfolio, or a small business site, choosing the right hosting solution is crucial. Among the myriad of options available, Amazon Web Services (AWS) provides a highly reliable and scalable way to host static websites using Amazon S3 and CloudFront.</p><h3>Why Amazon S3?</h3><ul><li><strong>Scalable:</strong> Handles any traffic automatically.</li><li><strong>Reliable:</strong> 99.999999999% durability, 99.99% availability.</li><li><strong>Simple:</strong> Easy to set up and manage.</li><li><strong>Affordable:</strong> Pay only for what you use.</li></ul><h3>Why CloudFront with S3?</h3><ul><li><strong>Faster:</strong> Global edge locations reduce latency.</li><li><strong>Secure:</strong> Protects with AWS security features and HTTPS.</li><li><strong>Efficient:</strong> Caches content to lower costs.</li><li><strong>Controlled:</strong> Restrict access to authorized users only.</li></ul><h3>Steps to Host a Static Website on Amazon S3 with CloudFront and Make it Private</h3><h4>1. Set Up S3 Bucket for Static Website Hosting</h4><ol><li><strong>Create an S3 Bucket</strong></li></ol><ul><li>Go to the S3 console.</li><li>Click <strong>Create bucket</strong>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KvAZe40cb52rR9Ez-vi-rw.png" /></figure><ul><li>Name your bucket (e.g., my-static-website) and select a region, and select the following options.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aFqzmTBVr175aDwPG9TvaQ.png" /></figure><p><strong>2. Upload Your Website Files</strong></p><ul><li>Open your bucket.</li><li>Click <strong>Upload</strong> and add your HTML, CSS, and JavaScript files.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X5-9mYQOHh8TDOzQ5mKPHw.png" /></figure><p><strong>3. Configure Bucket for Static Website Hosting</strong></p><ul><li>Go to the <strong>Properties</strong> tab.</li><li>Scroll to <strong>Static website hosting</strong> and click <strong>Edit</strong>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*glBn_JsMsG-f4zJ5wnukrA.png" /></figure><ul><li>Enable <strong>Static website hosting</strong>.</li><li>Set index.html as the index document and optionally, an error document.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/496/1*KlFwZqA08OiO4mdPSqHTpA.png" /></figure><h4>Step 4: Make Your S3 Content Public</h4><p><strong>. Go to the “Permissions” Tab</strong></p><ul><li>Stay in your bucket’s properties and switch to the <strong>Permissions</strong> tab.</li><li><strong>Update Bucket Policy</strong></li><li>Scroll down to the <strong>Bucket policy</strong> section and click <strong>Edit</strong>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V75Nq90V4Z91TZpTZgWlCQ.png" /></figure><ul><li>Use the following bucket policy template, replacing YourBucketName with your actual bucket name:</li></ul><pre>{<br>  &quot;Version&quot;: &quot;2012-10-17&quot;,<br>  &quot;Statement&quot;: [<br>    {<br>      &quot;Sid&quot;: &quot;PublicReadGetObject&quot;,<br>      &quot;Effect&quot;: &quot;Allow&quot;,<br>      &quot;Principal&quot;: &quot;*&quot;,<br>      &quot;Action&quot;: &quot;s3:GetObject&quot;,<br>      &quot;Resource&quot;: &quot;arn:aws:s3:::YourBucketName/*&quot;<br>    }<br>  ]<br>}</pre><ul><li>Click <strong>Save changes</strong> to update the bucket policy.</li><li>Now check the with the static website url in ur browser.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/949/1*V-IRuFkU_drvaVNz0WJXBg.png" /></figure><h3>Step 5: Create a CloudFront Distribution</h3><ol><li><strong>Navigate to CloudFront<br>. </strong>Go to the CloudFront service in the AWS Console.</li><li><strong>Create Distribution<br>. </strong>Click <strong>Create Distribution</strong>.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kDAXpb9xILWC8trzk52ImA.png" /></figure><p><strong>Choose Web Delivery Method<br>. </strong>Select <strong>Web</strong> as the delivery method.</p><p><strong>Configure Settings</strong></p><ul><li><strong>Origin Domain Name:</strong> Select your S3 bucket from the dropdown.</li><li><strong>Origin Path:</strong> Leave this empty.</li><li><strong>Viewer Protocol Policy:</strong> Redirect HTTP to HTTPS (or adjust based on your needs).</li><li><strong>Allowed HTTP Methods:</strong> GET, HEAD.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WDg7Zc2u0vnQ9PfewNiI3A.png" /></figure><ul><li><strong>Compress Objects Automatically:</strong> Yes.</li><li>Click on <strong>Do not enable security protections</strong></li><li>Select Your <strong>ACM certificate</strong></li><li>Write your default object of the static website in the S3. (eg. “index.html”)</li></ul><p><strong>5. Keep Default Settings<br>. </strong>Leave other settings at their defaults.</p><p><strong>Create Distribution<br>. </strong>Click <strong>Create Distribution</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/567/1*AKm9dR2BQSiHxWYscFAYpA.png" /></figure><h3>Step 6: Test Your Website</h3><ol><li><strong>Wait for Deployment<br>.</strong>Wait for your CloudFront distribution to deploy (status: Deployed).</li><li><strong>Access Your Website<br>. </strong>Use the CloudFront domain name (e.g., d12345abcdefg.cloudfront.net) to access your website.<br>. Verify that your HTML pages load correctly and that URLs are secure (HTTPS).</li></ol><h3>Step 7: Block Public Access and Restrict to CloudFront</h3><h4>1. Create an Origin Access Control (OAC) and Update CloudFront Distribution</h4><ol><li><strong>Navigate to CloudFront in AWS Console<br>. </strong>Go to the CloudFront service in the AWS Console.<br>. <strong>Select Your Distribution</strong></li><li>Find and select the CloudFront distribution you created for your S3 bucket.</li><li><strong>Create an Origin Access Control</strong></li></ol><ul><li>Click <strong>Origin Access Control</strong> from the sidebar.</li><li>Click <strong>Create Origin Access Control</strong>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B7YOkVGGtX_moerS7MBXvQ.png" /></figure><ul><li>Configure the following:</li><li><strong>Name:</strong> Enter a name for the OAC (e.g., MyS3OAC).</li><li><strong>Description:</strong> Optionally add a description.</li><li><strong>Access Control Type:</strong> Select <strong>Origin Access Identity</strong>.</li><li>Click <strong>Create</strong> and note the OAC ID.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1001/1*s1efetca5nMQu9PZZuCjJw.png" /></figure><p>Now copy the new OAC_ID</p><h4>2. Update S3 Bucket Policy to Restrict Access</h4><ol><li><strong>Go to Your S3 Bucket’s Permissions</strong></li></ol><ul><li>Navigate to your S3 bucket in the AWS Console.</li><li>Go to the <strong>Permissions</strong> tab and Block the Public access.</li></ul><p><strong>2. Edit Bucket Policy</strong></p><ul><li>Click <strong>Edit</strong> in the <strong>Bucket Policy</strong> section.</li><li>Use the following policy template, replacing YourBucketName with your bucket name and YOUR_OAC_ID with the OAC ID from CloudFront:</li></ul><pre>{<br>  &quot;Version&quot;: &quot;2012-10-17&quot;,<br>  &quot;Statement&quot;: [<br>    {<br>      &quot;Sid&quot;: &quot;AllowCloudFrontAccess&quot;,<br>      &quot;Effect&quot;: &quot;Allow&quot;,<br>      &quot;Principal&quot;: {<br>        &quot;AWS&quot;: &quot;arn:aws:iam::cloudfront:user/CloudFront Origin Access Identity YOUR_OAC_ID&quot;<br>      },<br>      &quot;Action&quot;: &quot;s3:GetObject&quot;,<br>      &quot;Resource&quot;: &quot;arn:aws:s3:::YourBucketName/*&quot;<br>    },<br>    {<br>      &quot;Sid&quot;: &quot;DenyPublicAccess&quot;,<br>      &quot;Effect&quot;: &quot;Deny&quot;,<br>      &quot;Principal&quot;: &quot;*&quot;,<br>      &quot;Action&quot;: &quot;s3:GetObject&quot;,<br>      &quot;Resource&quot;: &quot;arn:aws:s3:::YourBucketName/*&quot;,<br>      &quot;Condition&quot;: {<br>        &quot;StringNotEquals&quot;: {<br>          &quot;aws:Referer&quot;: &quot;d12345abcdefg.cloudfront.net&quot;<br>        }<br>      }<br>    }<br>  ]<br>}</pre><h4>Verify Configuration</h4><ol><li><strong>Test Access</strong></li></ol><ul><li>Attempt to access your S3 content directly via the S3 URL to confirm access is denied.</li><li>Access your content through the CloudFront URL to ensure it loads correctly.</li></ul><p><strong><em>Congratulations! You’ve successfully hosted your static website using AWS S3 and CloudFront, enjoying enhanced performance, availability, and security.</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8fac5e09c0c5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating FTP in Ubuntu server]]></title>
            <link>https://medium.com/@sonumishra19091999/creating-ftp-in-ubuntu-server-28f49a840529?source=rss-3c6bf5ae723f------2</link>
            <guid isPermaLink="false">https://medium.com/p/28f49a840529</guid>
            <dc:creator><![CDATA[Sonumishra]]></dc:creator>
            <pubDate>Sat, 10 Aug 2024 12:28:38 GMT</pubDate>
            <atom:updated>2024-08-10T12:28:38.723Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MARUUXoNnK-YFul0nVQFig.png" /></figure><p>File Transfer Protocol (FTP) is a widely used standard network protocol that facilitates the transfer of files between a client and server over a network. Whether you’re managing websites, sharing files, or simply moving data between systems, FTP provides a reliable and straightforward method for handling file transfers.<br>In this guide, we will walk you through the process of setting up an FTP server on an Ubuntu system without the need for a .pem file. Before you begin, ensure that your Ubuntu server has ports 20–21 and 40000–50000 open, as these are essential for FTP operations. This setup will allow you to securely transfer files between your server and client systems with ease.</p><h4>Pre-requesite:</h4><p>An Ubuntu server with port range of 20–21 and 40000–50000.</p><h4><strong>Steps to Set Up FTP:</strong></h4><p><strong>Step 1: Update System Package Repository<br></strong>Keeping your system up to date ensures you get the latest security patches and software versions.<br>Open the terminal and run:</p><pre>sudo apt update</pre><p><strong>Step 2: Installing vsftpd<br></strong>vsftpd is a secure and fast FTP server software that will handle the FTP connections.<br>Install vsftpd by running:</p><pre>sudo apt install vsftpd -y</pre><p><strong>Step 3: Launch vsftpd<br></strong>Starting and enabling the vsftpd service ensures that the FTP server is running and will start automatically on boot.<br>Start the vsftpd service:</p><pre>sudo systemctl start vsftpd<br>sudo systemctl enable vsftpd</pre><p><strong>Check if vsftpd is running:</strong></p><pre>sudo systemctl status vsftpd</pre><p><strong>Step 4: Backup Configuration File<br></strong>Backing up the configuration file lets you restore the original settings if something goes wrong.<br>Create a new FTP user (replace ftpuser with your preferred username.</p><pre>sudo adduser ftpuser</pre><p><strong>Set a password when prompted:</strong></p><pre>sudo passwd ftpuser</pre><p><strong>Configure the firewall to allow FTP traffic:</strong></p><pre>sudo ufw allow 20/tcp<br>sudo ufw allow 21/tcp<br>sudo ufw allow 40000:50000/tcp<br>sudo ufw reload</pre><p><strong>Step 6: Change the Default Directory<br></strong>Changing the default directory sets a specific folder for FTP users, improving organization and security.<br>Edit the vsftpd configuration file:</p><pre>sudo nano /etc/vsftpd.conf</pre><p><strong>Set the desired directory:</strong></p><pre>local_root=/home/ftpuser/ftp</pre><p><strong>Create the new directory and set appropriate permissions:</strong></p><pre>sudo mkdir -p /home/ftpuser/ftp<br>sudo chown nobody:nogroup /home/ftpuser/ftp<br>sudo chmod a-w /home/ftpuser/ftp<br>sudo mkdir /home/ftpuser/ftp/upload<br>sudo chown ftpuser:ftpuser /home/ftpuser/ftp/upload</pre><p><strong>Step 7: Authenticate FTP Users<br></strong>Ensuring only authenticated users can access the FTP server improves security by preventing unauthorized access.<br>Edit the vsftpd configuration file:</p><pre>sudo nano /etc/vsftpd.conf</pre><p><strong>Ensure the following lines are uncommented:</strong></p><pre># Example config file /etc/vsftpd.conf<br>#<br># The default compiled in settings are fairly paranoid. This sample file<br># loosens things up a bit, to make the ftp daemon more usable.<br># Please see vsftpd.conf.5 for all compiled in defaults.<br>#<br># READ THIS: This example file is NOT an exhaustive list of vsftpd options.<br># Please read the vsftpd.conf.5 manual page to get a full idea of vsftpd&#39;s<br># capabilities.<br>#<br>#<br># Run standalone?  vsftpd can run either from an inetd or as a standalone<br># daemon started from an initscript.<br>listen=NO<br>#<br># This directive enables listening on IPv6 sockets. By default, listening<br># on the IPv6 &quot;any&quot; address (::) will accept connections from both IPv6<br># and IPv4 clients. It is not necessary to listen on *both* IPv4 and IPv6<br># sockets. If you want that (perhaps because you want to listen on specific<br># addresses) then you must run two copies of vsftpd with two configuration<br># files.<br>listen_ipv6=YES<br>#<br># Allow anonymous FTP? (Disabled by default).<br>anonymous_enable=NO<br>#<br># Uncomment this to allow local users to log in.<br>local_enable=YES<br>#<br># Uncomment this to enable any form of FTP write command.<br>write_enable=YES<br>#<br># Default umask for local users is 077. You may wish to change this to 022,<br># if your users expect that (022 is used by most other ftpd&#39;s)<br>#local_umask=022<br>#<br># Uncomment this to allow the anonymous FTP user to upload files. This only<br># has an effect if the above global write enable is activated. Also, you will<br># obviously need to create a directory writable by the FTP user.<br>#anon_upload_enable=YES<br>#<br># Uncomment this if you want the anonymous FTP user to be able to create<br># new directories.<br>#anon_mkdir_write_enable=YES<br>#<br># Activate directory messages - messages given to remote users when they<br># go into a certain directory.<br>dirmessage_enable=YES<br>#<br># If enabled, vsftpd will display directory listings with the time<br># in  your  local  time  zone.  The default is to display GMT. The<br># times returned by the MDTM FTP command are also affected by this<br># option.<br>use_localtime=YES<br>#<br># Activate logging of uploads/downloads.<br>xferlog_enable=YES<br>#<br># Make sure PORT transfer connections originate from port 20 (ftp-data).<br>connect_from_port_20=YES<br>#<br># If you want, you can arrange for uploaded anonymous files to be owned by<br># a different user. Note! Using &quot;root&quot; for uploaded files is not<br># recommended!<br>chown_uploads=YES<br>chown_username=&lt;your ftp user&gt;<br>#<br># You may override where the log file goes if you like. The default is shown<br># below.<br>#xferlog_file=/var/log/vsftpd.log<br>#<br># If you want, you can have your log file in standard ftpd xferlog format.<br># Note that the default log file location is /var/log/xferlog in this case.<br>#xferlog_std_format=YES<br>#<br># You may change the default value for timing out an idle session.<br>#idle_session_timeout=600<br>#<br># You may change the default value for timing out a data connection.<br>#data_connection_timeout=120<br>#<br># It is recommended that you define on your system a unique user which the<br># ftp server can use as a totally isolated and unprivileged user.<br>#nopriv_user=ftpsecure<br>#<br># Enable this and the server will recognise asynchronous ABOR requests. Not<br># recommended for security (the code is non-trivial). Not enabling it,<br># however, may confuse older FTP clients.<br>#async_abor_enable=YES<br>#<br># By default the server will pretend to allow ASCII mode but in fact ignore<br># the request. Turn on the below options to have the server actually do ASCII<br># mangling on files when in ASCII mode.<br># Beware that on some FTP servers, ASCII support allows a denial of service<br># attack (DoS) via the command &quot;SIZE /big/file&quot; in ASCII mode. vsftpd<br># predicted this attack and has always been safe, reporting the size of the<br># raw file.<br># ASCII mangling is a horrible feature of the protocol.<br>#ascii_upload_enable=YES<br>#ascii_download_enable=YES<br>#<br># You may fully customise the login banner string:<br>#ftpd_banner=Welcome to blah FTP service.<br>#<br># You may specify a file of disallowed anonymous e-mail addresses. Apparently<br># useful for combatting certain DoS attacks.<br>#deny_email_enable=YES<br># (default follows)<br>#banned_email_file=/etc/vsftpd.banned_emails<br>#<br># You may restrict local users to their home directories.  See the FAQ for<br># the possible risks in this before using chroot_local_user or<br># chroot_list_enable below.<br>#chroot_local_user=YES<br>#<br># You may specify an explicit list of local users to chroot() to their home<br># directory. If chroot_local_user is YES, then this list becomes a list of<br># users to NOT chroot().<br># (Warning! chroot&#39;ing can be very dangerous. If using chroot, make sure that<br># the user does not have write access to the top level directory within the<br># chroot)<br>chroot_local_user=NO<br>#chroot_list_enable=YES<br># (default follows)<br>chroot_list_file=/etc/vsftpd.chroot_list<br>#<br># You may activate the &quot;-R&quot; option to the builtin ls. This is disabled by<br># default to avoid remote users being able to cause excessive I/O on large<br># sites. However, some broken FTP clients such as &quot;ncftp&quot; and &quot;mirror&quot; assume<br># the presence of the &quot;-R&quot; option, so there is a strong case for enabling it.<br>#ls_recurse_enable=YES<br>#<br># Customization<br>#<br># Some of vsftpd&#39;s settings don&#39;t fit the filesystem layout by<br># default.<br>#<br># This option should be the name of a directory which is empty.  Also, the<br># directory should not be writable by the ftp user. This directory is used<br># as a secure chroot() jail at times vsftpd does not require filesystem<br># access.<br>secure_chroot_dir=/var/run/vsftpd/empty<br>#<br># This string is the name of the PAM service vsftpd will use.<br>pam_service_name=vsftpd<br>#<br># This option specifies the location of the RSA certificate to use for SSL<br># encrypted connections.<br>rsa_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem<br>rsa_private_key_file=/etc/ssl/private/ssl-cert-snakeoil.key<br>ssl_enable=NO<br>#<br># Uncomment this to indicate that vsftpd use a utf8 filesystem.<br>#utf8_filesystem=YES</pre><p><strong>Save and close the file. Restart vsftpd to apply the changes:</strong></p><pre>sudo systemctl restart vsftpd</pre><p><strong>Step 8: Encrypt Traffic with FTPS<br></strong>Encrypting traffic with FTPS secures the data transfer, protecting it from being intercepted.<br>Generate an SSL certificate (self-signed for simplicity):</p><pre>sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/vsftpd.pem -out /etc/ssl/private/vsftpd.pem</pre><p>Open the vsftpd.conf file in an editor and change the line <strong><em>ssl_enable=NO</em></strong> to <strong><em>ssl_enable=YES</em>.</strong><br>Next, add the following lines to the configuration file:</p><pre>rsa_cert_file=/etc/ssl/private/vsftpd.pem<br>rsa_private_key_file=/etc/ssl/private/vsftpd.pem<br>allow_anon_ssl=NO<br>force_local_data_ssl=YES<br>force_local_logins_ssl=YES<br>ssl_tlsv1=YES<br>ssl_sslv2=NO<br>ssl_sslv3=NO<br>require_ssl_reuse=NO<br>ssl_ciphers=HIGH<br>pasv_min_port=40000<br>pasv_max_port=50000</pre><p>Save the changes and exit the file.</p><p><strong>Restart the service to apply the changes:</strong></p><pre>sudo systemctl restart vsftpd.service</pre><p>Your FTP server is now set up and secured with FTPS. Users can connect to it using their FTP clients, ensuring they have the appropriate credentials and are using FTPS to encrypt the data transfer.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=28f49a840529" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Automated IP Update for Cloudflare DNS with Docker: A Step-by-Step Guide]]></title>
            <link>https://medium.com/@sonumishra19091999/automated-ip-update-for-cloudflare-dns-with-docker-a-step-by-step-guide-c812c7527a06?source=rss-3c6bf5ae723f------2</link>
            <guid isPermaLink="false">https://medium.com/p/c812c7527a06</guid>
            <dc:creator><![CDATA[Sonumishra]]></dc:creator>
            <pubDate>Wed, 13 Mar 2024 11:06:14 GMT</pubDate>
            <atom:updated>2024-03-19T09:16:46.022Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MLQSUXS7mhgHCXFsfOtJSQ.png" /></figure><p><strong>Description:</strong> Learn to effortlessly automate IP updates for Cloudflare DNS records using Docker. Follow our concise steps to create a seamless mechanism for updating your server’s IP address within Cloudflare’s domain settings. Keep your services connected without interruptions, even when your server’s IP changes.</p><h4>Prerequisites:</h4><p><strong>Cloudflare Account:</strong> Ensure you have an active Cloudflare account. If you don’t have one, sign up for free at <a href="https://www.cloudflare.com/">Cloudflare</a>.</p><p><strong>Domain Name:</strong> Have a registered domain name linked to your Cloudflare account. If you don’t have a domain, register one through Cloudflare or ensure your existing domain is configured on the Cloudflare platform.</p><h4>STEPS:</h4><p>STEP 1: Generate Cloudflare API Token<br>STEP 2: Create a Shell Script<br>STEP 3: Create a Dockerfile<br>STEP 4: Create a Docker Compose File<br>STEP 5: Set Up a Cron Job</p><h4>STEP 1: Generate Cloudflare API Token</h4><p>To automate IP updates with Docker, you’ll need a Cloudflare API token. Follow these steps to generate one:</p><p>— Log in to your Cloudflare account.<br> — Navigate to the “My Profile” section.<br>— Scroll down to the “API Tokens” section and click on “Create Token.”<br> — Choose the “Edit Zone DNS” template.<br> — Provide a name for your token and set the following permissions:<br>. Zone: DNS — Edit<br>. Zone: Zone — Read<br>— Under “Zone Resources,” select the domain(s) you want to manage with this token.<br>— Click on the “Continue to Summary” button, review your selections, and click “Create Token.”<br>— Once created, copy the generated API token.</p><p>You now have the required Cloudflare API token for automated IP updates using Docker. Store this token securely, as it will be used in the subsequent steps.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wWzE-5gbjGAajSRCydqS6Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cZRi8rGS79EK6OPGltXo6w.png" /></figure><p><strong>NOTE:</strong> Your Cloudflare API token is a critical credential with specific permissions for managing DNS records and reading zone information. Its security is paramount for the overall integrity of your Cloudflare-managed services</p><h4>STEP 2: Create a Shell Script</h4><p>In this step, you’ll craft a shell script that automatically updates the IP address of your server within Cloudflare’s DNS settings</p><pre>#!/bin/bash<br><br>apiToken=&quot;your_API_Token&quot;<br>domainName=&quot;your_domain.com&quot;<br><br># Get the current server IP address<br>currentIP=$(curl -s ifconfig.me)<br><br># Find the Zone ID based on the domain name<br>zoneID=$(curl -s -X GET &quot;https://api.cloudflare.com/client/v4/zones?name=$domainName&quot; \<br>                       -H &quot;Authorization: Bearer $apiToken&quot; \<br>                       -H &quot;Content-Type: application/json&quot; | jq -r &#39;.result[0].id&#39;)<br><br>if [[ &quot;$zoneID&quot; == &quot;null&quot; || -z &quot;$zoneID&quot; ]]; then<br>  echo &quot;Failed to retrieve Zone ID for the domain $domainName.&quot;<br>  exit 1<br>fi<br><br># Find the DNS Record ID based on the DNS record name and Zone ID<br>dnsRecordID=$(curl -s -X GET &quot;https://api.cloudflare.com/client/v4/zones/$zoneID/dns_records?type=A&amp;name=$domainName&quot; \<br>                             -H &quot;Authorization: Bearer $apiToken&quot; \<br>                             -H &quot;Content-Type: application/json&quot; | jq -r &#39;.result[0].id&#39;)<br><br>if [[ &quot;$dnsRecordID&quot; == &quot;null&quot; || -z &quot;$dnsRecordID&quot; ]]; then<br>  echo &quot;Failed to retrieve DNS Record ID for the domain $domainName.&quot;<br>  exit 1<br>fi<br><br># Update DNS record with the new IP address<br>apiResponse=$(curl -s -X PUT &quot;https://api.cloudflare.com/client/v4/zones/$zoneID/dns_records/$dnsRecordID&quot; \<br>                       -H &quot;Authorization: Bearer $apiToken&quot; \<br>                       -H &quot;Content-Type: application/json&quot; \<br>                       --data &#39;{&quot;type&quot;:&quot;A&quot;,&quot;name&quot;:&quot;&#39;&quot;$domainName&quot;&#39;&quot;,&quot;content&quot;:&quot;&#39;&quot;$currentIP&quot;&#39;&quot;,&quot;ttl&quot;:1,&quot;proxied&quot;:false}&#39;)<br><br>if [[ $(echo &quot;$apiResponse&quot; | jq -r .success) != &quot;true&quot; ]]; then<br>  echo &quot;DNS Record Update Failed. API Response: $apiResponse&quot;<br>  exit 1<br>else<br>  echo &quot;DNS Record Updated Successfully. New IP: $currentIP&quot;<br>fi</pre><p><strong><em>The above Shell Script file is explained below,</em></strong></p><ul><li><strong>API Token and Domain Name:</strong> apiToken: This variable holds your Cloudflare API token, allowing the script to make authenticated requests to the Cloudflare API.</li></ul><pre>apiToken=&quot;your_API_Token&quot;<br>domainName=&quot;your_domain.com&quot;</pre><ul><li><strong>Get Current Server IP:</strong> domainName: Replace &quot;your_domain.com&quot; with the actual domain for which you want to update the IP address.</li></ul><pre>currentIP=$(curl -s ifconfig.me)</pre><ul><li><strong>Find Zone ID:</strong> Uses curl to fetch the current public IP address of the server from ifconfig.me.</li></ul><pre>zoneID=$(curl -s -X GET &quot;https://api.cloudflare.com/client/v4/zones?name=$domainName&quot; \<br>                       -H &quot;Authorization: Bearer $apiToken&quot; \<br>                       -H &quot;Content-Type: application/json&quot; | jq -r &#39;.result[0].id&#39;)</pre><ul><li><strong>Find DNS Record ID:</strong> Fetches the DNS Record ID for the specified domain and Zone ID from the Cloudflare API.</li></ul><pre>dnsRecordID=$(curl -s -X GET &quot;https://api.cloudflare.com/client/v4/zones/$zoneID/dns_records?type=A&amp;name=$domainName&quot; \<br>                             -H &quot;Authorization: Bearer $apiToken&quot; \<br>                             -H &quot;Content-Type: application/json&quot; | jq -r &#39;.result[0].id&#39;)</pre><ul><li><strong>Update DNS Record: </strong>Sends a PUT request to update the DNS record with the new IP address.</li></ul><pre>apiResponse=$(curl -s -X PUT &quot;https://api.cloudflare.com/client/v4/zones/$zoneID/dns_records/$dnsRecordID&quot; \<br>                             -H &quot;Authorization: Bearer $apiToken&quot; \<br>                             -H &quot;Content-Type: application/json&quot; \<br>                             --data &#39;{&quot;type&quot;:&quot;A&quot;,&quot;name&quot;:&quot;&#39;&quot;$domainName&quot;&#39;&quot;,&quot;content&quot;:&quot;&#39;&quot;$currentIP&quot;&#39;&quot;,&quot;ttl&quot;:1,&quot;proxied&quot;:false}&#39;)</pre><ul><li><strong>Check API Response: </strong>Verifies if the DNS record update was successful based on the response from the Cloudflare API.</li></ul><pre>if [[ $(echo &quot;$apiResponse&quot; | jq -r .success) != &quot;true&quot; ]]; then<br>  echo &quot;DNS Record Update Failed. API Response: $apiResponse&quot;<br>  exit 1<br>else<br>  echo &quot;DNS Record Updated Successfully. New IP: $currentIP&quot;<br>fi</pre><p><strong><em>Now, grant execution permission to your shell script using the following command:</em></strong></p><pre>chmod +x your_script_file.sh</pre><h4>STEP 3: Create a Dockerfile</h4><p>In this step, you’ll create a Dockerfile to build the Docker image that will run the IP update script. Paste the following Dockerfile content:</p><pre>FROM ubuntu:latest<br><br>RUN apt-get update &amp;&amp; \<br>    apt-get install -y \<br>    curl \<br>    jq &amp;&amp; \<br>    rm -rf /var/lib/apt/lists/*<br><br>COPY check.bash /usr/src/app/check.bash<br><br># Set the working directory<br>WORKDIR /usr/src/app<br><br># Make the script executable<br>RUN chmod +x your_script_file.sh<br><br># Execute the script when the container starts<br>CMD [&quot;./your_script_file.bash&quot;]</pre><p>This Dockerfile sets up a Docker image based on the latest version of Ubuntu and installs necessary packages for executing a shell script. Let’s break down each section:</p><ol><li><strong>FROM ubuntu:latest:</strong> Specifies the base image for the Dockerfile. In this case, it uses the latest version of Ubuntu available from Docker Hub.</li><li><strong>RUN apt-get update &amp;&amp; \ …: </strong>Runs commands to update the package list and install required packages (curl and jq). It then removes the package lists to minimize the image size.</li><li><strong>COPY check.bash /usr/src/app/your_script_file.bash: </strong>Copies the your_script_file.bash script from the local directory to the /usr/src/app/ directory inside the Docker image.</li><li><strong>WORKDIR /usr/src/app:</strong> Sets the working directory inside the Docker image to /usr/src/app, which is where the script is copied.</li><li><strong>RUN chmod +x your_script_file.bash: </strong>Changes the permissions of the your_script_file.bash script to make it executable.</li><li><strong>CMD [“./your_script_file.bash”]:</strong> Specifies the default command to run when the container starts. In this case, it runs the your_script_file.bash script located in the working directory.</li></ol><p>Overall, this Dockerfile sets up an environment with the necessary tools and configurations to execute the your_script_file.bash script inside a Docker container.</p><h4>STEP 4: Create a Docker Compose File</h4><p>To create a Docker Compose file (usually named docker-compose.yml), you define the services for your Docker application. Here&#39;s a simple example for your use case:</p><pre>version: &#39;3&#39;<br>services:<br> update-ip:<br>   build: .</pre><p>Let’s break down the contents:</p><ul><li>version: &#39;3&#39;: Specifies the Docker Compose file version. In this case, it&#39;s version 3.</li><li>services: Defines the services in your Docker application.</li><li>update-ip: A service named update-ip. You can change this to match your application&#39;s name.</li><li>build: .: Specifies the build configuration for the service. The dot (.) indicates that the build context is the current directory where the Docker Compose file is located. This assumes your Dockerfile is in the same directory.</li></ul><h4>STEP 5: Set Up a Cron Job</h4><p>Before setting up the cron job, let’s create a shell script that will manage the lifecycle of your Docker Compose services. This script starts the services, waits for a specified duration, and then stops and removes them.</p><p>Create a new file named manage_services.sh with the following content:</p><pre>#!/bin/bash<br><br># Start the Docker Compose services in detached mode<br>docker-compose up --build -d<br><br># Sleep for one minute<br>sleep 60<br><br># Stop and remove the Docker Compose services<br>docker-compose down</pre><p>Save the script, and ensure it is executable:</p><pre>chmod +x manage_services.sh</pre><p>This script encapsulates the necessary steps to control the lifecycle of your services. Now, we’ll use this script in the next step to set up a cron job for automated execution.</p><p><strong><em>Now set the cronjob for the this “manage_services.sh” script so that after every 30 mins it run the compose file and will give the updated IP of the server</em></strong></p><p>Open the crontab editor using the following command:</p><pre>crontab -e</pre><p>Add the following line to schedule the manage_services.sh command every 30 minutes:</p><pre>*/30 * * * * cd /path/to/your/manage_services.sh &amp;&amp; ./manage_services.sh</pre><p>The cron job is now scheduled to run your Docker Compose command every 30 minutes. Adjust the interval or other parameters as needed for your specific requirements.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c812c7527a06" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dockerizing simple Node with Nginx]]></title>
            <link>https://medium.com/@sonumishra19091999/dockerizing-simple-node-with-nginx-82870c8ae3e5?source=rss-3c6bf5ae723f------2</link>
            <guid isPermaLink="false">https://medium.com/p/82870c8ae3e5</guid>
            <dc:creator><![CDATA[Sonumishra]]></dc:creator>
            <pubDate>Sat, 09 Mar 2024 11:11:00 GMT</pubDate>
            <atom:updated>2024-03-09T11:11:00.153Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*weRUSV-0y9lT5OzpXgcPog.png" /></figure><p>In this blog post, we will delve into the process of Dockerizing a simple Node.js application with Nginx, streamlining the deployment workflow. Docker containers encapsulate the Node.js app and Nginx web server, ensuring consistency across various environments. Following the steps to create a Dockerfile, build the image, and integrate Nginx, we’ll explore Docker Compose for a convenient multi-container setup. By the end, you’ll grasp the power of containerization and its efficiency in deploying Node.js applications with Nginx.</p><p>For a foundational understanding, refer to the previous blog on Deploying a Node.js App on Ubuntu with Nginx. Here’s the link <a href="https://medium.com/@sonumishra19091999/deploying-a-node-js-app-on-ubuntu-with-nginx-8b6999c37775">https://medium.com/@sonumishra19091999/deploying-a-node-js-app-on-ubuntu-with-nginx-8b6999c37775</a></p><h3>Prerequisites:</h3><p>Ensure your Ubuntu server is set up with the following components:</p><p><strong>Docker: </strong>Docker installed on your Ubuntu server<br><strong>Docker Compose:</strong> Docker Compose installed for managing multi-container applications.</p><h4>STEPS</h4><p>STEP 1: Create a Project-structure<br>STEP 2: Create a Dockerfile for NodeJS<br>STEP 3: Create a config file for Nginx<br>STEP 4: Create an env file<br>STEP 5: Create a Docker-Compose file</p><p><strong>STEP 1: Create a Project-structure</strong></p><p>A structured project layout is crucial for code organization and project scalability. It enhances maintainability, readability, and collaboration among team members. In the context of Docker and Nginx, a clear structure streamlines containerization and deployment processes.</p><p>Create the following structure,<br>Nodejs-project/<br>├── Dockerfile<br>├── docker-compose.yml<br>├── env<br>├── index.js<br>├── nginx<br>│ └── default.conf<br>└── package.json</p><p><strong>Dockerfile:</strong> Docker configuration for the Node.js app.<br><strong>docker-compose.yml:</strong> Docker Compose configuration to manage containers.<br><strong>env:</strong> Directory to store environment variables or configuration files.<br><strong>index.js:</strong> Main file for your Node.js application.<br><strong>nginx/:</strong> Directory for Nginx configurations.<br><strong>default.conf:</strong> Nginx configuration file.<br><strong>package.json:</strong> Node.js dependencies and scripts.</p><p><strong>STEP 2: Create a Dockerfile for NodeJS</strong></p><p>Creating a Dockerfile is crucial for containerizing your Node.js application. The Dockerfile defines the environment for your Node.js app, ensuring consistency and portability. It encapsulates dependencies and setup steps, enabling easy deployment and scalability in diverse environments.<br>Create a following dockerfile :</p><pre>FROM node:14-alpine<br><br>WORKDIR /usr/src/app<br><br>COPY package*.json /usr/src/app<br><br>RUN npm install<br><br>COPY . /usr/src/app<br><br>CMD npm start</pre><p>FROM node:14-alpine: Specifies the base image as Node.js 14 on Alpine Linux. Alpine Linux provides a lightweight base for your image.</p><p>WORKDIR /usr/src/app: Sets the working directory within the container to /usr/src/app. Subsequent commands will be executed in this directory.</p><p>COPY package*.json /usr/src/app: Copies package.json and package-lock.json (if present) into the container&#39;s working directory.</p><p>RUN npm install: Installs Node.js dependencies based on the copied package files. This step ensures your application has all the required packages.</p><p>COPY . /usr/src/app: Copies the entire application code into the container&#39;s working directory. This includes your application files, such as index.js.</p><p>CMD npm start: Defines the default command to run when the container starts. In this case, it&#39;s set to execute npm start, which typically starts your Node.js application.</p><p>Define your project’s metadata and dependencies in <strong><em>package.json</em></strong> for Node.js.</p><pre>{<br>  &quot;name&quot;: &quot;node-nginx&quot;,<br>  &quot;version&quot;: &quot;0.0.1&quot;,<br>  &quot;description&quot;: &quot;node with nginx on docker for beginner&quot;,<br>  &quot;main&quot;: &quot;index.js&quot;,<br>  &quot;scripts&quot;: {<br>    &quot;start&quot;: &quot;node index.js&quot;<br>  },<br>  &quot;keywords&quot;: [&quot;node&quot;,&quot;nginx&quot;,&quot;docker&quot;,&quot;ingress&quot;],<br>  &quot;author&quot;: &quot;restuwahyu13&quot;,<br>  &quot;license&quot;: &quot;MIT&quot;<br>}</pre><p>Develop a sample <strong><em>index.js</em></strong> file serving as your Node.js app’s entry point. It encompasses essential logic for routes, HTTP request handling, and module interactions. Customize it based on your app’s specific requirements, ensuring it aligns with your project’s architecture and functionality.</p><pre>const http = require(&#39;http&#39;)<br>const server = http.createServer((req, res) =&gt; {<br>        res.writeHead(200, { &#39;content-type&#39;: &#39;text/html&#39; })<br><br>        if (req.url === &#39;/&#39;) {<br>                res.write(&#39;&lt;h1&gt;Node and Nginx on Docker is Working&lt;/h1&gt;&#39;)<br>                res.end()<br>        } else {<br>                res.write(&#39;&lt;h1&gt;404 Nout Found&lt;/h1&gt;&#39;)<br>                res.end()<br>        }<br>})<br><br>server.listen(process.env.PORT || 3000, () =&gt; console.log(`server running on ${server.address().port}`))<br><br></pre><p><strong>STEP 3: Create a config file for Nginx</strong></p><p>Inside the “<strong><em>nginx</em></strong>” folder, establish a “<strong><em>default.conf</em></strong>” file. This configuration file is crucial for Nginx to define how it should handle incoming requests and interact with your Node.js application. Customize the configurations based on your project’s needs and structure.</p><pre>server {<br>  listen 80;<br>  listen [::]:80;<br>  server_name webapp-node.io;<br><br>  location / {<br>    proxy_pass http://webapp:3000;<br>    proxy_http_version 1.1;<br>    proxy_set_header Upgrade $http_upgrade;<br>    proxy_set_header Connection &#39;upgrade&#39;;<br>    proxy_set_header Host $host;<br>    proxy_cache_bypass $http_upgrade;<br>  }<br>}</pre><p><strong>STEP 4: Create an env file</strong></p><p>Create an “env” file in the project root with the following content:</p><pre>WEBAPP_PORT=3000<br>NGINX_PORT=80</pre><p>This file will define environment variables for your Node.js application and Nginx configuration. Adjust the values as needed for your specific setup and requirements.</p><p><strong>STEP 5: Create a Docker-Compose file</strong></p><p>Create a “docker-compose.yml” file in the project root with the following content. This file defines the services, networks, and volumes needed for your Dockerized Node.js and Nginx setup.</p><pre>version: &#39;3.8&#39;<br>services:<br>  webapp:<br>    restart: unless-stopped<br>    build: .<br>    volumes:<br>      - ./:/usr/src/app<br>      - /usr/src/app/node_modules<br>    networks:<br>      - node_network<br><br>  proxy:<br>    restart: unless-stopped<br>    image: nginx<br>    ports:<br>      - 80:80<br>    depends_on:<br>      - webapp<br>    volumes:<br>      - ./nginx/default.conf:/etc/nginx/conf.d/default.conf<br>    networks:<br>      - node_network<br><br>networks:<br>  node_network:<br><br></pre><p><strong>webapp Service:</strong></p><p><em>restart:</em> Specifies the restart policy for the service.</p><p><em>build:</em> Specifies the build context for the service, using the current directory.</p><p><em>volumes:</em> Mounts project files and the “node_modules” directory to the container to handle dependencies.</p><p><em>networks:</em> Connects the service to the custom “node_network.”</p><p><strong>proxy Service:</strong></p><p><em>restart:</em> Specifies the restart policy for the service.</p><p><em>image: </em>Uses the official Nginx image from Docker Hub.</p><p><em>ports: </em>Maps port 80 from the host to port 80 on the container.</p><p><em>depends_on</em>: Ensures that the “webapp” service is started before the “proxy” service.</p><p><em>volumes:</em> Mounts the Nginx configuration file from the host to the container.</p><p><em>networks:</em> Connects the service to the custom “node_network.”</p><p><em>networks:node_network:</em> Defines a custom bridge network named “node_network” that both services connect to. This allows them to communicate with each other using service names as hostnames.</p><p>This configuration enables communication between the Node.js application in the “webapp” service and Nginx in the “proxy” service, providing a scalable and modular environment for your Dockerized web application.</p><p><em>To access your deployed web application, take the provided IP address and enter it into your web browser’s address bar. For instance, if the IP address is </em><em>172.31.84.207, type </em><em>172.31.84.207 in your browser. Hit Enter, and you should see your Node.js app running via Nginx on Docker.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=82870c8ae3e5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploying a Node.js App on Ubuntu with Nginx]]></title>
            <link>https://medium.com/@sonumishra19091999/deploying-a-node-js-app-on-ubuntu-with-nginx-8b6999c37775?source=rss-3c6bf5ae723f------2</link>
            <guid isPermaLink="false">https://medium.com/p/8b6999c37775</guid>
            <dc:creator><![CDATA[Sonumishra]]></dc:creator>
            <pubDate>Fri, 08 Mar 2024 12:18:08 GMT</pubDate>
            <atom:updated>2024-03-08T12:18:08.997Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FFBEGAc0RrUPcvDPK6bz3Q.png" /></figure><p>Welcome to our step-by-step guide on deploying a Node.js application on an Ubuntu server with Nginx! If you’re eager to learn how to take your Node.js project live and enhance its performance with the power of Nginx, you’re in the right place.</p><p>In this guide, we’ll guide you from setting up a new Ubuntu server to configuring Nginx as a reverse proxy for your Node.js app. Whether you’re a beginner launching your first Node.js project or an experienced developer needing a solid web server solution, this guide has something for all skill levels.</p><h4><strong>Prerequisite:</strong> Ubuntu Server Setup</h4><h4>STEPS</h4><p>STEP 1: Getting NodeJS Up and Running( Installation and Setup )<br>STEP 2: Crafting a Basic Node &amp; Express App<br>STEP 3: Configuring Nginx as a Proxy (Seamless Server Management)</p><h4><strong>STEP 1: Getting NodeJS Up and Running( Installation and Setup )</strong></h4><p>As NodeJS is open-source, it’s freely available for various platforms. To install NodeJS on Ubuntu, follow these steps:</p><p>Ensure your system is up to date with the latest updates:</p><pre>sudo apt update</pre><p>This ensures you have the most recent packages before installing NodeJS.</p><p>Now, let’s proceed with the installation of Node.js:</p><pre>sudo apt install nodejs -y</pre><p>This command installs Node.js on your Ubuntu system. After the installation, you can check the version to ensure everything went smoothly:</p><p>To verify if Node.js is successfully installed and check its version, use the following commands:</p><pre>node -v</pre><p>Now, install Node Package Manager (npm) using:</p><pre>sudo apt install npm</pre><p>npm is crucial for managing Node.js packages and dependencies, simplifying the installation and updating process. It enhances project development by providing easy access to a vast ecosystem of libraries and tools.</p><h4>STEP 2: Crafting a Basic Node &amp; Express App</h4><p>Build a simple Node.js and Express application to understand the core concepts. This step is essential as it lays the foundation for more complex projects, teaching fundamental server-side scripting and routing skills crucial for robust web development.</p><p>The code below sets up a Node.js and Express app to display “Hello World” on your webpage. It’s a simple introduction to creating a server and handling HTTP requests, serving as a foundation for more advanced web development.</p><p>Initialize your Node.js application using:</p><pre>cd ~<br>mkdir mynodeapp &amp;&amp; cd mynodeapp<br>npm init -y</pre><p>These commands navigate to your home directory, create a new directory called “mynodeapp”, move into that directory, and then initialize a new Node.js application using the default settings provided by the -y flag. This creates a package.json file, which is essential for managing your project&#39;s dependencies and configurations.</p><p>Install Express, a popular Node.js web application framework, using the following command:</p><pre>npm install express</pre><p>This installs the Express framework, enabling you to simplify and streamline the process of building robust and scalable web applications with Node.js.</p><p>Certainly! Here are the steps to create and edit the app.js file using the nano editor:</p><pre>nano app.js</pre><p>Copy and paste the following code into the nano editor:</p><pre>const express = require(&quot;express&quot;); <br>const app = express(); // Initializing Express App<br><br>// Sending Hello World when anyone browse your webpage<br><br>app.get(&quot;/*&quot;, (req, res)=&gt;{<br>        res.send(&#39;Hello World&#39;); <br>});<br><br>app.listen(3000, ()=&gt; console.log(&quot;App Listening on port 3000&quot;));</pre><p>Save the changes to your app.js file.<br>In the terminal, run the following command to start your Node.js application:</p><pre>node app.js</pre><p>The message “App Listening on port 3000” indicates that your Node.js application is running and accepting connections on port 3000. To stop the application, you can press Ctrl + C in the terminal, and it will gracefully shut down the server.</p><p>Certainly! Using pm2 is an excellent solution to run Node.js/Express.js applications without blocking resources and allowing them to run in the background. It also provides features like process management, monitoring, and automatic restarts.</p><p>To install pm2, run the following command:</p><pre>sudo npm install -g pm2</pre><p>This command installs pm2 globally on your system, allowing you to manage Node.js processes easily. The use of sudo ensures the installation process has the necessary permissions.</p><p>Start the above application using pm2:</p><pre>pm2 start app.js</pre><p>Verify whether your application is running using the following command:</p><pre>pm2 status</pre><p>To halt your application, use:</p><pre>pm2 stop &lt;application_name/ID&gt;</pre><p>For us, the application name is app.js or the ID, as displayed in the output of pm2 status, such as 0.</p><p>To restart your application:</p><pre>pm2 restart &lt;application_name/ID&gt;</pre><p>Ensure your application runs successfully locally by testing with CURL:</p><pre>curl localhost:3000</pre><h4>STEP 3: Configuring Nginx as a Proxy (Seamless Server Management)</h4><p>In this step, we’ll configure Nginx as a proxy to seamlessly manage incoming requests and distribute them to your Node.js application. This enhances security, load balancing, and overall performance, providing a robust foundation for your web server setup.</p><p>To swiftly install Nginx from the default repositories on Ubuntu, use:</p><pre>sudo apt install nginx -y</pre><p>To configure Nginx as a reverse proxy and set up the necessary settings, open the default Nginx configuration file using the following command:</p><pre>sudo nano /etc/nginx/sites-available/default</pre><p>This will open the file in the nano text editor. You can then proceed to make the required changes to set up the reverse proxy to localhost:3000 for your Node.js application.</p><p>Certainly! In the default Nginx configuration file, replace the existing content of the location / block with the provided code:</p><pre>location / {<br>    proxy_pass http://localhost:3000;<br>    proxy_http_version 1.1;<br>    proxy_set_header Upgrade $http_upgrade;<br>    proxy_set_header Connection &#39;upgrade&#39;;<br>    proxy_set_header Host $host;<br>    proxy_cache_bypass $http_upgrade;<br>}</pre><p>This configuration sets up Nginx as a reverse proxy, directing traffic to your Node.js application running on localhost:3000. Save the changes and exit the editor.</p><p>To start Nginx and apply the changes you made to the configuration, use the following command:</p><pre>sudo systemctl restart nginx</pre><p>This restarts the Nginx service, incorporating the updated configuration with the reverse proxy settings for your Node.js application.</p><p>🎉 Congratulations! 🎉 Your application is now successfully hosted and running. You can access it by navigating to your server’s IP address or domain name in a web browser. If you encounter any issues or have further questions, feel free to ask. Happy coding! 🚀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8b6999c37775" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dockerizing CodeIgniter: Streamlining Deployment with Containers]]></title>
            <link>https://medium.com/@sonumishra19091999/dockerizing-codeigniter-streamlining-deployment-with-containers-d186c47c7a34?source=rss-3c6bf5ae723f------2</link>
            <guid isPermaLink="false">https://medium.com/p/d186c47c7a34</guid>
            <dc:creator><![CDATA[Sonumishra]]></dc:creator>
            <pubDate>Wed, 06 Mar 2024 13:30:13 GMT</pubDate>
            <atom:updated>2024-03-08T12:24:28.994Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/820/1*yv0UeJdij0kDxwbDsz9rgQ.jpeg" /></figure><p>In the fast-changing world of web development, Docker stands out as a handy tool for making it easier to put your apps online and handle the software pieces they rely on. This blog will walk you through turning your CodeIgniter app into a Docker setup, building on what we learned about running CodeIgniter on an Ubuntu server before.</p><p>Here’s the link if you want host Codeigniter on your ubuntu server:<br><a href="https://medium.com/@sonumishra19091999/guide-to-hosting-codeigniter-on-ubuntu-server-f666b7f2f9f8">https://medium.com/@sonumishra19091999/guide-to-hosting-codeigniter-on-ubuntu-server-f666b7f2f9f8</a></p><h4>Certainly! Let’s proceed with the blog!!</h4><h3>Prerequisites</h3><p>-Ensure Docker is installed on your system.<br>-Confirm Docker Compose is available.</p><h3>STEPS</h3><p>Step 1: Project Structure<br>Step 2: Create Dockerfile for PHP and Apache<br>Step 3: Create a configuiration file for Codeigniter<br>Step 4: Create Dockerfile for MySQL<br>Step 5: Configure Docker Compose</p><h4>Step 1: Project Structure</h4><p>codeigniter-project/<br> ├── database<br> ├── docker-compose.yml<br> └── dockerfiles<br> ├── mysql<br> │ └── Dockerfile<br> └── php-apache<br> ├── Dockerfile<br> └── codeigniter.conf</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jA3bWa4XOrJo-IE00JYXmg.png" /></figure><h4>database:</h4><p>The database directory is like a storage room for anything your CodeIgniter app needs for databases. When MySQL starts, it connects to this room, making sure all the important database stuff is neatly organized and separate from the rest of the project.</p><h4>docker-compose.yml:</h4><p>The docker-compose.yml file orchestrates the Docker containers for your CodeIgniter project. It defines the services, and volumes required to run your application seamlessly.</p><h4>dockerfiles:</h4><p>The dockerfiles directory contains Dockerfiles, which are instructions for building Docker images. It&#39;s divided into subdirectories for MySQL and PHP-Apache services.</p><h4>mysql:</h4><p>This subdirectory holds the Dockerfile responsible for creating a MySQL container image. It includes configurations specific to running a MySQL database for your CodeIgniter application.</p><h4>php-apache:</h4><p>In this subdirectory, you’ll find both a Dockerfile and a codeigniter.conf file. The Dockerfile is crucial for building an image with PHP and Apache, while the codeigniter.conf file configures Apache specifically for CodeIgniter.</p><p><strong><em>This well-organized structure ensures clarity in managing different aspects of your CodeIgniter project, from databases to web servers.</em></strong></p><h4>Step 2: Create Dockerfile for PHP and Apache</h4><p>Now Let’s create a dockerfile inside the <em>php-apache</em> folder. <br>This Dockerfile orchestrates the setup of a PHP and Apache environment, installs dependencies, sets up Composer, creates a CodeIgniter 4 project, configures Apache to serve it, and exposes port 80 for access.</p><pre>FROM php:8.1.0-apache<br><br>RUN apt-get update \<br>    &amp;&amp; apt-get install -y nano zip unzip git libicu-dev \<br>    &amp;&amp; docker-php-ext-configure intl \<br>    &amp;&amp; docker-php-ext-install intl \<br>    &amp;&amp; apt-get clean \<br>    &amp;&amp; rm -rf /var/lib/apt/lists/*<br><br>RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer<br><br>WORKDIR /var/www/html<br><br>RUN composer create-project codeigniter4/appstarter app --prefer-dist --stability=stable --no-progress --no-interaction<br><br>RUN chown -R www-data:www-data /var/www/html \<br>    &amp;&amp; composer self-update<br><br>COPY codeigniter.conf /etc/apache2/sites-available/<br>RUN a2ensite codeigniter.conf \<br>    &amp;&amp; service apache2 reload || true<br><br>RUN cd /etc/apache2/sites-available \<br>    &amp;&amp; a2dissite 000-default.conf \<br>    &amp;&amp; service apache2 reload || true<br><br>EXPOSE 80</pre><p><strong>Base Image:</strong><br>FROM php:8.1.0-apache: Uses the official PHP 8.1.0 Apache image as a starting point.</p><p><strong>Dependency Installation:</strong><br>Installs essential dependencies like nano, zip, unzip, git, and libicu-dev.</p><p><strong>Composer Setup:<br></strong>Installs Composer, a PHP dependency manager, allowing easy management of CodeIgniter dependencies.</p><p><strong>Working Directory:</strong><br>WORKDIR /var/www/html: Sets the working directory for subsequent commands.</p><p><strong>CodeIgniter Project Creation:</strong><br>Creates a new CodeIgniter 4 project named ‘app’ using the appstarter template.</p><p><strong>Ownership and Composer Update:</strong><br>Sets ownership of the project directory to the Apache user (www-data) and updates Composer.</p><p><strong>Apache Configuration:<br></strong>Copies the codeigniter.conf file to configure Apache for CodeIgniter.<br>Enables the CodeIgniter configuration and reloads the Apache service.</p><p><strong>Disable Default Apache Configuration:</strong><br>Disables the default Apache site configuration for a clean setup.</p><p><strong>Expose Port:</strong><br>EXPOSE 80: Informs Docker that the container will listen on port 80 at runtime.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PhXm0hACtJG_T6frx1u6lA.png" /></figure><h4>Step 3: Create a configuiration file for Codeigniter</h4><p>To ensure seamless communication between our CodeIgniter application and the Apache web server, we need a tailored Apache configuration. Let’s create the codeigniter.conf file:</p><pre>&lt;VirtualHost *:80&gt;<br>ServerName @localhost<br>DocumentRoot /var/www/html/app/public<br><br>&lt;Directory /var/www/html/app&gt;<br>AllowOverride All<br>&lt;/Directory&gt;<br><br>ErrorLog ${APACHE_LOG_DIR}/error.log<br>CustomLog ${APACHE_LOG_DIR}/access.log combined<br><br>&lt;/VirtualHost&gt;<br><br></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hPzAkQwZs16ESLr9TNnuBg.png" /></figure><h4>Step 4: Create Dockerfile for MySQL</h4><p>Before diving into the MySQL Dockerfile, let’s understand why we need it. In our CodeIgniter application, MySQL is the chosen database management system. By creating a MySQL Dockerfile, we ensure that our database environment is well-configured, isolated, and ready to seamlessly connect with our CodeIgniter app.</p><p>Now let’s create dockerfile in the <em>mysql</em> folder</p><pre>FROM mysql:latest<br><br>ENV MYSQL_ROOT_PASSWORD=root<br>ENV MYSQL_DATABASE=mydb<br>ENV MYSQL_USER=sonu<br>ENV MYSQL_PASSWORD=Mishraji@123<br><br>EXPOSE 3306</pre><p><strong>Base Image:</strong><br>FROM mysql:latest: Utilizes the latest MySQL image available from the official Docker repository as a starting point.</p><p><strong>Environment Variables:<br></strong>ENV MYSQL_ROOT_PASSWORD=root: Sets the root password for MySQL to &#39;root&#39;.<br>ENV MYSQL_DATABASE=mydb: Specifies the name of the MySQL database as &#39;mydb&#39;.<br>ENV MYSQL_USER=sonu: Defines a MySQL user named &#39;sonu&#39;.<br>ENV MYSQL_PASSWORD=Mishraji@123: Sets the password for the &#39;sonu&#39; MySQL user to &#39;Mishraji@123&#39;.</p><p><strong>Expose Port:<br></strong>EXPOSE 3306: Informs Docker that the container will listen on port 3306 for MySQL connections.</p><p>This Dockerfile ensures a consistent and reproducible MySQL environment for your CodeIgniter application, providing the necessary database infrastructure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5FAbJZOX9TjM_c1vuIFTjg.png" /></figure><h4>Step 5: Configure Docker Compose</h4><p>Docker Compose simplifies the orchestration of multiple containers, making it easy to manage our CodeIgniter application and its dependencies. Let’s create the docker-compose.yml file:</p><pre>version: &quot;3&quot;<br>services:<br> web:<br>   build: dockerfiles/php-apache<br>   ports:<br>    - &quot;80:80&quot;<br><br> db:<br>  build: dockerfiles/mysql<br>  ports:<br>   - &quot;3306:3306&quot;<br>  volumes:<br>   - /home/ubuntu/codeigniter-project/mydatabase/:/var/lib/mysql</pre><p><strong>version: &quot;3&quot;:<br></strong>Specifies the Docker Compose file version.</p><p><strong>services:</strong><br>Defines the services (containers) that compose the application.<br><strong>web:</strong> (PHP and Apache service):<br><strong>build: dockerfiles/php-apache:<br></strong>Specifies the build context for the PHP and Apache service using the dockerfiles/php-apache<strong> </strong>directory.</p><p><strong>ports: - &quot;80:80&quot;:</strong><br>Maps port 80 of the host to port 80 of the container for the web service.</p><p><strong>db: (MySQL service):<br></strong><strong>build: dockerfiles/mysql:<br></strong>Specifies the build context for the MySQL service using the dockerfiles/mysql directory.</p><p><strong>ports: - &quot;3306:3306&quot;:</strong><br>Maps port 3306 of the host to port 3306 of the container for the MySQL service.</p><p><strong>volumes: - /home/ubuntu/codeigniter-project/mydatabase/:/var/lib/mysql</strong><br>Mounts the local directory /home/ubuntu/codeigniter-project/mydatabase/ to /var/lib/mysql in the MySQL container.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cUmmeGT0ox4zOvuTWdGS4A.png" /></figure><p>Certainly, if you are in the codeigniter-project folder, running the following command will build and start the containers in detached mode:</p><pre>docker-compose up -d</pre><p>This command tells Docker Compose to read the docker-compose.yml file in the current directory and build the services defined within it. The -d flag stands for &quot;detached,&quot; meaning the containers will run in the background.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rkyswXDKBq7YyGtWhIZAfA.png" /></figure><p>Ensure that you have Docker Compose installed on your system and that you are in the correct directory before running this command. Once executed, Docker Compose will handle the orchestration of your CodeIgniter application and MySQL database containers.</p><p><strong><em>Open a web browser and enter the IP address in the address bar. If your machine’s IP address is, for example, </em></strong><strong><em>192.168.1.2, enter </em></strong><strong><em>http://192.168.1.2 in the browser.</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jBB5XotWFJ6ZnHXp8z9iIw.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d186c47c7a34" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Guide to Hosting CodeIgniter on Ubuntu Server]]></title>
            <link>https://medium.com/@sonumishra19091999/guide-to-hosting-codeigniter-on-ubuntu-server-f666b7f2f9f8?source=rss-3c6bf5ae723f------2</link>
            <guid isPermaLink="false">https://medium.com/p/f666b7f2f9f8</guid>
            <dc:creator><![CDATA[Sonumishra]]></dc:creator>
            <pubDate>Wed, 06 Mar 2024 11:43:44 GMT</pubDate>
            <atom:updated>2024-03-08T12:27:08.441Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*mNEec5EuSpx7WCUVJcUtsw.jpeg" /></figure><h3>INTRODUCTION</h3><p>CodeIgniter helps create dynamic and interactive web experiences. If you’re ready to take your website from your computer to the internet, this guide is for you! We’ll walk you through deploying your CodeIgniter project on an Ubuntu server. <br>This detailed guide will take you through each crucial step, ensuring a seamless and secure deployment process.</p><h3>Prerequisites:</h3><p>Ubuntu server setup</p><h3>STEPS:</h3><p>STEP:1 Installing LAMP Stack (Apache, PHP and MYSQL)<br>STEP:2 Installing Composer<br>STEP:3 Installing Codeigniter 4<br>STEP:4 Configuring MYSQL for Codeigniter 4<br>STEP:5 Configuring Apache for Codeigniter 4</p><h4>STEP:1 Installing LAMP Stack (Apache, PHP and MYSQL)</h4><p>To deploy your CodeIgniter project, we’ll first need to install two essential components on your system: Apache web server and PHP. Apache acts as the foundation, serving your website’s files to visitors. PHP is a scripting language that helps your website generate dynamic content.</p><p>You can install them by running the following command.</p><pre>sudo apt update -y<br><br>sudo apt install apache2 php php-cli php-common php-imap php-redis php-snmp php-xml php-zip php-mbstring php-curl libapache2-mod-php php-intl -y</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*laXkVK0j_CcIDBMPgj-kxw.png" /></figure><p>After successfully installing Apache, initiate and activate the Apache service with this straightforward command:</p><pre>sudo systemctl start apache2<br><br>sudo systemctl enable apache2</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aNmay8TaASVcCWr3pYRxrw.png" /></figure><p>Following the installation, confirm your PHP version with this simple command:</p><pre>php -v</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eVLeATcJuVFreiHgXFbc4Q.png" /></figure><p>Now lets install MYSQL following the below command:</p><pre>apt install mariadb-server mariadb-client -y</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mxBovs0Tl4p4ADmkoTs0qw.png" /></figure><p>Check the status of the MariaDB service by using the following command:</p><pre>systemctl status mariadb</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dNIG6tFi18qiLCzfdspq3g.png" /></figure><p>By default, MariaDB comes without additional security measures. To enhance the security of your MariaDB installation, execute the mysql_secure_installation script:</p><pre>mysql_secure_installation</pre><p>This script will guide you through securing your MariaDB installation by setting up a root password, removing anonymous users, restricting root login, and more. Follow the prompts to enhance the security of your MariaDB database server.<br>Configure it like this:</p><ul><li>— Set root password? [Y/n] <strong>Y</strong></li><li>— Remove anonymous users? [Y/n] <strong>Y</strong></li><li>— Disallow root login remotely? [Y/n] <strong>Y</strong></li><li>— Remove test database and access to it? [Y/n] <strong>Y</strong></li><li>— Reload privilege tables now? [Y/n] <strong>Y</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gfv-NO8vZ_3Of3plKZjOmg.png" /></figure><p>Now, access the MariaDB shell by entering the following command:</p><pre>mysql -u root -p</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QiScfJ8ToPVh4B-mL47trQ.png" /></figure><p>After successfully logging into your database server, create a dedicated database for your CodeIgniter installation using the following SQL commands:</p><pre>CREATE DATABASE codeigniter;</pre><pre>CREATE USER &#39;codeigniter&#39;@&#39;localhost&#39; IDENTIFIED BY &#39;your-safe-password&#39;;</pre><pre>GRANT ALL PRIVILEGES ON codeigniter. * TO &#39;codeigniter&#39;@&#39;localhost&#39;;</pre><pre>FLUSH PRIVILEGES;</pre><pre>exit;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*64mbv2_xS3xvbwyObpJsIQ.png" /></figure><h4>STEP:2 Installing Composer</h4><p>Composer serves as a PHP dependency manager for CodeIgniter, streamlining the integration of external libraries. It automates autoloading, enforces version control, and facilitates efficient package installation. This tool enhances code modularity and simplifies the management of project dependencies, optimizing the development workflow.</p><p>To install PHP Composer, execute the following command:</p><pre>curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cmb5N0GDxd_6ly2B90hSBA.png" /></figure><p>Confirm the successful installation of Composer by running the following command:</p><pre>composer --version</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZKWxhGj2PUlcujm-UNqwVw.png" /></figure><h4>STEP:3 Installing Codeigniter 4</h4><p>Move into the Apache web root directory using the following command:</p><pre>cd /var/www/html</pre><p>This command takes you to the directory where Apache serves web content, providing a suitable location to install CodeIgniter 4.</p><p>Following that, initiate a new CodeIgniter 4 project with the following command:</p><pre>composer create-project codeigniter4/appstarter app</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MMyIR8OO4TONYmnmybRR7g.png" /></figure><p>Replace &#39;app&#39; with the desired name for your CodeIgniter 4 project. This command fetches the necessary files and sets up a new CodeIgniter 4 project in the specified directory.</p><p>After creating your CodeIgniter 4 project, establish the correct ownership for the project directory using the following command:</p><pre>chown -R www-data:www-data /var/www/html/app</pre><h4>STEP:4 Configuring MYSQL for Codeigniter 4</h4><p>Editing the database configuration in CodeIgniter is essential to establish a connection between the application and the database. It ensures accurate data storage and retrieval, enabling seamless interaction between the CodeIgniter 4 project and the configured database, enhancing overall functionality and reliability.</p><p>Proceed to modify the database configuration by executing the following commands inside ‘html’ folder:</p><pre>cp app/env app/.env <br><br>nano app/.env</pre><p>Replace ‘app’ with your project name</p><p>Configure the environment settings in the .env file as follows:</p><p># — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — # ENVIRONMENT # — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — CI_ENVIRONMENT = development</p><p>This setting indicates that your CodeIgniter 4 project is currently set up for development. Adjust the environment variable based on your project’s deployment stage, whether it’s development, testing, or production.</p><p>Adjust the CodeIgniter base URL for web browser access in the .env file:</p><p>Configure CodeIgniter base URL for accessing via your web browser:-</p><p># — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — # APP # — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — app.baseURL = ‘http://localhost&#39;</p><p>Replace &#39;http://localhost&#39; with the actual URL where your CodeIgniter 4 application will be accessible. This configuration ensures proper routing and links within your application.</p><p>Configure the database connection settings in the .env file as follows:</p><p># — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — # DATABASE # — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —</p><p>database.default.hostname = localhost <br>database.default.database = codeigniter <br>database.default.username = codeigniter <br>database.default.password = Str0ngP@ssf1 <br>database.default.DBDriver = MySQLi</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LUXOr8OAq_0sEaHISTNu3A.png" /></figure><p>Replace ‘Str0ngP@ssf1’ with your codeigniter 4 user password</p><h4>STEP:5 Configuring Apache for Codeigniter 4</h4><p>Configuring Apache for CodeIgniter 4 is essential to ensure proper routing, URL rewriting, and access to project files. This process optimizes the web server’s settings, enhancing the application’s performance, security, and overall functionality, making it accessible via the specified domain and facilitating seamless user interaction.</p><p>Now, Create a new Apache virtual host configuration file using the command:</p><pre>nano /etc/apache2/sites-available/codeigniter.conf</pre><p>Insert the provided configuration into the Apache virtual host file:</p><pre>&lt;VirtualHost *:80&gt;<br>ServerName @localhost<br>DocumentRoot /var/www/html/app/public<br><br>&lt;Directory /var/www/html/app&gt;<br>AllowOverride All<br>&lt;/Directory&gt;<br><br>ErrorLog ${APACHE_LOG_DIR}/error.log<br>CustomLog ${APACHE_LOG_DIR}/access.log combined<br><br>&lt;/VirtualHost&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YL1mUbgMtoD0fbvA1vmHNw.png" /></figure><p>After adding the configuration, save and close the file. Then, activate the Apache virtual host using the following command:</p><p>Following the configuration updates, restart the Apache service to implement the changes:</p><pre>systemctl reload apache2</pre><p>This command reloads the Apache service, ensuring that the modifications to the virtual host configuration take effect without restarting the entire server.</p><p>Now, Disable the default Apache configuration file using the following command:</p><pre>sudo a2dissite 000-default.conf</pre><p>This command deactivates the default configuration, ensuring that only your newly configured virtual host is active.</p><p>Reload Apache to apply the changes:</p><pre>systemctl reload apache2</pre><p><strong><em>Now, open your web browser and navigate to the CodeIgniter UI using the URL </em></strong><a href="http://web.example.com/"><strong><em>http://web.example.com</em></strong></a><strong><em>. You should encounter the initial setup screen, indicating that your CodeIgniter application is accessible and ready for configuration.</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cMX6_8JBvyKBQixiFY41wQ.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f666b7f2f9f8" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>