{"id":9352,"date":"2022-04-21T09:16:13","date_gmt":"2022-04-21T09:16:13","guid":{"rendered":"https:\/\/cpanelplesk.com\/wp62\/?p=9352"},"modified":"2022-04-21T09:16:13","modified_gmt":"2022-04-21T09:16:13","slug":"how-can-change-the-root-directory-by-using-symbolic-links","status":"publish","type":"post","link":"https:\/\/cpanelplesk.com\/wp62\/how-can-change-the-root-directory-by-using-symbolic-links\/","title":{"rendered":"How can change the Root Directory by Using Symbolic Links"},"content":{"rendered":"<p><span style=\"font-weight: 400\">This article explains how to alter a shared server account&#8217;s document root directory. The default document root directory for your account is \/home\/username\/public_html, where username is your account username. However, you might want to use a different directory as the document root on occasion. For example, if you want to try out a new application or test a website configuration before it goes live, this is frequently the case.<\/span><\/p>\n<p><span style=\"font-weight: 400\">To modify the document root directory, This approach makes use of symbolic links and necessitates the use of SSH.\u00a0<\/span><\/p>\n<p><span class=\"text-info\" style=\"font-weight: 400\">Do not use the techniques below if you want to alter the document root directory for an addon domain. Instead, utilize cPanel to update the document root directory for the addon domain.<\/span><\/p>\n<h3><b>Using Symbolic Links<\/b><\/h3>\n<p><span style=\"font-weight: 400\">By copying the contents of the public_html directory to another directory and then creating a symbolic link that refers public_html to the new document root directory, you can alter the document root directory. Follow these steps to accomplish this:<\/span><\/p>\n<ul>\n<li><span style=\"font-weight: 400\">Use SSH to access your account.<\/span><\/li>\n<li><span style=\"font-weight: 400\">Type the following command at the command prompt:<\/span><\/li>\n<\/ul>\n<div class=\"command-sh\">\n<pre>mv ~\/public_html ~\/public_html_backup<\/pre>\n<\/div>\n<ul>\n<li>This command copies the contents of the public_html directory, including all files, to the public_html backup directory. If you choose, you can call it something other than public_html backup.<\/li>\n<li><span style=\"font-weight: 400\">You must perform the next command in step 3 as soon as possible after running this command for two reasons. First, as long as public_html is absent, your site is unreachable. Second, if the public_html directory is absent, cPanel will automatically recreate it. Your site will not perform as expected if you have not run the command in step 3 before this happens.<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400\">Replace new document root with the name of the directory you wish to use as the new document root in the following command:<\/span><\/p>\n<div class=\"command-sh\">\n<pre>ln -s ~\/new_document_root ~\/public_html<\/pre>\n<\/div>\n<p><span style=\"text-decoration: underline\">To test your website, use a web browser. Content from the new document root directory should be displayed in the browser.<\/span><\/p>\n<p><span style=\"font-weight: 400\">If your website isn&#8217;t working properly, you should:<\/span><\/p>\n<ul>\n<li><span style=\"font-weight: 400\">Ascertain that the new document root directory is present and contains web site files (such as index.html or index.php).<\/span><\/li>\n<li><span style=\"font-weight: 400\">Make that the commands in steps 2 and 3 are executed in quick succession. Type the following command to see if the symbolic link is correct:<\/span><\/li>\n<\/ul>\n<div class=\"command-sh\">\n<pre>ls -l ~\/public_html<\/pre>\n<\/div>\n<p>You should get something that looks like this, where username is your account username:<\/p>\n<div class=\"command-sh\">\n<pre>\/home\/username\/public_html -&gt; \/home\/username\/new_document_root<\/pre>\n<\/div>\n<p>If the result isn&#8217;t similar, the symbolic link isn&#8217;t set up appropriately. Type the following command in the prompt:<\/p>\n<div class=\"command-sh\">\n<pre>rm -rf ~\/public_html\r\n<\/pre>\n<\/div>\n<p><em>Now, repeat steps 2 and 3.<\/em><\/p>\n<h3><b>Restoring the public_html Directory<\/b><\/h3>\n<p><span style=\"font-weight: 400\">By reversing the technique you followed above, you may get back to the original setup and utilize the public_html directory as the document root.<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u00a0Follow these steps to accomplish this:<\/span><\/p>\n<ul>\n<li><span style=\"font-weight: 400\">Use SSH to access your account.<\/span><\/li>\n<li><span style=\"font-weight: 400\">Type the following at the command prompt:<\/span><\/li>\n<\/ul>\n<div class=\"command-sh\">\n<pre>rm ~\/public_html<\/pre>\n<\/div>\n<ul>\n<li>The symbolic link that redirects public_html to the updated document root directory is removed with this command.<\/li>\n<li><span style=\"font-weight: 400\">You must perform the next command in step 3 as soon as possible after running this command for two reasons. First, as long as public_html is absent, your site is unreachable. Second, if the public_html directory is absent, cPanel will automatically recreate it. Your site will not perform as expected if you have not run the command in step 3 before this happens.<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400\">Replace source directory with the name of the directory you want to use as public_html in the following command. This directory might be the public_html backup directory you established in the previous procedure, the new document root directory you used for testing, or something completely different:<\/span><\/p>\n<div class=\"command-sh\">\n<pre>mv ~\/source_directory ~\/public_html<\/pre>\n<\/div>\n<p class=\"text-info\">To test your website, use a web browser. Content from the public html directory should be displayed by the browser.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This article explains how to alter a shared server account&#8217;s document root directory. The default document root directory for your account is \/home\/username\/public_html, where username is your account username. However, you might want to use a different directory as the document root on occasion. For example, if you want to try out a new application [&#8230;]<\/p>\n<p><a class=\"understrap-read-more-link\" href=\"https:\/\/cpanelplesk.com\/wp62\/how-can-change-the-root-directory-by-using-symbolic-links\/\">Continue Reading&#8230;<\/a><\/p>\n","protected":false},"author":19,"featured_media":9446,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,4,14],"tags":[],"class_list":["post-9352","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cpanel","category-general","category-linux"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How can change the Root Directory by Using Symbolic Links - cPanel Plesk<\/title>\n<meta name=\"description\" content=\"The default document root directory for your account is \/home\/username\/public_html, where username is your account username.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/cpanelplesk.com\/wp62\/how-can-change-the-root-directory-by-using-symbolic-links\/\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:title\" content=\"How can change the Root Directory by Using Symbolic Links - cPanel Plesk\" \/>\n<meta name=\"twitter:description\" content=\"The default document root directory for your account is \/home\/username\/public_html, where username is your account username.\" \/>\n<meta name=\"twitter:image\" content=\"https:\/\/cpanelplesk.com\/wp62\/wp-content\/uploads\/2022\/04\/symbolic.png\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"samama\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/how-can-change-the-root-directory-by-using-symbolic-links\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/how-can-change-the-root-directory-by-using-symbolic-links\/\"},\"author\":{\"name\":\"samama\",\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/b5c17eff2915a029433dfd2d5a6e8465\"},\"headline\":\"How can change the Root Directory by Using Symbolic Links\",\"datePublished\":\"2022-04-21T09:16:13+00:00\",\"dateModified\":\"2022-04-21T09:16:13+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/how-can-change-the-root-directory-by-using-symbolic-links\/\"},\"wordCount\":622,\"publisher\":{\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/c78ae1cf9451a09592fb9697d69c0c13\"},\"image\":{\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/how-can-change-the-root-directory-by-using-symbolic-links\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/cpanelplesk.com\/wp62\/wp-content\/uploads\/2022\/04\/symbolic.png\",\"articleSection\":[\"Cpanel\",\"General\",\"Linux\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/how-can-change-the-root-directory-by-using-symbolic-links\/\",\"url\":\"https:\/\/cpanelplesk.com\/wp62\/how-can-change-the-root-directory-by-using-symbolic-links\/\",\"name\":\"How can change the Root Directory by Using Symbolic Links - cPanel Plesk\",\"isPartOf\":{\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/how-can-change-the-root-directory-by-using-symbolic-links\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/how-can-change-the-root-directory-by-using-symbolic-links\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/cpanelplesk.com\/wp62\/wp-content\/uploads\/2022\/04\/symbolic.png\",\"datePublished\":\"2022-04-21T09:16:13+00:00\",\"dateModified\":\"2022-04-21T09:16:13+00:00\",\"description\":\"The default document root directory for your account is \/home\/username\/public_html, where username is your account username.\",\"breadcrumb\":{\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/how-can-change-the-root-directory-by-using-symbolic-links\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/cpanelplesk.com\/wp62\/how-can-change-the-root-directory-by-using-symbolic-links\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/how-can-change-the-root-directory-by-using-symbolic-links\/#primaryimage\",\"url\":\"https:\/\/cpanelplesk.com\/wp62\/wp-content\/uploads\/2022\/04\/symbolic.png\",\"contentUrl\":\"https:\/\/cpanelplesk.com\/wp62\/wp-content\/uploads\/2022\/04\/symbolic.png\",\"width\":1024,\"height\":538},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/how-can-change-the-root-directory-by-using-symbolic-links\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/cpanelplesk.com\/wp62\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How can change the Root Directory by Using Symbolic Links\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/#website\",\"url\":\"https:\/\/cpanelplesk.com\/wp62\/\",\"name\":\"cPanel Plesk\",\"description\":\"Blog on famous hosting control panels\",\"publisher\":{\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/c78ae1cf9451a09592fb9697d69c0c13\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/cpanelplesk.com\/wp62\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/c78ae1cf9451a09592fb9697d69c0c13\",\"name\":\"Farooq Omer\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/cpanelplesk.com\/wp62\/wp-content\/uploads\/2020\/11\/cpanelplesk.png\",\"contentUrl\":\"https:\/\/cpanelplesk.com\/wp62\/wp-content\/uploads\/2020\/11\/cpanelplesk.png\",\"width\":300,\"height\":44,\"caption\":\"Farooq Omer\"},\"logo\":{\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/b5c17eff2915a029433dfd2d5a6e8465\",\"name\":\"samama\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/5ad71c1d187b45a3c1a68698160b5f6d?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/5ad71c1d187b45a3c1a68698160b5f6d?s=96&d=mm&r=g\",\"caption\":\"samama\"},\"url\":\"https:\/\/cpanelplesk.com\/wp62\/author\/samama\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How can change the Root Directory by Using Symbolic Links - cPanel Plesk","description":"The default document root directory for your account is \/home\/username\/public_html, where username is your account username.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/cpanelplesk.com\/wp62\/how-can-change-the-root-directory-by-using-symbolic-links\/","twitter_card":"summary_large_image","twitter_title":"How can change the Root Directory by Using Symbolic Links - cPanel Plesk","twitter_description":"The default document root directory for your account is \/home\/username\/public_html, where username is your account username.","twitter_image":"https:\/\/cpanelplesk.com\/wp62\/wp-content\/uploads\/2022\/04\/symbolic.png","twitter_misc":{"Written by":"samama","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/cpanelplesk.com\/wp62\/how-can-change-the-root-directory-by-using-symbolic-links\/#article","isPartOf":{"@id":"https:\/\/cpanelplesk.com\/wp62\/how-can-change-the-root-directory-by-using-symbolic-links\/"},"author":{"name":"samama","@id":"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/b5c17eff2915a029433dfd2d5a6e8465"},"headline":"How can change the Root Directory by Using Symbolic Links","datePublished":"2022-04-21T09:16:13+00:00","dateModified":"2022-04-21T09:16:13+00:00","mainEntityOfPage":{"@id":"https:\/\/cpanelplesk.com\/wp62\/how-can-change-the-root-directory-by-using-symbolic-links\/"},"wordCount":622,"publisher":{"@id":"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/c78ae1cf9451a09592fb9697d69c0c13"},"image":{"@id":"https:\/\/cpanelplesk.com\/wp62\/how-can-change-the-root-directory-by-using-symbolic-links\/#primaryimage"},"thumbnailUrl":"https:\/\/cpanelplesk.com\/wp62\/wp-content\/uploads\/2022\/04\/symbolic.png","articleSection":["Cpanel","General","Linux"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/cpanelplesk.com\/wp62\/how-can-change-the-root-directory-by-using-symbolic-links\/","url":"https:\/\/cpanelplesk.com\/wp62\/how-can-change-the-root-directory-by-using-symbolic-links\/","name":"How can change the Root Directory by Using Symbolic Links - cPanel Plesk","isPartOf":{"@id":"https:\/\/cpanelplesk.com\/wp62\/#website"},"primaryImageOfPage":{"@id":"https:\/\/cpanelplesk.com\/wp62\/how-can-change-the-root-directory-by-using-symbolic-links\/#primaryimage"},"image":{"@id":"https:\/\/cpanelplesk.com\/wp62\/how-can-change-the-root-directory-by-using-symbolic-links\/#primaryimage"},"thumbnailUrl":"https:\/\/cpanelplesk.com\/wp62\/wp-content\/uploads\/2022\/04\/symbolic.png","datePublished":"2022-04-21T09:16:13+00:00","dateModified":"2022-04-21T09:16:13+00:00","description":"The default document root directory for your account is \/home\/username\/public_html, where username is your account username.","breadcrumb":{"@id":"https:\/\/cpanelplesk.com\/wp62\/how-can-change-the-root-directory-by-using-symbolic-links\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/cpanelplesk.com\/wp62\/how-can-change-the-root-directory-by-using-symbolic-links\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/cpanelplesk.com\/wp62\/how-can-change-the-root-directory-by-using-symbolic-links\/#primaryimage","url":"https:\/\/cpanelplesk.com\/wp62\/wp-content\/uploads\/2022\/04\/symbolic.png","contentUrl":"https:\/\/cpanelplesk.com\/wp62\/wp-content\/uploads\/2022\/04\/symbolic.png","width":1024,"height":538},{"@type":"BreadcrumbList","@id":"https:\/\/cpanelplesk.com\/wp62\/how-can-change-the-root-directory-by-using-symbolic-links\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/cpanelplesk.com\/wp62\/"},{"@type":"ListItem","position":2,"name":"How can change the Root Directory by Using Symbolic Links"}]},{"@type":"WebSite","@id":"https:\/\/cpanelplesk.com\/wp62\/#website","url":"https:\/\/cpanelplesk.com\/wp62\/","name":"cPanel Plesk","description":"Blog on famous hosting control panels","publisher":{"@id":"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/c78ae1cf9451a09592fb9697d69c0c13"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/cpanelplesk.com\/wp62\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/c78ae1cf9451a09592fb9697d69c0c13","name":"Farooq Omer","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/image\/","url":"https:\/\/cpanelplesk.com\/wp62\/wp-content\/uploads\/2020\/11\/cpanelplesk.png","contentUrl":"https:\/\/cpanelplesk.com\/wp62\/wp-content\/uploads\/2020\/11\/cpanelplesk.png","width":300,"height":44,"caption":"Farooq Omer"},"logo":{"@id":"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/image\/"}},{"@type":"Person","@id":"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/b5c17eff2915a029433dfd2d5a6e8465","name":"samama","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/5ad71c1d187b45a3c1a68698160b5f6d?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/5ad71c1d187b45a3c1a68698160b5f6d?s=96&d=mm&r=g","caption":"samama"},"url":"https:\/\/cpanelplesk.com\/wp62\/author\/samama\/"}]}},"_links":{"self":[{"href":"https:\/\/cpanelplesk.com\/wp62\/wp-json\/wp\/v2\/posts\/9352","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cpanelplesk.com\/wp62\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cpanelplesk.com\/wp62\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cpanelplesk.com\/wp62\/wp-json\/wp\/v2\/users\/19"}],"replies":[{"embeddable":true,"href":"https:\/\/cpanelplesk.com\/wp62\/wp-json\/wp\/v2\/comments?post=9352"}],"version-history":[{"count":5,"href":"https:\/\/cpanelplesk.com\/wp62\/wp-json\/wp\/v2\/posts\/9352\/revisions"}],"predecessor-version":[{"id":9357,"href":"https:\/\/cpanelplesk.com\/wp62\/wp-json\/wp\/v2\/posts\/9352\/revisions\/9357"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cpanelplesk.com\/wp62\/wp-json\/wp\/v2\/media\/9446"}],"wp:attachment":[{"href":"https:\/\/cpanelplesk.com\/wp62\/wp-json\/wp\/v2\/media?parent=9352"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cpanelplesk.com\/wp62\/wp-json\/wp\/v2\/categories?post=9352"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cpanelplesk.com\/wp62\/wp-json\/wp\/v2\/tags?post=9352"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}