<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title></title>
	<atom:link href="https://codekosh.com/feed/" rel="self" type="application/rss+xml" />
	<link>https://codekosh.com/</link>
	<description></description>
	<lastBuildDate>Tue, 05 Aug 2025 18:45:25 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://codekosh.com/wp-content/uploads/2025/08/Fav-ico-150x150.jpg</url>
	<title></title>
	<link>https://codekosh.com/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>How to Use custom Shortcodes to Render Elementor Saved Templates</title>
		<link>https://codekosh.com/how-to-use-custom-shortcodes-to-render-elementor-saved-templates/</link>
					<comments>https://codekosh.com/how-to-use-custom-shortcodes-to-render-elementor-saved-templates/#respond</comments>
		
		<dc:creator><![CDATA[Shubham Rana]]></dc:creator>
		<pubDate>Mon, 23 Dec 2024 11:34:59 +0000</pubDate>
				<category><![CDATA[Core Php]]></category>
		<category><![CDATA[Elementor]]></category>
		<category><![CDATA[WordPress]]></category>
		<guid isPermaLink="false">https://codekosh.com/?p=1061</guid>

					<description><![CDATA[<p>Elementor is one of the most popular page builders used in the wordpress, but its free version doesn’t allow you [&#8230;]</p>
<p>The post <a href="https://codekosh.com/how-to-use-custom-shortcodes-to-render-elementor-saved-templates/">How to Use custom Shortcodes to Render Elementor Saved Templates</a> appeared first on <a href="https://codekosh.com"></a>.</p>
]]></description>
										<content:encoded><![CDATA[		<div data-elementor-type="wp-post" data-elementor-id="1061" class="elementor elementor-1061">
				<div class="elementor-element elementor-element-68c8d42 e-flex e-con-boxed e-con e-parent" data-id="68c8d42" data-element_type="container" data-e-type="container">
					<div class="e-con-inner">
				<div class="elementor-element elementor-element-5fdfcfd elementor-widget elementor-widget-text-editor" data-id="5fdfcfd" data-element_type="widget" data-e-type="widget" data-widget_type="text-editor.default">
				<div class="elementor-widget-container">
									<p>Elementor is one of the most popular page builders used in the wordpress, but its free version doesn’t allow you to use saved templates via shortcodes. Luckily, with a bit of custom code, you can achieve this functionality and make your templates reusable throughout your site.</p>								</div>
				</div>
				<div class="elementor-element elementor-element-db87d93 elementor-widget elementor-widget-heading" data-id="db87d93" data-element_type="widget" data-e-type="widget" data-widget_type="heading.default">
				<div class="elementor-widget-container">
					<h3 class="elementor-heading-title elementor-size-default">What Are Shortcodes in WordPress?
</h3>				</div>
				</div>
				<div class="elementor-element elementor-element-bdf138b elementor-widget elementor-widget-text-editor" data-id="bdf138b" data-element_type="widget" data-e-type="widget" data-widget_type="text-editor.default">
				<div class="elementor-widget-container">
									<p>Shortcodes are small pieces of code that allow you to insert dynamic content into WordPress pages or posts. The shortcode will be dynamically renders a saved Elementor template with the template ID.</p>								</div>
				</div>
				<div class="elementor-element elementor-element-75196ad elementor-widget elementor-widget-heading" data-id="75196ad" data-element_type="widget" data-e-type="widget" data-widget_type="heading.default">
				<div class="elementor-widget-container">
					<h3 class="elementor-heading-title elementor-size-default">Step-by-Step Guide to Render Elementor Saved Templates</h3>				</div>
				</div>
				<div class="elementor-element elementor-element-58a2e47 elementor-widget elementor-widget-text-editor" data-id="58a2e47" data-element_type="widget" data-e-type="widget" data-widget_type="text-editor.default">
				<div class="elementor-widget-container">
									Step 1: Create a custom function in your active theme file <strong>functions.php</strong> file.

Copy the below code and add in your <strong>functions.php</strong> file.								</div>
				</div>
				<div class="elementor-element elementor-element-045499b elementor-widget elementor-widget-html" data-id="045499b" data-element_type="widget" data-e-type="widget" data-widget_type="html.default">
				<div class="elementor-widget-container">
					<pre>
function codekosh_render_elementor_template($atts) {
    $atts = shortcode_atts(
        array(
            'id' => '',
        ),
        $atts,
        'elementor_template'
    );

    $template_id = intval($atts['id']);

    // Prevent recursion or invalid ID
    if (!$template_id || get_the_ID() == $template_id) {
        return '<!-- Invalid or Recursive Template Call -->';
    }

    // Make sure Elementor is loaded
    if (!did_action('elementor/loaded')) {
        return '<!-- Elementor not loaded -->';
    }

    // Enqueue necessary frontend assets (important for guests)
    Elementor\Plugin::$instance->frontend->enqueue_styles();
    Elementor\Plugin::$instance->frontend->enqueue_scripts();

    // Buffer output to return as shortcode
    ob_start();
    echo Elementor\Plugin::$instance->frontend->get_builder_content_for_display($template_id);
    return ob_get_clean();
}
add_shortcode('elementor_template', 'codekosh_render_elementor_template');

</pre>				</div>
				</div>
				<div class="elementor-element elementor-element-0798f16 elementor-widget elementor-widget-text-editor" data-id="0798f16" data-element_type="widget" data-e-type="widget" data-widget_type="text-editor.default">
				<div class="elementor-widget-container">
									<p>Step 2: Create and Save an Elementor Template.</p><ul><li>Go to Templates &gt; Saved Templates in the WordPress admin area.</li><li>Click Add New, design your section, and save it.</li></ul>								</div>
				</div>
				<div class="elementor-element elementor-element-8c7d9ab elementor-widget elementor-widget-image" data-id="8c7d9ab" data-element_type="widget" data-e-type="widget" data-widget_type="image.default">
				<div class="elementor-widget-container">
												<figure class="wp-caption">
											<a href="https://codekosh.com/wp-content/uploads/2024/12/image_2024_12_23T12_29_14_677Z.jpg" data-elementor-open-lightbox="yes" data-elementor-lightbox-title="image_2024_12_23T12_29_14_677Z" data-e-action-hash="#elementor-action%3Aaction%3Dlightbox%26settings%3DeyJpZCI6MTA4MSwidXJsIjoiaHR0cHM6XC9cL2NvZGVrb3NoLmNvbVwvd3AtY29udGVudFwvdXBsb2Fkc1wvMjAyNFwvMTJcL2ltYWdlXzIwMjRfMTJfMjNUMTJfMjlfMTRfNjc3Wi5qcGcifQ%3D%3D">
							<img fetchpriority="high" decoding="async" width="1024" height="405" src="https://codekosh.com/wp-content/uploads/2024/12/image_2024_12_23T12_29_14_677Z-1024x405.jpg" class="attachment-large size-large wp-image-1081" alt="" srcset="https://codekosh.com/wp-content/uploads/2024/12/image_2024_12_23T12_29_14_677Z-1024x405.jpg 1024w, https://codekosh.com/wp-content/uploads/2024/12/image_2024_12_23T12_29_14_677Z-300x119.jpg 300w, https://codekosh.com/wp-content/uploads/2024/12/image_2024_12_23T12_29_14_677Z-768x304.jpg 768w, https://codekosh.com/wp-content/uploads/2024/12/image_2024_12_23T12_29_14_677Z-1536x607.jpg 1536w, https://codekosh.com/wp-content/uploads/2024/12/image_2024_12_23T12_29_14_677Z.jpg 1920w" sizes="(max-width: 1024px) 100vw, 1024px" />								</a>
											<figcaption class="widget-image-caption wp-caption-text"></figcaption>
										</figure>
									</div>
				</div>
				<div class="elementor-element elementor-element-016a840 elementor-widget elementor-widget-text-editor" data-id="016a840" data-element_type="widget" data-e-type="widget" data-widget_type="text-editor.default">
				<div class="elementor-widget-container">
									<ul><li>Note down the Template ID from the template list.</li></ul>								</div>
				</div>
				<div class="elementor-element elementor-element-a7f4012 elementor-widget elementor-widget-image" data-id="a7f4012" data-element_type="widget" data-e-type="widget" data-widget_type="image.default">
				<div class="elementor-widget-container">
												<figure class="wp-caption">
											<a href="https://codekosh.com/wp-content/uploads/2024/12/image_2024_12_23T12_37_03_600Z.png" data-elementor-open-lightbox="yes" data-elementor-lightbox-title="image_2024_12_23T12_37_03_600Z" data-e-action-hash="#elementor-action%3Aaction%3Dlightbox%26settings%3DeyJpZCI6MTA4MCwidXJsIjoiaHR0cHM6XC9cL2NvZGVrb3NoLmNvbVwvd3AtY29udGVudFwvdXBsb2Fkc1wvMjAyNFwvMTJcL2ltYWdlXzIwMjRfMTJfMjNUMTJfMzdfMDNfNjAwWi5wbmcifQ%3D%3D">
							<img decoding="async" width="1024" height="562" src="https://codekosh.com/wp-content/uploads/2024/12/image_2024_12_23T12_37_03_600Z-1024x562.png" class="attachment-large size-large wp-image-1080" alt="" srcset="https://codekosh.com/wp-content/uploads/2024/12/image_2024_12_23T12_37_03_600Z-1024x562.png 1024w, https://codekosh.com/wp-content/uploads/2024/12/image_2024_12_23T12_37_03_600Z-300x165.png 300w, https://codekosh.com/wp-content/uploads/2024/12/image_2024_12_23T12_37_03_600Z-768x421.png 768w, https://codekosh.com/wp-content/uploads/2024/12/image_2024_12_23T12_37_03_600Z-1536x842.png 1536w, https://codekosh.com/wp-content/uploads/2024/12/image_2024_12_23T12_37_03_600Z-2048x1123.png 2048w" sizes="(max-width: 1024px) 100vw, 1024px" />								</a>
											<figcaption class="widget-image-caption wp-caption-text"></figcaption>
										</figure>
									</div>
				</div>
				<div class="elementor-element elementor-element-7cccfd3 elementor-widget elementor-widget-text-editor" data-id="7cccfd3" data-element_type="widget" data-e-type="widget" data-widget_type="text-editor.default">
				<div class="elementor-widget-container">
									<p>Step 3: Use the Shortcode</p><ul><li>Add the following shortcode wherever you want the saved template to appear as I have used under the elementor tabbing widget:</li></ul>								</div>
				</div>
				<div class="elementor-element elementor-element-e61b13a elementor-widget elementor-widget-image" data-id="e61b13a" data-element_type="widget" data-e-type="widget" data-widget_type="image.default">
				<div class="elementor-widget-container">
												<figure class="wp-caption">
											<a href="https://codekosh.com/wp-content/uploads/2024/12/image_2024_12_23T12_52_03_700Z.jpg" data-elementor-open-lightbox="yes" data-elementor-lightbox-title="image_2024_12_23T12_52_03_700Z" data-e-action-hash="#elementor-action%3Aaction%3Dlightbox%26settings%3DeyJpZCI6MTA4NCwidXJsIjoiaHR0cHM6XC9cL2NvZGVrb3NoLmNvbVwvd3AtY29udGVudFwvdXBsb2Fkc1wvMjAyNFwvMTJcL2ltYWdlXzIwMjRfMTJfMjNUMTJfNTJfMDNfNzAwWi5qcGcifQ%3D%3D">
							<img decoding="async" width="1024" height="394" src="https://codekosh.com/wp-content/uploads/2024/12/image_2024_12_23T12_52_03_700Z-1024x394.jpg" class="attachment-large size-large wp-image-1084" alt="" srcset="https://codekosh.com/wp-content/uploads/2024/12/image_2024_12_23T12_52_03_700Z-1024x394.jpg 1024w, https://codekosh.com/wp-content/uploads/2024/12/image_2024_12_23T12_52_03_700Z-300x115.jpg 300w, https://codekosh.com/wp-content/uploads/2024/12/image_2024_12_23T12_52_03_700Z-768x296.jpg 768w, https://codekosh.com/wp-content/uploads/2024/12/image_2024_12_23T12_52_03_700Z-1536x591.jpg 1536w, https://codekosh.com/wp-content/uploads/2024/12/image_2024_12_23T12_52_03_700Z.jpg 1920w" sizes="(max-width: 1024px) 100vw, 1024px" />								</a>
											<figcaption class="widget-image-caption wp-caption-text"></figcaption>
										</figure>
									</div>
				</div>
				<div class="elementor-element elementor-element-8622f0e elementor-widget elementor-widget-text-editor" data-id="8622f0e" data-element_type="widget" data-e-type="widget" data-widget_type="text-editor.default">
				<div class="elementor-widget-container">
									<ul><li>Replace the ID of your saved template in the ShortCode.</li></ul>								</div>
				</div>
					</div>
				</div>
				</div>
		<p>The post <a href="https://codekosh.com/how-to-use-custom-shortcodes-to-render-elementor-saved-templates/">How to Use custom Shortcodes to Render Elementor Saved Templates</a> appeared first on <a href="https://codekosh.com"></a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://codekosh.com/how-to-use-custom-shortcodes-to-render-elementor-saved-templates/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to create the first react app</title>
		<link>https://codekosh.com/how-to-create-the-first-react-app/</link>
					<comments>https://codekosh.com/how-to-create-the-first-react-app/#respond</comments>
		
		<dc:creator><![CDATA[Shubham Rana]]></dc:creator>
		<pubDate>Sun, 16 Jun 2024 08:30:40 +0000</pubDate>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[React Js]]></category>
		<guid isPermaLink="false">https://codekosh.com/?p=726</guid>

					<description><![CDATA[<p>Introduction: Codekosh Solutions has the best tutorials for React app creation. Today we will explain to you how to create [&#8230;]</p>
<p>The post <a href="https://codekosh.com/how-to-create-the-first-react-app/">How to create the first react app</a> appeared first on <a href="https://codekosh.com"></a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><strong>Introduction:</strong></p>
<p>Codekosh Solutions has the best tutorials for React app creation.<br />
Today we will explain to you how to create the React app.</p>
<p>React is a popular JavaScript framework used to build front-end applications. Developed by Facebook, React has made its strong presence in the dev community to build fast applications using an intuitive programming paradigm that ties JavaScript with an HTML-like syntax – JSX.</p>
<p>In short, ReactJs is a popular and widely used front-end library application system for developing single-page applications. Since it’s a library, we can install this library to Create React App for developing single-page applications.</p>
<p>Create React App is a tool or generator for new developers, allowing them to develop and execute React projects. You don’t have to configure it manually. In other words, you don’t have to worry about configuring a build system like Webpack. You don’t have to worry about most of the complicated systems of modern front-end development. You can start the React code with basic knowledge of Javascript.</p>
<p><strong>Requirements:</strong></p>
<p>You need the following things to start the React application.<br />
&#8212; Need to install the Node.js and NPM on your desktop. For Windows users, you can download the Node at <a href="https://nodejs.org/" target="_blank" rel="noopener">Node.org</a>.<br />
&#8212; For the MAC/Linux you can use the commands to install the node.js in your machine.</p>
<p>For the MAC users, I recommended installing the &#8220;Homebrew&#8221; (if you haven&#8217;t already) to install the Node.js.<br />
&#8212; Open your terminal and run the following command to install Homebrew:</p>
<pre>/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"</pre>
<p>&#8212; Install Node.js using the Homebrew library:</p>
<pre> brew install node</pre>
<p>&#8212; Verify the Node.js installation:</p>
<pre>node -v 
npm -v</pre>
<p>For Linux users open your terminal and you can install the Node.js by following commands:<br />
&#8212; Update your package list command:</p>
<pre> sudo apt update</pre>
<p>&#8212; To Install Node.js and npm from the default Ubuntu repository:</p>
<pre> sudo apt install nodejs npm</pre>
<p>Verify the installation:<br />
Check the installed versions of Node.js and npm:</p>
<pre>node -v 
 npm -v</pre>
<p>This will show you your machine&#8217;s installed version of Node and NPM.</p>
<p><strong>Steps to Create Your New React App</strong><br />
&#8212; Open your terminal to install the base project, run the following command:</p>
<p><img loading="lazy" decoding="async" class="alignnone wp-image-731" src="https://codekosh.com/wp-content/uploads/2024/06/image_2024_06_16T08_55_37_377Z-300x37.png" alt="" width="534" height="66" /></p>
<pre> npx create-react-app codekosh-react-tutorials</pre>
<p><img loading="lazy" decoding="async" class="alignnone wp-image-732" src="https://codekosh.com/wp-content/uploads/2024/06/image_2024_06_16T09_01_09_958Z-300x217.jpg" alt="" width="537" height="388" /></p>
<p>&#8212; Now your base project is set up in the new directory as we are using the &#8220;codekosh-react-tutorials&#8221; You can give any name to your base project directory.</p>
<p>&#8212; Now go to the directory where you set up the base react app using the below command.<br />
<img loading="lazy" decoding="async" class="alignnone wp-image-736" src="https://codekosh.com/wp-content/uploads/2024/06/image_2024_06_16T09_17_44_321Z-300x48.png" alt="" width="544" height="87" srcset="https://codekosh.com/wp-content/uploads/2024/06/image_2024_06_16T09_17_44_321Z-300x48.png 300w, https://codekosh.com/wp-content/uploads/2024/06/image_2024_06_16T09_17_44_321Z-1024x164.png 1024w, https://codekosh.com/wp-content/uploads/2024/06/image_2024_06_16T09_17_44_321Z-768x123.png 768w, https://codekosh.com/wp-content/uploads/2024/06/image_2024_06_16T09_17_44_321Z-1536x246.png 1536w, https://codekosh.com/wp-content/uploads/2024/06/image_2024_06_16T09_17_44_321Z.png 1826w" sizes="(max-width: 544px) 100vw, 544px" /></p>
<pre>cd codekosh-react-tutorials</pre>
<p><strong>Starting the React App Development Server:</strong><br />
&#8212; To run your React project you need to execute the below command:<br />
<img loading="lazy" decoding="async" class="alignnone wp-image-735" src="https://codekosh.com/wp-content/uploads/2024/06/image_2024_06_16T09_20_00_589Z-300x48.png" alt="" width="544" height="87" /></p>
<pre> npm start</pre>
<p>When we run codekosh-react-tutorials, we just have to run npm start in the app directory to start serving the development server. We will see a new browser opening with localhost:3000.</p>
<p><img loading="lazy" decoding="async" class="alignnone wp-image-733" src="https://codekosh.com/wp-content/uploads/2024/06/image_2024_06_16T09_25_47_919Z-300x143.png" alt="" width="548" height="261" /></p>
<p>Browser view:</p>
<p><img loading="lazy" decoding="async" class="alignnone wp-image-741" src="https://codekosh.com/wp-content/uploads/2024/06/image_2024_06_16T10_01_23_549Z-300x216.png" alt="" width="544" height="392" /></p>
<p><strong>See React in Action</strong></p>
<p>Did you notice something interesting in this react js app creation tutorial guide?</p>
<p>You have just created your first React Project using React developer tools without getting much into the technical details.<br />
Isn’t it the beauty of Create React App?</p>
<p>It’s not necessary to know everything to create a React app. It gives us the freedom to avoid the complex steps involved in writing React code.</p>
<p>Now you know how to start, test, and build a Create project. Consider these commands and understand their usage, as you will need them for your project development.<br />
We hope this article turned out to be beneficial!</p>
<p>Happy coding!</p>
<p>The post <a href="https://codekosh.com/how-to-create-the-first-react-app/">How to create the first react app</a> appeared first on <a href="https://codekosh.com"></a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://codekosh.com/how-to-create-the-first-react-app/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to Create a Subdomain in DigitalOcean</title>
		<link>https://codekosh.com/how-to-create-a-subdomain-in-digitalocean/</link>
					<comments>https://codekosh.com/how-to-create-a-subdomain-in-digitalocean/#respond</comments>
		
		<dc:creator><![CDATA[Shubham Rana]]></dc:creator>
		<pubDate>Mon, 13 May 2024 05:54:14 +0000</pubDate>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<guid isPermaLink="false">https://codekosh.com/?p=512</guid>

					<description><![CDATA[<p>While using a cloud server, It always very difficult to set up a domain or sub-domain in the digital ocean, [&#8230;]</p>
<p>The post <a href="https://codekosh.com/how-to-create-a-subdomain-in-digitalocean/">How to Create a Subdomain in DigitalOcean</a> appeared first on <a href="https://codekosh.com"></a>.</p>
]]></description>
										<content:encoded><![CDATA[<p class="top-content">While using a cloud server, It always very difficult to set up a domain or sub-domain in the digital ocean, Google Cloud and AWS. In given few steps I will explain to you how easily you can set up a sub-domain with your active domain in digital Ocean server.</p>
<h2>Setup Sub – Domain in Digital Ocean:</h2>
<ol>
<li style="list-style-type: none;">
<ol>
<li>Login to your digital ocean account.</li>
<li>Click on the domain – e.g I want to make portfolio.codekosh.com – so I m click on codekosh.com from added domain list. As I have marked in reg.<br />
<img loading="lazy" decoding="async" class="alignnone wp-image-523" src="https://codekosh.com/wp-content/uploads/2024/05/select-a-domain-from-domain-list-300x118.jpg" alt="" width="516" height="203" /></li>
<li>Now you need to add the &#8220;A&#8221; record and CNAME record.<br />
A record e.g: <strong>portfolio and </strong>CNMAE <strong>www.portfolio</strong><strong> </strong>and point to your droplet.<img loading="lazy" decoding="async" class=" wp-image-527" src="https://codekosh.com/wp-content/uploads/2024/05/create-your-a-record-300x154.jpg" alt="Create your A record" width="516" height="265" /><br />
Create your <strong>CNAME </strong>record.<br />
<img loading="lazy" decoding="async" class="alignnone wp-image-531" src="https://codekosh.com/wp-content/uploads/2024/05/create-your-cname-record-300x154.jpg" alt="" width="518" height="266" /></li>
</ol>
</li>
</ol>
<h2 class="HeadingStyles__StyledH1-sc-73f0758c-0 gOvywW TutorialTemplate___StyledHeading2-sc-64c15beb-1 kQEzBT">How To Set Up Apache Virtual Hosts on Ubuntu</h2>
<p>Setting up Apache virtual hosts on Ubuntu allows you to host multiple websites on a single server, each with its own domain or subdomain. This setup is particularly useful for web developers, businesses, or individuals who want to run multiple websites through domain and subdomain on the same server without conflicts. Here&#8217;s a comprehensive guide to walk you through the process by <a href="https://codekosh.com/development/how-to-create-a-subdomain-in-digitalocean/">codekosh.com.</a></p>
<h3>Step 1: Install Apache</h3>
<p>If Apache isn&#8217;t already installed on your Ubuntu server, you can install it using the following below commands.</p>
<pre><code>sudo apt update
sudo apt install apache2</code></pre>
<h3>Step 2 — Creating the Directory Structure</h3>
<p class="common">Step to create a directory structure that will hold the site data that you will be serving to visitors.</p>
<p class="common">Your document root, the top-level directory that Apache looks at to find content to serve, will be set to individual directories under the <strong>/var/www</strong> directory. You will create a directory here for each of the virtual hosts.</p>
<p class="common">Create a directory structure to store the website files for each virtual host. Within each of these directories, you will create a <strong>public_html</strong> directory. The <strong>public_html</strong> directory contains the content that will be served to your visitors.</p>
<p class="common">Use this command, with your own domain name, to create your directories.</p>
<pre>sudo mkdir -p /var/www/example.com/public_html</pre>
<p class="common">Replace example.com with your domain name.</p>
<h3>Step 3: Assign Permissions</h3>
<p class="common">You’ve created the directory structure for your files, but they are owned by the root user. If you want your regular user to be able to modify files in these web directories, you can change the ownership with this command.</p>
<pre>sudo chown -R $USER:$USER /var/www/example.com/public_html</pre>
<p class="common">The <strong>$USER</strong>&gt; variable will take the value of the user you are currently logged in as when you press ENTER in terminal. By doing this, the regular user now owns the <strong>public_html</strong> subdirectories where you will be storing your content.</p>
<p class="common">You should also modify your permissions to ensure that read access is permitted to the general web directory and all of the files and folders it contains so that the pages can be served correctly.</p>
<pre>sudo chmod -R 755 /var/www</pre>
<p class="common">Your web server now has the permissions it needs to serve content, and your user should be able to create content within the necessary folders. The next step is to create content for your virtual host sites.</p>
<h3>Step 4: Create Sample HTML File for host (Optional)</h3>
<p class="common">With your directory structure in place, you can start focusing on individual virtual host site and the content within that site. Start by creating an <strong>index.html</strong> page for your subdomain <strong>e.g <a href="https://codekosh.com/">portfolio.codekosh.com</a></strong>.</p>
<p class="common">Run this command to open and create the <strong>index.html</strong>. This example uses nano:</p>
<pre>nano /var/www/subdomain.example.com/public_html/index.html</pre>
<p class="common">You can add some html stuff in your <strong>index.html</strong> file to load the file in broswer by your subdomain.</p>
<p class="common">To save and close the <strong>index.html</strong> file in nano, start by pressing <strong>CTRL+X</strong>. Press <strong>Y</strong> when prompted to save the file, then press <strong>ENTER</strong> when you are finished to exit.</p>
<h3>Step 5: Creating New Virtual Host File</h3>
<p class="common">Apache on Ubuntu uses separate configuration files for each virtual host. You can create a new configuration file for each site in the <strong>/etc/apache2/sites-available/</strong> directory.</p>
<pre>sudo nano /etc/apache2/sites-available/subdomain.example.com.conf</pre>
<p class="common">Enter the following configuration in the config file:</p>
<pre>	
	    ServerAdmin admin@example.com
	    ServerName example.com
	    ServerAlias www.yoursubdomain.example.com
	    DocumentRoot /var/www/yoursubdomain.example.com/public_html
	    ErrorLog ${APACHE_LOG_DIR}/error.log
	    CustomLog ${APACHE_LOG_DIR}/access.log combined
	
</pre>
<p class="common">Save and close the file.</p>
<h3>Step 6: Enable the Virtual Host file</h3>
<p class="common">In previous step that we have created the virtual host file, you must enable them. Apache includes some tools that allow you to do this.</p>
<p class="common">You’ll be using the <strong>a2ensite</strong> tool to enable each of your sites.</p>
<pre>sudo a2ensite subdomain.example.com.conf</pre>
<p class="common">Before reloading your server, you have to disable the default site defined in <strong>000-default.conf</strong> by using the <strong>a2dissite</strong> command.</p>
<pre>sudo a2dissite 000-default.conf</pre>
<p class="common">Next, command to test the configuration errors:</p>
<pre>sudo apache2ctl configtest</pre>
<p class="common">When you are finished the above process, restart Apache to make these changes take effect.</p>
<pre>sudo systemctl restart apache2</pre>
<p class="common">Optionally, you can check the status of the server after all these changes with this below command.</p>
<pre>sudo systemctl status apache2</pre>
<p class="common">That&#8217;s it! You should now be able to access your website using the subdomain name you configured. Repeat steps 2-6 for each additional virtual host you want to set up.</p>
<p>The post <a href="https://codekosh.com/how-to-create-a-subdomain-in-digitalocean/">How to Create a Subdomain in DigitalOcean</a> appeared first on <a href="https://codekosh.com"></a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://codekosh.com/how-to-create-a-subdomain-in-digitalocean/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
