<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Abm Adnan Azmee</title>
    <description>The latest articles on DEV Community by Abm Adnan Azmee (@adnanazmee).</description>
    <link>https://dev.to/adnanazmee</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F431507%2F41be9a15-b792-4655-ab46-440702924afb.jpg</url>
      <title>DEV Community: Abm Adnan Azmee</title>
      <link>https://dev.to/adnanazmee</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/adnanazmee"/>
    <language>en</language>
    <item>
      <title>Deploying React App with Yarn on Apache Server, CentOS 7 ( Oracle Linux 7 )</title>
      <dc:creator>Abm Adnan Azmee</dc:creator>
      <pubDate>Tue, 12 Jan 2021 15:51:52 +0000</pubDate>
      <link>https://dev.to/adnanazmee/deploying-react-app-with-yarn-on-apache-server-centos-7-oracle-linux-7-2pp9</link>
      <guid>https://dev.to/adnanazmee/deploying-react-app-with-yarn-on-apache-server-centos-7-oracle-linux-7-2pp9</guid>
      <description>&lt;p&gt;This article focuses on the deployment of React JS project built using yarn command on Apache Server at CentOS 7 ( Oracle Linux 7 ).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Prerequisites&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;This tutorial assumes you have a working React JS project built using Yarn at your remote repository.&lt;/li&gt;
&lt;li&gt;You have &lt;em&gt;Apache Web Server&lt;/em&gt; installed in your CentOS 7. ( If you don't have it installed you can follow &lt;a href="https://www.digitalocean.com/community/tutorials/how-to-install-the-apache-web-server-on-centos-7"&gt;this&lt;/a&gt; article. )&lt;/li&gt;
&lt;li&gt;You have &lt;em&gt;Git&lt;/em&gt; installed in your CentOS 7. ( If you don't have it installed you can follow &lt;a href="https://www.digitalocean.com/community/tutorials/how-to-install-git-on-centos-7"&gt;this&lt;/a&gt; article. )&lt;/li&gt;
&lt;li&gt;You have &lt;em&gt;Yarn&lt;/em&gt; installed in your CentOS 7. ( If you don't have it installed you can follow &lt;a href="https://classic.yarnpkg.com/en/docs/install/#centos-stable"&gt;this&lt;/a&gt; article. )&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I recently created a React App using Yarn package manager on my Windows PC and deployed it on Apache Web Server at CentOS 7. During my deployment I couldn't find enough resources where they went through the whole process, that's why I am writing this article to help anyone in need.&lt;/p&gt;

&lt;p&gt;At first, in your CentOS 7 go to the directory where you are planning to keep the project and download it from your remote repository using the Terminal. Here the name of the project is "YourReactApp".&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git clone url_of_remote_repository/YourReactApp.git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Go inside your project directory and run the command &lt;strong&gt;yarn&lt;/strong&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd YourReactApp
yarn
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After running the command you will see the following.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yarn install v1.22.5
[1/4] Resolving packages...
[2/4] Fetching packages...
. 
.
[4/4] Building fresh packages...
Done in 535.39s.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run the command &lt;strong&gt;yarn build&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yarn build
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After the build is done, you will see a folder a named "build" is created in your project directory. Inside the build folder, you need to create a ".htaccess" file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd build
nano .htaccess
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add the following code snippet in the ".htaccess" file and save it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.html [QSA,L]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now copy the "build" folder and paste it inside "/var/www/html".&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo cp -rf build /var/www/html/build
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After copying the file you need to modify the "httpd.conf" file. You can find it in " /etc/httpd/conf/" directory.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;nano /etc/httpd/conf/httpd.conf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the "httpd.conf" file find the line "ServerName" and add your &lt;em&gt;DNS name&lt;/em&gt; or &lt;em&gt;IP address&lt;/em&gt;. In "&amp;lt;Directory&amp;gt;" add your content directory , which is "/var/www/html/build" in this case. In addition, change the "AllowOverride None" to "AllowOverride All" and save the file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;Directory "/var/www/html/build"&amp;gt;
    ...
    AllowOverride All
    ...
&amp;lt;/Directory&amp;gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Great! You are done with your configuration, now run the server with the following command :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo systemctl start httpd
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can see the status of your server with the following command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo systemctl status httpd
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When the server is running you will see &lt;em&gt;active&lt;/em&gt; status.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Output
Redirecting to /bin/systemctl status httpd.service
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
   Active: active (running) since Wed 2019-02-20 01:29:08 UTC; 5s ago
     Docs: man:httpd(8)
           man:apachectl(8)
 Main PID: 1290 (httpd)
   Status: "Processing requests..."
   CGroup: /system.slice/httpd.service
           ├─1290 /usr/sbin/httpd -DFOREGROUND
           ├─1291 /usr/sbin/httpd -DFOREGROUND
           ├─1292 /usr/sbin/httpd -DFOREGROUND
           ├─1293 /usr/sbin/httpd -DFOREGROUND
           ├─1294 /usr/sbin/httpd -DFOREGROUND
           └─1295 /usr/sbin/httpd -DFOREGROUND
...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Enjoy !!!&lt;/p&gt;

&lt;h4&gt;
  
  
  📫 Get in touch
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;LinkedIn - &lt;a href="https://linkedin.com/in/adnanazmee"&gt;Adnan Azmee&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Twitter - &lt;a href="https://twitter.com/AzmeeAdnan"&gt;@AzmeeAdnan&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;or give some ♥ on &lt;a href="//mailto:adnanazmee@gmail.com"&gt;mail&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>react</category>
      <category>apache</category>
      <category>centos7</category>
      <category>deployment</category>
    </item>
  </channel>
</rss>
