<?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 Rahul Gupta on Medium]]></title>
        <description><![CDATA[Stories by Rahul Gupta on Medium]]></description>
        <link>https://medium.com/@rahul26021999?source=rss-67485d4353ea------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*ba56t2C7wKJWph7fX2Os2A.jpeg</url>
            <title>Stories by Rahul Gupta on Medium</title>
            <link>https://medium.com/@rahul26021999?source=rss-67485d4353ea------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 23:47:25 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rahul26021999/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[How to deploy Python Django Project on AWS EC2 Ubuntu Server.]]></title>
            <link>https://rahul26021999.medium.com/how-to-deploy-python-django-project-on-aws-ec2-ubuntu-server-5c484fdb8f8c?source=rss-67485d4353ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/5c484fdb8f8c</guid>
            <category><![CDATA[ubuntu]]></category>
            <category><![CDATA[deploy]]></category>
            <category><![CDATA[django]]></category>
            <category><![CDATA[hosting]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Rahul Gupta]]></dc:creator>
            <pubDate>Sat, 11 Dec 2021 15:04:15 GMT</pubDate>
            <atom:updated>2024-04-11T12:19:46.888Z</atom:updated>
            <content:encoded><![CDATA[<p>Here, We will learn how to deploy a Django Project on AWS EC2 Ubuntu Server using Gunicorn.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Bgrr5SLtZOOuuW-1.png" /></figure><p><strong>Prerequisites</strong></p><ol><li>Create a Ubuntu Server On AWS EC2 Instance.<br>If not created yet?<br><strong> </strong><a href="https://medium.com/@rahul26021999/how-to-create-a-ubuntu-20-04-server-on-aws-ec2-elastic-cloud-computing-5b423b5bf635"><strong>Learn How to Create a Ubuntu 20.04 Server on AWS EC2 (Elastic Cloud Computing)</strong></a></li><li><a href="https://rahul26021999.medium.com/how-to-connect-to-ec2-instance-aws-from-windows-ubuntu-da97c0cc9c8"><strong>Connect to Ubuntu Server Created in the above Step.</strong></a></li></ol><h3>Steps To deploy Django Project on EC2 Instance</h3><h4><strong>Install required Libraries</strong></h4><pre><strong># Update the ubuntu libraries</strong></pre><pre>$ sudo apt-get update </pre><pre><strong># Install Python, pip, Nginx, Postgresql</strong></pre><pre>$ sudo apt-get install python3-pip python3-dev libpq-dev postgresql postgresql-contrib nginx</pre><pre><strong># If you want to use Mysql Database  </strong></pre><pre>$ sudo apt-get install python3-dev default-libmysqlclient-dev build-essential</pre><pre><strong># Install Virtual Environement</strong></pre><pre>$ sudo -H pip3 install --upgrade pip<br>$ sudo -H pip3 install virtualenv</pre><h4>Create a virtual environment for the project and Activate it.</h4><pre><strong># Create a project Directory</strong></pre><pre>$ mkdir myproject</pre><pre><strong># Move inside Project Directory</strong></pre><pre>$ cd myproject</pre><pre><strong># Create Virtual Environment for project</strong></pre><pre>$ virtualenv <strong>myprojectenv</strong></pre><pre><strong># Activate virtual Environment</strong></pre><pre>$ source <strong>myprojectenv</strong>/bin/activate</pre><h4>Create a Django project or clone using version control and install project dependencies.</h4><pre><strong>#  Clone Existing Project in myproject Directory </strong></pre><pre>$ git clone <a href="https://github.com/rahul26021999/TicTacToe.git">https://github.com/YourUserName/</a><strong>djangoProject</strong><a href="https://github.com/rahul26021999/TicTacToe.git">.git</a></pre><pre>$ cd <strong>djangoProject</strong></pre><pre>$ pip install -r requirements.txt</pre><pre><strong>                                   OR</strong></pre><pre><strong># Create a new Django Project in myproject Directory</strong></pre><pre>$ pip install django</pre><pre>$ django-admin --version</pre><pre>$ django-admin startproject <strong>djangoProject</strong></pre><pre>$<strong> </strong>cd <strong>djangoProject</strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/818/1*hzdUGCcLC4KaM9e38vR5kQ.png" /><figcaption>Directory Structure</figcaption></figure><p>Here till now, we have created or cloned a project in myproject directory. Our directory structure should look like this.</p><h4><strong>Change project settings</strong></h4><pre>(<strong>myprojectenv</strong>) $ sudo vi <strong>djangoProject</strong>/settings.py</pre><p>a) Change allowed hosts in Settings.py to accept HTTP requests from the server’s IP or anywhere by adding <strong>‘*’</strong>.</p><pre>ALLOWED_HOSTS = [&#39;*&#39; ,&#39;your_server_domain_or_IP&#39;, &#39;second_domain_or_IP&#39;]</pre><p>b) Change Database Settings</p><p>We have installed the Postgresql Database in the Instance you can create your new Database in the EC2 instance or can use any database that you want.</p><p>You can also go with the SQLite Database which comes by default with the Django project.</p><pre>DATABASES = {<br>    &#39;default&#39;: {<br>        &#39;ENGINE&#39;: &#39;django.db.backends.postgresql_psycopg2&#39;,<br>        &#39;NAME&#39;: &#39;myproject&#39;,<br>        &#39;USER&#39;: &#39;myprojectuser&#39;,<br>        &#39;PASSWORD&#39;: &#39;password&#39;,<br>        &#39;HOST&#39;: &#39;localhost&#39;,<br>        &#39;PORT&#39;: &#39;&#39;,<br>    }<br>}</pre><p><strong>Note:</strong> Replace the Database name “myproject”, Database User “myprojectuser” and Database Password “password” with yours.</p><p>c) Setting indicating where the static files should be placed</p><pre><strong># Add on the top of setting.py file (Ignore if already there)</strong></pre><pre>import os</pre><pre><strong># Add at the end of the setting.py File (Ignore if already there)</strong></pre><pre>STATIC_URL = &#39;/static/&#39;<br>STATIC_ROOT = os.path.join(BASE_DIR, &#39;static/&#39;)</pre><p>Save and exit from the setting.py file.</p><h4>Complete Initial Project Setup</h4><ol><li>Migrate the initial database schema to the new database that we have created.</li></ol><pre>(<strong>myprojectenv</strong>) $ python manage.py makemigrations<br>(<strong>myprojectenv</strong>) $ python manage.py migrate</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/968/1*Z3sS7S-VskCqTKZzuWpF7w.png" /></figure><p>After Default migrations, you will see results like this.</p><p>2. Create a superuser</p><pre>(<strong>myprojectenv</strong>) $ python manage.py createsuperuser</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vBDPNy2aRIX5wdnK6Utz5w.png" /></figure><p>3. Collect all the static files</p><pre>(<strong>myprojectenv</strong>) $ python manage.py collectstatic</pre><p>You may have to confirm the operation. The static files will then be placed in a directory called static within your project directory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/736/1*B6ACw2Ykwh0g3mq6e67yng.png" /></figure><h4>Test the server</h4><pre>(<strong>myprojectenv</strong>) $ python manage.py runserver 0.0.0.0:8000</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GNrOVIGHhHlEDmAOCsn5Hg.png" /></figure><p>In your web browser, visit your server’s domain name or IP address followed by :8000 . You will see the Django default home page for the new project or your custom page for the existing repo.</p><pre>http://server_domain_or_IP:8000</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tGuaOmM4CR6oPyxk7Vsgqw.png" /></figure><p>Check By Accessing the admin panel using <a href="http://server_domain_or_ip:8000/">http://server_domain_or_IP:8000</a>/admin.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ihh9Edyuxp0Q7qy4a2dsIA.png" /></figure><p>In terminal Use CTRL-C to exit. We will use Gunicorn to host the project this is just for exploring and testing the project.</p><p><strong>Note: </strong>Make sure you have opened the security inbound port 8000 in the Security group while creating the EC2 instance, If not then you can do it now.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1020/1*Mka3exYHVqAFSUDD0InlZA.png" /><figcaption>Security Inbound setting for the EC2</figcaption></figure><h4>Install Gunicorn and Postgres adapter in Virtual environment</h4><p>With your virtual environment active, install Django, Gunicorn, and the psycopg2 PostgreSQL adaptor with the local instance of pip</p><pre>(<strong>myprojectenv</strong>) $ pip install django gunicorn psycopg2-binary</pre><h4>Testing Gunicorn’s Ability to Serve the Project</h4><p>This will start Gunicorn on the same interface that the Django development server was running on. You can go back and test the app again.</p><pre>(<strong>myprojectenv</strong>) $ gunicorn --bind 0.0.0.0:8000 <strong>djangoProject</strong>.wsgi</pre><p>Check By Accessing the admin panel using <a href="http://server_domain_or_ip:8000/">http://server_domain_or_IP:8000</a>/admin</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/448/1*10k4wNLRcKX3HzgkxcU-Og.png" /></figure><p><strong>Note:</strong> The admin interface will not have any of the styling applied since Gunicorn does not know about the static CSS content responsible for this.</p><p>Use CTRL-C to exit. If not then try CTRL +SHFT + C.</p><p>Deactivate from the virtual Environment</p><pre>(<strong>myprojectenv</strong>) $ deactivate</pre><p>we are ready for hosting the using Gunicorn now.</p><h4>Create a Gunicorn systemd Service File</h4><p>we are using “djangoproject” as a service name you can use any name here.</p><pre>$ sudo vi /etc/systemd/system/djangoproject.service</pre><pre><strong># Add the below content to djangoproject service file and save it.</strong></pre><pre>[Unit]<br>Description=gunicorn daemon<br>After=network.target</pre><pre>[Service]<br>User=ubuntu<br>Group=www-data<br>WorkingDirectory=/home/ubuntu/myproject/<strong>djangoProject</strong><br>ExecStart=/home/ubuntu/<strong>myproject/myprojectenv</strong>/bin/gunicorn --access-logfile - --workers 3 --bind unix:/home/ubuntu/<strong>myproject</strong>/<strong>djangoProject</strong>/<strong>djangoProject</strong>.sock <strong>djangoProject</strong>.wsgi:application</pre><pre>[Install]<br>WantedBy=multi-user.target</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S3PMWsthq9qtR6GnBPZ4sg.png" /><figcaption>/etc/systemd/system/djangoproject.service</figcaption></figure><p>save and exit the file.</p><p><strong>Note: </strong>Make sure everything must be correct here. If you are using a different project name then check again for the service file.</p><p>We can now start the Gunicorn service we created and enable it so that it starts at boot:</p><pre>$ sudo systemctl start djangoproject // start the service<br>$ sudo systemctl enable djangoproject // Enable the service<br>$ sudo systemctl status djangoproject // Check status</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-2krpDRMNER2OQ4twerrcg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9dXiTQSvxKtIwc-Zt4-1ow.png" /><figcaption>djangoproject.service status check</figcaption></figure><p>User CTRL-C to exit from status.</p><p><strong>Note:</strong> If the status of djangoproject.service is not <strong>“Active”</strong>, Check the error it can be a path error in your djangoproject.service file. You can edit the service file and correct it.</p><pre><strong># If there is any Error ( Run below commands after editing the .service file )</strong></pre><pre>$ sudo systemctl daemon-reload<br>$ sudo systemctl restart djangoproject</pre><p>Check for the djangoproject Socket File in your project directory. It must be there.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/801/1*GI-rESkZA4sv0uNdscrpLQ.png" /></figure><h3>Configure Nginx to Proxy Pass to Gunicorn</h3><p>Now that Gunicorn is set up, we need to configure Nginx to pass traffic to the process.</p><p>Start by creating and opening a new server block in Nginx’s sites-available directory</p><pre>$ sudo vi /etc/nginx/sites-available/<strong>djangoproject</strong></pre><pre><strong># Add the code below</strong></pre><pre>server {<br>    listen 80;<br>    server_name server_domain_or_IP;<br><br>    location = /favicon.ico { access_log off; log_not_found off; }<br>    location /static/ {<br>        root /home/ubuntu/<strong>myproject</strong>/<strong>djangoProject</strong>;<br>    }<br><br>    location / {<br>        include proxy_params;<br>        proxy_pass http://unix:/home/ubuntu<strong>/myproject/djangoProject</strong><strong>/djangoProject</strong><strong>.sock;</strong><br>    }<br>}</pre><pre><strong># save and exit</strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/933/1*_a21iaxp3G7H3-iGyZNwng.png" /><figcaption>/etc/nginx/sites-available/<strong>djangoproject</strong></figcaption></figure><p><strong>Note:</strong> Replace your IP address with &quot;server_domain_or_IP&quot; .</p><p>Now, we can enable the file by linking it to the sites-enabled directory:</p><pre>$ sudo ln -s /etc/nginx/sites-available/<strong>djangoproject</strong> /etc/nginx/sites-enabled</pre><pre><strong># Test your Nginx configuration for syntax errors by typing:</strong></pre><pre>$ sudo nginx -t</pre><pre><strong># If no errors are reported, go ahead and restart Nginx by typing:</strong></pre><pre>$ sudo systemctl restart nginx</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fDzcG3Wa3321TAoXZcbEIw.png" /></figure><p>Here, We are done now you can test your project by accessing it on the web browser using your IP address. We have hosted this application on port 80, So that you don&#39;t have to enter any port in the URL as 80 is the default port.</p><pre>http://server_domain_or_IP</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uzPOp2erh7XjK2eA4CZhRQ.png" /><figcaption>Default Django Page</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C8I-XIBaX_l4tPh3uz6gJg.png" /><figcaption>Admin Panel</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5c484fdb8f8c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Generate QR Code in Java Spring Boot]]></title>
            <link>https://rahul26021999.medium.com/how-to-generate-qr-code-in-java-spring-boot-134adb81f10d?source=rss-67485d4353ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/134adb81f10d</guid>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[qr-code]]></category>
            <category><![CDATA[qrcodegenerator]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Rahul Gupta]]></dc:creator>
            <pubDate>Wed, 29 Sep 2021 13:00:35 GMT</pubDate>
            <atom:updated>2021-09-30T01:37:47.328Z</atom:updated>
            <content:encoded><![CDATA[<p>As we know that QR Codes are becoming the most widely recognized 2D barcodes worldwide. The big benefit of the QR code is that <strong>we can store large amounts of data in a limited space.</strong></p><p>Here, In this article, we will learn how to generate a QR code using Java Spring boot.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/853/1*_eSm7ooRH2I_Sb2ppOTTtA.png" /><figcaption><a href="http://localhost:8080/">http://localhost:8080</a></figcaption></figure><h3>Create a Java spring Boot project and add spring web starter dependencies in the pom.xml</h3><ol><li>Spring Boot web starter</li><li>Thymeleaf : Thymeleaf is a Java-based library used to create a web application. It provides good support for serving an XHTML/HTML5 in web applications.</li></ol><pre>&lt;dependency&gt;<br>    &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;<br>    &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;<br>&lt;/dependency&gt;</pre><pre>&lt;dependency&gt;<br>    &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;<br>    &lt;artifactId&gt;spring-boot-starter-thymeleaf&lt;/artifactId&gt;<br>&lt;/dependency&gt;</pre><h3><strong>Add ZXing Library to generate the QR Code in the pom.xml</strong></h3><p>We are using ZXing Library to generate the QR Code, so it is required to add two more dependencies in the<strong> pom.xml </strong>file as shown below.</p><ol><li><strong>Core image dependency</strong></li></ol><pre>&lt;dependency&gt;<br>    &lt;groupId&gt;com.google.zxing&lt;/groupId&gt;<br>    &lt;artifactId&gt;core&lt;/artifactId&gt;<br>    &lt;version&gt;3.4.0&lt;/version&gt;<br>&lt;/dependency&gt;</pre><p><strong>2. Java Client dependency.</strong></p><pre>&lt;dependency&gt;<br>    &lt;groupId&gt;com.google.zxing&lt;/groupId&gt;<br>    &lt;artifactId&gt;javase&lt;/artifactId&gt;<br>    &lt;version&gt;3.4.0&lt;/version&gt;<br>&lt;/dependency&gt;</pre><p>Till here your pom.xml file should look like this :</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f83575ae284a626f94814b677e7e1ac0/href">https://medium.com/media/f83575ae284a626f94814b677e7e1ac0/href</a></iframe><h3>Create a class for <strong>QR Code Generator name QRCodeGenerator.java</strong></h3><p>Add two static functions in the QRCodeGenerator class.</p><ol><li><strong>Generate QR Code Image </strong><br>This function is used to generate the QR Code in image form and this will save the image in the specified path.</li><li><strong>Generate QR Code ByteArray </strong><br>This function will generate the QR Code in the form of a byte array.</li></ol><p>We can change the color of the QR Code by mentioning the colors in the MatrixToImageConfig Object.</p><pre>MatrixToImageConfig con = new MatrixToImageConfig( foregroundColor , backgroundColor) ;</pre><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e6c6fd9521e5549611afe99fd0abbf91/href">https://medium.com/media/e6c6fd9521e5549611afe99fd0abbf91/href</a></iframe><h3>Create a Controller class name MainController.java</h3><p>In this class, we will create a method “<strong>getQRCode”</strong> with the GetMapping (“/”). This method will call the function that we have created in QRCodeGenerator class to get the Image or the Byte Array for the QR code.</p><p>We have returned a file name called qrcode.html that will display the QRCode. This qrcode.html is located in resources/templates/qrcode.html</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ca42f3748a7701bea2c913434ee36200/href">https://medium.com/media/ca42f3748a7701bea2c913434ee36200/href</a></iframe><h3>Run the application</h3><ol><li>Go to the browser and hit: <a href="http://localhost:8080/"><em>http://localhost:8080</em></a></li><li>Go inside the “<em>src/main/resources/static/img/</em>” folder to see the QR Code image.</li></ol><h3>Github Repository for full Reference</h3><p><a href="https://github.com/rahul26021999/QrCode-JavaSpringBoot">https://github.com/rahul26021999/QrCode-JavaSpringBoot</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=134adb81f10d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to get a Free Domain Name for AWS Web Hosting]]></title>
            <link>https://rahul26021999.medium.com/how-to-get-a-free-domain-name-for-aws-web-hosting-512471e24af3?source=rss-67485d4353ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/512471e24af3</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[aws-ec2]]></category>
            <category><![CDATA[dns]]></category>
            <category><![CDATA[domains]]></category>
            <dc:creator><![CDATA[Rahul Gupta]]></dc:creator>
            <pubDate>Thu, 04 Feb 2021 17:10:33 GMT</pubDate>
            <atom:updated>2021-05-09T01:03:13.529Z</atom:updated>
            <content:encoded><![CDATA[<p>Here, we will learn how to set free Domain Name for a AWS EC2 instance . Considering that you have already created a EC2 instance on AWS .<br>and you have already configured EC2 instance to handle HTTPS or HTTP request from the world . <strong>If not please take reference from the given links.</strong></p><ol><li><a href="https://medium.com/@rahul26021999/how-to-create-a-ubuntu-20-04-server-on-aws-ec2-elastic-cloud-computing-5b423b5bf635">How to Create a Ubuntu 20.04 LTS server in AWS EC2 .</a></li><li><a href="https://medium.com/@rahul26021999/how-to-deploy-laravel-project-on-ec2-aws-6d004a57bb1f">How To Deploy Laravel Project on EC2 AWS</a> . (Complete Reference to Create a Apache server , MySQL server and deploy Laravel Project)</li></ol><h3>Allocate a Elastic IP Address to your EC2 Instance</h3><p>You can use EC2 Instance public IP Address to Domain Name System but if you will restart , stop , start your EC2 Instance the EC2 IP Address will Change and you have to change that in you Domain Name System also that’s why you should use Elastic IP for mapping EC2 with Domain Name System.</p><ol><li>Go to EC2 Instance&gt; Network &amp; Security &gt; Elastic IP in AWS Services.</li><li>Click On Allocate a New Address</li><li>AWS provides only one free Elastic IP for AWS Free Tier.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/1*d41bP6grMMz95ldHHcGtPA.png" /></figure><p>4. Choose the Elastic IP Address Created above and Associate that IP to AWS EC2 instance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/1*42uZfdzk4b25NTaV8ErHCg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/1*jmV3VGtrm6JkO2atzVNHtw.png" /></figure><p>5. Now you can use this Public Elastic IP Address in your Domain Name System .</p><h3>Get a free Domain Name</h3><ol><li>You can get a free domain name from F<a href="https://www.freenom.com/en/index.html?lang=en">reenom</a>. It provides .ml , .tk , .cf , etc for free .</li><li>Go to Manage DNS section and add two “A” Records to map Domain with your public IP address of your EC2 .</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ID0ALpCzCZSSgGTVv0BvVg.png" /></figure><p>3. It might take 10 — 30 min to Map your domain with your EC2 .</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=512471e24af3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Download/Upload a File/Directory from AWS EC2 Instance to Local Machine.]]></title>
            <link>https://rahul26021999.medium.com/download-upload-a-file-directory-from-aws-ec2-instance-to-local-machine-de95e08fc07e?source=rss-67485d4353ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/de95e08fc07e</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[download]]></category>
            <category><![CDATA[filé]]></category>
            <category><![CDATA[aws-ec2]]></category>
            <category><![CDATA[ubuntu]]></category>
            <dc:creator><![CDATA[Rahul Gupta]]></dc:creator>
            <pubDate>Thu, 04 Feb 2021 16:41:24 GMT</pubDate>
            <atom:updated>2021-12-12T03:41:08.902Z</atom:updated>
            <content:encoded><![CDATA[<p>Here , we will learn about how to exchange files between local machine and AWS EC2 Instance.</p><p><strong>Related Links</strong></p><ol><li><a href="https://medium.com/@rahul26021999/how-to-create-a-ubuntu-20-04-server-on-aws-ec2-elastic-cloud-computing-5b423b5bf635">https://medium.com/@rahul26021999/how-to-create-a-ubuntu-20-04-server-on-aws-ec2-elastic-cloud-computing-5b423b5bf635</a></li><li><a href="https://medium.com/@rahul26021999/how-to-connect-to-ec2-instance-aws-from-windows-ubuntu-da97c0cc9c8">https://medium.com/@rahul26021999/how-to-connect-to-ec2-instance-aws-from-windows-ubuntu-da97c0cc9c8</a></li></ol><h3><strong>Download a file from AWS EC2 Instance</strong></h3><p>By running this command you can download a file from AWS EC2 instance to your local machine.</p><pre>$ sudo scp -i path/to/mykey.pem user@ec2–49–252–8–93.ap-south-1.compute.amazonaws.com:path/remote/filename path/local/directory</pre><h3><strong>Download a directory from AWS EC2 Instance</strong></h3><p>By running this command you can download a folder from AWS EC2 instance to your local machine.</p><pre>$ sudo scp -i path/to/mykey.pem -r user@ec2–49–252–8–93.ap-south-1.compute.amazonaws.com:path/remote/directory path/local/directory</pre><p><strong># Hack 1 </strong>: To download folder from AWS EC2, You can archive it and then download it like a file .</p><h3>Upload a file to AWS EC2 Instance from local</h3><p>By running this command you can upload a file from your local machine to AWS EC2 instance.</p><pre>$ sudo scp -i path/to/mykey.pem path/local/filename user@ec2–49–252–8–93.ap-south-1.compute.amazonaws.com:path/remote/directory</pre><h3>Upload a directory to AWS EC2 Instance from local</h3><p>By running this command you can upload a folder from your local machine to AWS EC2 instance.</p><pre>$ sudo scp -i path/to/mykey.pem -r path/local/directoryName user@ec2–49–252–8–93.ap-south-1.compute.amazonaws.com:path/remote/directory</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=de95e08fc07e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Create a Ubuntu 20.04 Server on AWS EC2 (Elastic Cloud Computing)]]></title>
            <link>https://rahul26021999.medium.com/how-to-create-a-ubuntu-20-04-server-on-aws-ec2-elastic-cloud-computing-5b423b5bf635?source=rss-67485d4353ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/5b423b5bf635</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[aws-ec2]]></category>
            <category><![CDATA[ubutu]]></category>
            <category><![CDATA[ubuntu-20-04]]></category>
            <dc:creator><![CDATA[Rahul Gupta]]></dc:creator>
            <pubDate>Tue, 30 Jun 2020 22:30:58 GMT</pubDate>
            <atom:updated>2021-05-09T01:03:17.203Z</atom:updated>
            <content:encoded><![CDATA[<p>Here , we will learn about how to create a <strong>Ubuntu 20.04 LTS</strong> server on AWS EC2 . <br>All of this is <a href="http://aws.amazon.com/free/">Free tier</a> eligible : <br>1. The Amazon <strong>EC2 Free Tier</strong> is available to you for <strong>12 months </strong>. <br>2. <strong>750 hrs</strong> per month of Amazon EC2 in a Single-AZ db.t2.micro Instance.</p><p><strong>Prerequisites<br></strong> Create a AWS Account .</p><h3>Steps To Create a Ubuntu Instance</h3><p>1. Login with your AWS Account and go to <strong>console.</strong></p><p>2. Search for <strong>EC2</strong> in Services and Go to EC2 .</p><p>3. (optional) In the top right corner of the Amazon EC2 , select the <strong><em>Region</em></strong><em> </em>in which you want to create the EC2 instance .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/559/1*m4lSrQZudgDU-aF6uvni5w.png" /></figure><p>4. Click on <strong>Launch</strong> Instance On <strong>EC2 Dashboard</strong> .</p><p>5. Choose <strong>AMI</strong> (Amazon Machine Image) i.e Select <strong>Ubuntu 20.04 LTS </strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VYhFHqQq2ElDbzTcgiYJRw.png" /></figure><p>6. Choose and Instance Type in this Case we will choose <strong>General purpose t2.micro</strong>. Because that is <strong>Free Tier Eligible</strong> . Now click On Next : Configure Instance Details .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KGY_3_kYT2b6IiG1_T-oig.png" /></figure><p>7. (optional) Configure Instance. In this we can specify the No. of instances and User Roles for those instances by specifying <strong>IAM Role</strong> .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NK2H_j_cesCbj3rgvCGNcg.png" /></figure><p>8. Add Storage : In this we can change the <strong>size</strong> for our EC2 Instance . Free Tier is Eligible upto <strong>30GB of Storage</strong> .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8IkwWyf2Qmbyg3L2FTPzEQ.png" /></figure><p>9. (Optional) Add Tags : We can add Some tags to specify the Instance Type here .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PxLS0yiWvk54cBgWnpMOjA.png" /></figure><p>10. Configure <strong>Security</strong> <strong>Group</strong></p><p>Here we will create a <strong>new</strong> Security Group in which we will specify which <strong>Ports</strong> will be Open for EC2 instance .</p><p>We will add <strong>HTTP</strong> , <strong>HTTPS</strong> and <strong>SSH</strong> Port for our EC2 Instance. HTTP and HTTPS to allow web request from anywhere in the world to our instance . And SSH to <strong>Connect</strong> to our EC2 Instance from <strong>Local</strong> <strong>Machine</strong> .</p><pre>HTTP   80   Anywhere <br>HTTPS  443  Anywhere<br>SSH    20   Anywhere or Custom</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l1Oehdegff8vC66YNrX5ZA.png" /></figure><p>11 . <strong>Review</strong> and <strong>Launch</strong> Instance</p><p>12 . Create a <strong>key pair</strong> to <strong>connect</strong> to our EC2 instance from local machine. <strong>Download</strong> the Key Pair and keep it <strong>Safely</strong>. It will be used to connect to EC2 instance <strong>Later</strong> .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I7qKB4TVwhcBZ55IbeccYQ.png" /></figure><p>13 . Click on <strong>Launch Instance.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wMwfzM_G9FT--Nj5eRhrGQ.png" /></figure><blockquote>Your EC2 Instance is <strong>Ready</strong> to use. Please wait for while until <strong>Instance State </strong>change to <strong>running</strong> and <strong>status check</strong> is <strong>done</strong> . Now , <br><a href="https://medium.com/@rahul26021999/how-to-connect-to-ec2-instance-aws-from-windows-ubuntu-da97c0cc9c8"><strong>Connect</strong> to your EC2 Instance from your Local Machine ( <strong>Window</strong> / <strong>Ubuntu</strong>)</a></blockquote><h3>Also Learn</h3><ol><li><a href="https://medium.com/@rahul26021999/how-to-deploy-laravel-project-on-ec2-aws-6d004a57bb1f">How To Deploy Laravel Project on EC2 AWS .</a> ( Complete Reference to Create a Apache server , mysql server and deploy laravel Project )</li><li><a href="https://medium.com/@rahul26021999/how-to-setup-mysql-database-on-aws-rds-relational-database-service-f5a186ccbadb">How to setup mysql database on AWS RDS ( Relational Database Service )</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5b423b5bf635" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to connect to EC2 Instance (AWS) from Windows/Ubuntu]]></title>
            <link>https://rahul26021999.medium.com/how-to-connect-to-ec2-instance-aws-from-windows-ubuntu-da97c0cc9c8?source=rss-67485d4353ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/da97c0cc9c8</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[puttygen]]></category>
            <category><![CDATA[putty]]></category>
            <category><![CDATA[aws-ec2]]></category>
            <category><![CDATA[aws-connect]]></category>
            <dc:creator><![CDATA[Rahul Gupta]]></dc:creator>
            <pubDate>Tue, 30 Jun 2020 16:24:01 GMT</pubDate>
            <atom:updated>2021-05-09T01:02:42.425Z</atom:updated>
            <content:encoded><![CDATA[<p>Here, we will learn how to connect to AWS EC2 instance from your local machine (Windows/Ubuntu) .</p><h4>Prerequisite</h4><ol><li>Considering that you have successfully created a AWS Account.</li><li>You have also <strong>created</strong> a AWS EC2 Instance on your AWS Account.<br>If not yet ? <a href="https://medium.com/@rahul26021999/how-to-create-a-ubuntu-20-04-server-on-aws-ec2-elastic-cloud-computing-5b423b5bf635">Learn How to Create a Ubuntu 20.04 Server on AWS EC2 (Elastic Cloud Computing)</a></li><li>Get Ready with your private key file (.pem). That your have generated while creating EC2 instance .</li></ol><h3>Steps to Connect EC2 From Windows</h3><h4>1. Download and Install Putty on your local machine</h4><p>Download and install PuTTY from the <a href="http://www.chiark.greenend.org.uk/~sgtatham/putty/">PuTTY download page</a>. If you already have an older version of PuTTY installed please Update it , Be sure to install the entire suite.</p><h4><strong>2. Convert your private key using PuTTYgen</strong></h4><p>PuTTY does not natively support the private key format for SSH keys. PuTTY provides a tool named <strong>PuTTYgen</strong>, which converts keys to the required format for PuTTY. You must convert your private key (.pem file) into this format (.ppk file) as follows in order to connect to your instance using PuTTY.</p><ol><li>From the <strong>Start</strong> menu, choose <strong>All Programs </strong>then <strong>PuTTYgen</strong>.</li></ol><p>2. Under <strong>Type of key to generate</strong>, choose <strong>RSA</strong>. If you’re using an older version of PuTTYgen, choose <strong>SSH-2 RSA</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/452/1*X0OPLEkMnMYyXob3ZbCRLw.jpeg" /></figure><p>3. Choose <strong>Load</strong>. By default, PuTTYgen displays only files with the extension .ppk . To locate your .pem file, choose the option to display files of all types.</p><p>4. Select your .pem file. It will show a message successfully imported now save your private key .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/448/1*QnxpEz-CJfo6LEzZUG1LXQ.jpeg" /></figure><p>Your private key is now in the correct format for use with PuTTY. You can now <strong>connect</strong> to your instance using PuTTY’s SSH client.</p><h4>3. Connect To EC2 Using Putty</h4><p>1. Start PuTTY (from the <strong>Start</strong> menu, choose <strong>All Programs, PuTTY, PuTTY</strong>) .</p><p>2. In the <strong>Category</strong> pane, choose <strong>Session</strong> and complete the following fields :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/424/1*fHN7S5fKBmkDbrrooQdEYw.jpeg" /></figure><pre>Enter Host_name =  my-instance-user-name@my-instance-public-dns-name<br>Enter Port = 22<br>Connection Type = SSH</pre><blockquote><strong>Replace</strong> “my-instance-user-name@my-instance-public-dns-name”<strong> </strong>with your <strong>host name</strong> and <strong>user name</strong> . You will find these details on <strong>AWS EC2 Dashboard</strong>. Go to EC2 <strong>dashboard</strong>. <strong>Click</strong> on your instance. <strong>Click</strong> on connect you will these find details in Example there .</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/691/1*ReZl8hmiByKn3450gIu25A.png" /></figure><p>3. In the <strong>Category</strong> pane, expand <strong>Connection</strong>, expand <strong>SSH</strong>, and then choose <strong>Auth </strong>then <strong>Browse</strong> and Select the .ppk file that you generated for your key pair and choose <strong>open .</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/426/1*8RLECDPBQj_hOblLPwLZ4Q.jpeg" /></figure><p>4. (Optional) If you plan to start this session again later, you can save the session information for future use. Under <strong>Category</strong>, choose <strong>Session</strong>, enter a name for the session in <strong>Saved Sessions</strong>, and then choose <strong>Save</strong>.</p><p>4. Choose <strong>Open</strong>.</p><blockquote>If this is the first time you have connected to this instance, PuTTY displays a security alert dialog box that asks whether you trust the host to which you are connecting. Choose yes .</blockquote><blockquote>You are now connected to <strong>your</strong> EC2 Instance from Windows</blockquote><h3>Steps to Connect EC2 From Ubuntu</h3><p>To connect to your EC2 Instance from Ubuntu .</p><ol><li>Open Terminal .</li><li>Go to the folder Where your private key is stored .</li><li>Run the Below Command to connect to your EC2 instance .</li></ol><pre>$ sudo ssh -i &quot;yourPrivateKey.pem&quot; my-instance-user-name@my-instance-public-dns-name</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H0USTG34j9dI_EV9s-vnNQ.png" /><figcaption>Terminal Example</figcaption></figure><blockquote><strong>Replace</strong> “my-instance-user-name@my-instance-public-dns-name”<strong> </strong>with your <strong>host name</strong> and <strong>user name</strong> . You will find these details on <strong>AWS EC2 Dashboard</strong>. Go to EC2 <strong>dashboard</strong>. <strong>Click</strong> on your instance. <strong>Click</strong> on connect you will these find details in Example there .</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/691/1*ReZl8hmiByKn3450gIu25A.png" /></figure><blockquote>If this is the first time you have connected to this instance, It will displays a security alert Choose yes to connect to EC2 instance .</blockquote><blockquote>You are now connected to your EC2 Instance from Ubuntu .</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=da97c0cc9c8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to setup mysql database on AWS RDS ( Relational Database Service )]]></title>
            <link>https://rahul26021999.medium.com/how-to-setup-mysql-database-on-aws-rds-relational-database-service-f5a186ccbadb?source=rss-67485d4353ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/f5a186ccbadb</guid>
            <category><![CDATA[aws-free-tier]]></category>
            <category><![CDATA[relational-databases]]></category>
            <category><![CDATA[phpmyadmin]]></category>
            <category><![CDATA[aws-ec2]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Rahul Gupta]]></dc:creator>
            <pubDate>Sat, 27 Jun 2020 21:57:58 GMT</pubDate>
            <atom:updated>2021-05-09T01:00:28.645Z</atom:updated>
            <content:encoded><![CDATA[<p>In this Article we will learn how to setup a mysql database in AWS <strong>RDS<br></strong>and How to connect that database from phpmyadmin of our <strong>EC2</strong> instance or local Machine. All of this is <a href="http://aws.amazon.com/free/">free tier</a> eligible.</p><p><strong>Prerequisites<br></strong> Create a AWS Account .</p><h3><strong>Create a DB Instance on Amazon RDS</strong></h3><p>We will use Amazon RDS to create a <strong>MySQL</strong> DB Instance with <strong>db.t2.micro</strong> DB instance class, <strong>20 GB </strong>of storage and this is <a href="http://aws.amazon.com/free/">free tier</a> eligible.<br><br>The Amazon <strong>RDS Free Tier</strong> is available to you for <strong>12 months</strong>.</p><ul><li>750 hrs per month of Amazon RDS in a Single-AZ db.t2.micro Instance.</li><li>20 GB per month of General Purpose Storage (SSD).</li><li>20 GB per month for automated backup storage and any user-initiated DB Snapshots.</li></ul><h3>Steps to create a DB Instance</h3><p>1. Login with your AWS Account and go to <strong>console.</strong></p><p>2. Search for <strong>RDS</strong> in Services and go to RDS .</p><p>3. In the top right corner of the Amazon RDS console, select the <em>Region </em>in which you want to create the DB instance . (optional)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*QCJrvQGqwxR8nxsM.png" /></figure><p>4. Click on <strong>Create Database</strong> in Create Database Section on Dashboard.</p><p>5. Choose <strong>Standard</strong> <strong>Create</strong> to configure db Instance .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/804/1*mSw4jmcMl0Fdk8mML0dltA.png" /></figure><p>6. Choose <strong>MYSQL</strong> in Engine options and <strong>Free Tier</strong> in Templates.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/773/1*s-3gTBEHAGYz3RovfDOANg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/766/1*pf_gutA_24aRM5ODpQZX9w.png" /></figure><p>7. Configure a <strong>DB instance name</strong> and <strong>credentials settings.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/762/1*6D9L2OAxWB5-Bad3bx8D8g.png" /></figure><p>8. <strong>Disable</strong> Storage auto scaling in storage Section .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/759/1*3rsB9T8aBG1XAbvjkvHArg.png" /></figure><p>9. <strong>Change</strong> you Additional <strong>connectivity</strong> <strong>configurations</strong> . Public Accessible to <strong>yes</strong> to access the Database from <strong>local</strong> <strong>machine</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/596/1*633n0Ymrmvtyb97-Rb7Pig.png" /></figure><p>10 . Set Database Authentication to <strong>Password</strong> Authentication</p><p>11. Now Coming towards <strong>Additional Configuration</strong></p><p>a ) Enter a <strong>Initial</strong> Database name</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/680/1*8_tFxUh9nWzFQ868wh6rkw.png" /></figure><p>b) Enable <strong>Automatic Backups</strong> and Backup <strong>retention period</strong> to 1 or 2 days and Disable Monitoring.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/747/1*RycxBlPHOQ4Wybh05cnfUg.png" /></figure><p>d) Enable <strong>All Log exports.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/377/1*UMeU0ot3LILFko1ZaNmGZA.png" /></figure><p>e) Enable <strong>auto minor version upgrade</strong> and <strong>Delete Protection</strong> also . This will not allow anyone to delete the Db instance Directly .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/686/1*vwGcOVAYeLyAhVNsFeOZjQ.png" /></figure><p>12. Click on <strong>create Database</strong></p><p>Here , you are done with setting a MYSQL database in Amazon RDS (Free Tier Eligible ) .</p><h4>How to Access mysql Database from phpmyadmin in local Machine or EC2 Instance .</h4><blockquote>To access the db instance from your local machine you have to allow the public accessibility option to yes in step 9. And also the Security group rules in your Db instance should look like this .</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/993/1*OfxuHpWzLqOxX1GtBoG4Ig.png" /></figure><p>Now open phpmyadmin config.inc.php in your machine or EC2 instance to connect with your database server .</p><p>Open /etc/phpmyadmin/config.inc.php to add DB Instance to phpmyadmin</p><pre>$ sudo vi /etc/phpmyadmin/config.inc.php</pre><p>Add the below Line at the end of config.inc.php</p><pre>$i++;<br>$cfg[&#39;Servers&#39;][$i][&#39;host&#39;]          = &#39;ENDPOINT_HERE&#39;;<br>$cfg[&#39;Servers&#39;][$i][&#39;port&#39;]          = &#39;3306&#39;;<br>$cfg[&#39;Servers&#39;][$i][&#39;socket&#39;]        = &#39;&#39;;<br>$cfg[&#39;Servers&#39;][$i][&#39;connect_type&#39;]  = &#39;tcp&#39;;<br>$cfg[&#39;Servers&#39;][$i][&#39;extension&#39;]     = &#39;mysql&#39;;<br>$cfg[&#39;Servers&#39;][$i][&#39;compress&#39;]      = FALSE;<br>$cfg[&#39;Servers&#39;][$i][&#39;auth_type&#39;]     = &#39;config&#39;;<br>$cfg[&#39;Servers&#39;][$i][&#39;user&#39;]          = &#39;root&#39;<br>$cfg[&#39;Servers&#39;][$i][&#39;password&#39;]      = &#39;PASSWORD_HERE&#39;;</pre><p>Replace “<strong>ENDPOINT_HERE<em>”</em> </strong>and “<strong>PASSWORD_HERE</strong>” with your credentials.</p><p><strong>For Endpoint</strong> : Go To databases on RDS. Click on your db instance and you will find your DB Endpoints in <strong>Connectivity &amp; security.</strong></p><p><strong>For Password</strong> : Use your db password that you have used in Step 7 ( Configure a DB instance name and <strong>credentials settings</strong>.<strong> </strong>) while creating a Database Instance .</p><p><strong>Note</strong> : You can use your credentials with any software that connects to your database instance . i.e. <a href="https://www.jetbrains.com/datagrip/">DataGrip</a> , <a href="https://dev.mysql.com/downloads/workbench/">MySQL Workbench</a> ,etc .</p><h3><strong>References</strong></h3><ol><li><a href="https://aws.amazon.com/getting-started/hands-on/create-mysql-db/">https://aws.amazon.com/getting-started/hands-on/create-mysql-db/</a></li><li><a href="https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_MySQL.html">https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_MySQL.html</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f5a186ccbadb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How To Deploy Laravel Project on EC2 AWS .]]></title>
            <link>https://rahul26021999.medium.com/how-to-deploy-laravel-project-on-ec2-aws-6d004a57bb1f?source=rss-67485d4353ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/6d004a57bb1f</guid>
            <category><![CDATA[laravel-development]]></category>
            <category><![CDATA[laravel]]></category>
            <category><![CDATA[aws-ec2]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[deploy]]></category>
            <dc:creator><![CDATA[Rahul Gupta]]></dc:creator>
            <pubDate>Sat, 27 Jun 2020 17:01:56 GMT</pubDate>
            <atom:updated>2021-09-29T12:11:03.405Z</atom:updated>
            <content:encoded><![CDATA[<h3>How To Deploy Laravel Project on EC2 AWS .</h3><p>In this Article , We will Learn How to deploy a laravel project on AWS EC2 (Elastic Cloud Computing ) Instance .</p><p><strong>Prerequisites</strong></p><p>Create a Ubuntu Server On AWS EC2 Instance.<br>If not created yet ?<strong> </strong><a href="https://medium.com/@rahul26021999/how-to-create-a-ubuntu-20-04-server-on-aws-ec2-elastic-cloud-computing-5b423b5bf635"><strong>Learn How to Create a Ubuntu 20.04 Server on AWS EC2 (Elastic Cloud Computing)</strong></a></p><h3>Steps To deploy Laravel Project on EC2</h3><p>Connect to EC2 instance using your private key ( Key Pair ). <br><a href="https://medium.com/@rahul26021999/how-to-connect-to-ec2-instance-aws-from-windows-ubuntu-da97c0cc9c8">Learn How to Connect to your EC2 Instance</a> .</p><h4><strong>Update your Libraries</strong></h4><pre>$ sudo apt-get update</pre><h4><strong>Install Apache2</strong></h4><pre>$ sudo apt-get install apache2</pre><p>Now copy the IPv4 Public IP Address of your EC2 instance and hit on the browser. If you see a screen something like below , you are good to go. Apache server is working!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7wwp_vyk3qeTkLghR8PKFQ.png" /></figure><h4><strong>Install PHP and useful packages</strong></h4><pre>$ sudo apt-get install php</pre><pre>$ php --version</pre><pre>$ sudo apt-get install php7.4-cli php7.4-common php7.4-curl php7.4-gd php7.4-json php7.4-mbstring php7.4-intl php7.4-mysql php7.4-xml php7.4-zip</pre><p>Usually, when a user requests a directory from the web server, Apache will first look for a file named <strong>index.html</strong>. If you want to change Apache to serve php files rather than others, move <strong>index.php</strong> to first position in the <strong>dir.conf</strong> file as shown below.</p><pre>$ sudo vi /etc/apache2/mods-enabled/dir.conf</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/879/1*wInQPCivfCempNvNbNLPsQ.png" /></figure><h4>Install MySQL Server</h4><pre>$ sudo apt-get install mysql-server</pre><p>This will install mysql server but this will not prompt anything to configure mysql .</p><h4>Configuring MySQL</h4><pre>$ sudo mysql_secure_installation</pre><p>This way you can make some changes to your MySQL installation’s security options.</p><p>Note that even though you’ve set a password for the <strong>root</strong> MySQL user, this user is not configured to authenticate with a password when connecting to the MySQL shell because it uses auth_socket by default .</p><p>In order to use a password to connect to MySQL as <strong>root</strong>, you will need to switch its authentication method from auth_socket to mysql_native_password by using following commands.</p><pre>$ sudo mysql</pre><p>To configure the <strong>root</strong> account to authenticate with a password, run the following ALTER USER command. Note that this command will change the <strong>root</strong> password you set in <strong>mysql_secure_installation .</strong></p><pre>mysql&gt; ALTER USER &#39;root&#39;@&#39;localhost&#39; IDENTIFIED WITH mysql_native_password BY &#39;yourpassword&#39;;</pre><p>Then, run FLUSH PRIVILEGES which tells the server to reload the grant tables and put your new changes into effect:</p><pre>FLUSH PRIVILEGES;</pre><p>Now You are done with setting up your mysql server on your EC2. you can use your credentials in your laravel project.</p><h4><strong>Install Composer</strong></h4><pre>$ php -r &quot;copy(&#39;https://getcomposer.org/installer&#39;, &#39;composer-setup.php&#39;);&quot;</pre><pre>$ php -r &quot;if (hash_file(&#39;sha384&#39;, &#39;composer-setup.php&#39;) === &#39;e0012edf3e80b6978849f5eff0d4b4e4c79ff1609dd1e613307e16318854d24ae64f26d17af3ef0bf7cfb710ca74755a&#39;) { echo &#39;Installer verified&#39;; } else { echo &#39;Installer corrupt&#39;; unlink(&#39;composer-setup.php&#39;); } echo PHP_EOL;&quot;</pre><pre>$ php composer-setup.php</pre><pre>$ php composer-setup.php --install-dir=bin --filename=composer</pre><pre>$ php -r &quot;unlink(&#39;composer-setup.php&#39;);&quot;</pre><pre>$ composer --version<br></pre><h4><strong>Install Git</strong></h4><pre>$ sudo apt-get install git-core</pre><h4><strong>Clone Your Repository</strong></h4><p>Change to <strong>/var/www/html</strong> directory and clone your Laravel Project there using following commands.</p><pre>$ cd /var/www/html</pre><pre>$ sudo git clone <a href="https://github.com/rahul26021999/Prepareurself.git">https://github.com/username/reponame.git</a></pre><pre>$ cd reponame</pre><h4><strong>Adding .env File to your Laravel project</strong></h4><pre>$ sudo vi .env</pre><h4><strong>Installing Libraries In Project</strong></h4><pre>$ sudo composer install</pre><h4><strong>Read Write Permissions for your Project</strong></h4><pre>sudo chmod 777 -R storage/<br>sudo chmod 777 -R bootstrap/</pre><h4><strong>Apache Configuration</strong></h4><p>By Default Apache open /var/www/html/index.html Now we have to open our Laravel project when we go to the public IP of the EC2. <br>Go to /etc/apache2/sites-available/000-default.conf and change the DocumentRoot as shown below.</p><pre>$ sudo vi /etc/apache2/sites-available/000-default.conf</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/682/1*25KAlZHqeG6H8iK22_3fRw.png" /></figure><h4>Restart your Apache</h4><pre>$ sudo systemctl restart apache2</pre><p>Now you have successfully deployed your laravel Project on AWS , <br>Which you can easily access through your public IPV4 IP Address.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6d004a57bb1f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>