{"id":21,"date":"2009-07-29T23:32:36","date_gmt":"2009-07-30T05:32:36","guid":{"rendered":"http:\/\/blog.supportpro.com\/?p=21"},"modified":"2023-07-27T02:10:24","modified_gmt":"2023-07-27T08:10:24","slug":"brief-intro-about-cphulk-mod_userdir-open_basedir","status":"publish","type":"post","link":"https:\/\/www.supportpro.com\/blog\/brief-intro-about-cphulk-mod_userdir-open_basedir\/","title":{"rendered":"Brief intro about mod_userdir | open_basedir"},"content":{"rendered":"<p><span style=\"text-decoration: underline;\"><strong>mod_userdir<\/strong><\/span><\/p>\n<p>It is an Apache module that allows you to create a separate website for each user on a server. These sites can all be accessed by going to,<\/p>\n<p><em>http:\/\/servername.com\/~username<\/em><\/p>\n<p><em>Eg:- http:\/\/example.com\/~user\/<\/em><\/p>\n<p>The module is installed on most Apache setups by default, but isnt necessarily always enabled. Most mass-hosted cPanel servers make extensive use of it for a variety of reasons.<\/p>\n<p>Apaches mod_userdir allows users to view their sites by entering a tilde(~) and their username as the URL on a specific host. For example http:\/\/test.cpanel.net\/~test will bring up the user Tests domain<\/p>\n<p><strong><span style=\"text-decoration: underline;\">How To Enable<\/span> <\/strong><\/p>\n<p>1. To access the Server Setup Menu, click on Server Setup, on the main screen of your WebHost Manager interface. Then, click on Tweak Security.<\/p>\n<p>2. Click on Configure in the mod_userdir Tweak section.<\/p>\n<p>3. Click on the Checkbox next to Enable mod_userdir Protection to enable mod_userdir Protection.<\/p>\n<p>4. Click on a checkbox next to a domains name to allow them to access their domain using ~username, if necessary.<\/p>\n<p>5. Enter the name of any user you wish to be able access the domain using ~username, other than the domains owner, in the blank field next to the domains name, if necessary.<\/p>\n<p>6. Click on Save.<\/p>\n<p><span style=\"text-decoration: underline;\"><strong>Disadvantage <\/strong><\/span><\/p>\n<p>The disadvantage of this feature is that any bandwidth usage used by the site will be put on the domain it is accessed under .<\/p>\n<p>Mod_userdir protection prevents access to a domain through domain.com\/~user. You may however want to disable it on specific virtual hosts (generally shared SSL hosts).<\/p>\n<p><span style=\"text-decoration: underline;\"><strong>open_basedir<\/strong><\/span><\/p>\n<p><span style=\"text-decoration: underline;\"><strong>Enable open_basedir<\/strong><\/span><\/p>\n<p>Set open_basedir to only allow access to required portions of the filesystem, like your web sites documents and any shared libraries.<\/p>\n<p>You can set open_basedir in the php.ini file:<\/p>\n<p><em>; Set open_basedir to the <\/em><\/p>\n<p><em>open_basedir = \/var\/www\/foo.bar\/:\/usr\/local\/php\/<\/em><\/p>\n<p>The setting can also be applied in apaches httpd.conf file, or an .htaccess file:<\/p>\n<p># Set open_basedir to a safe location<\/p>\n<p><em>php_value open_basedir \/var\/www\/foo.bar\/:\/usr\/local\/php<\/em><\/p>\n<p><span style=\"text-decoration: underline;\"><strong>WHM<\/strong><\/span><\/p>\n<p>Steps :<\/p>\n<p>1. To access the PHP open_basedir Tweak feature, click on Security, on the main screen of your WebHost Manager interface.<\/p>\n<p>2. Then click on Security Center.<\/p>\n<p>3. Then click on PHP open_basedir Tweak.<\/p>\n<p>4. Click on Configure in the PHPs open_basedir section.<\/p>\n<p>5. Click on the check box next to Enable PHP open_basedir Protection to enable Enable PHP open_basedir Protection.<\/p>\n<p>6. Click on a check box next to a domain name to allow them to open files outside of their home directory with PHP, if necessary.<\/p>\n<p>7. Click on Save.<br \/>\n<strong>Plesk : <\/strong>If you&#8217;re using Plesk hosting control panel, you may need to manually edit Apache configuration file of vhost.conf and vhost_ssl.conf, and add in or edit the following php_admin_value open_basedir lines to the following:<\/p>\n<p>&lt;Directory \/full\/path\/to\/the\/directory\/httpdocs&gt;<\/p>\n<p>php_admin_value open_basedir none<\/p>\n<p>&lt;\/Directory&gt;<\/p>\n<p>&lt;Directory \/full\/path\/to\/the\/directory\/httpdocs&gt;<\/p>\n<p>php_admin_value open_basedir \/full\/path\/to\/dir:\/full\/path\/to\/directory\/httpdocs:\/tmp<\/p>\n<p>&lt;\/Directory&gt;<br \/>\nNote: For SSL hosts in the vhost_ssl.conf file, the Directory path will end with httpsdocs instead of httpdocs<\/p>\n<p><span style=\"text-decoration: underline;\"><strong>Disable Manually<\/strong><\/span><\/p>\n<p>Open up the httpd.conf file, and search for the lines that starts with the following characters:<\/p>\n<p>php_admin_value open_basedir ..<\/p>\n<p>Replace the whole line under the virtual host for the domain user account<\/p>\n<p>php_admin_value open_basedir none.<\/p>\n<p><span style=\"text-decoration: underline;\"><strong>Add Additional Directories<\/strong><\/span><br \/>\nYou can also opt to allow your PHP scripts to access additional directory instead without disabling the protection.For example, to add \/new_directory to the allow list.<\/p>\n<p>php_admin_value open_basedir \/home\/user_account\/:\/usr\/lib\/php:\/usr\/local\/lib\/php:\/tmp<\/p>\n<p>php_admin_value open_basedir \/home\/user_account\/:\/usr\/lib\/php:\/usr\/local\/lib\/php:\/tmp:\/new_directory<\/p>\n<p>Restart the Apache after finished editing<\/p>\n<p><strong>Article Authored by Ajith KK<\/strong><\/p>\n<p><strong>Author, Ajith KK, is a Systems Engineer with SupportPRO. Ajith specializes in L1 and L2 Linux\/Windows administration. SupportPRO offers 24X7 technical support services to <a href=\"https:\/\/www.supportpro.com\/plans.php\">Web hosting<\/a> companies and service providers.<\/strong><\/p>\n<p>If you require help, c<a href=\"https:\/\/www.supportpro.com\/requestquote.php\">ontact SupportPRO Server Admin<\/a><\/p>\n<p style=\"text-align: center;\"><!--HubSpot Call-to-Action Code --><span id=\"hs-cta-wrapper-9d590242-d641-4383-94b4-8cfd62f0af6b\" class=\"hs-cta-wrapper\"><span id=\"hs-cta-9d590242-d641-4383-94b4-8cfd62f0af6b\" class=\"hs-cta-node hs-cta-9d590242-d641-4383-94b4-8cfd62f0af6b\"><!-- [if lte IE 8]><\/p>\n\n\n\n\n\n<div id=\"hs-cta-ie-element\"><\/div>\n\n\n<![endif]--><a href=\"https:\/\/cta-redirect.hubspot.com\/cta\/redirect\/2725694\/9d590242-d641-4383-94b4-8cfd62f0af6b\"><img decoding=\"async\" id=\"hs-cta-img-9d590242-d641-4383-94b4-8cfd62f0af6b\" class=\"hs-cta-img\" style=\"border-width: 0px;\" src=\"https:\/\/no-cache.hubspot.com\/cta\/default\/2725694\/9d590242-d641-4383-94b4-8cfd62f0af6b.png\" alt=\"Server not running properly? Get A FREE Server Checkup By Expert Server Admins - $125 Value\" \/><\/a><\/span><script charset=\"utf-8\" src=\"https:\/\/js.hscta.net\/cta\/current.js\"><\/script><script type=\"text\/javascript\"> hbspt.cta.load(2725694, '9d590242-d641-4383-94b4-8cfd62f0af6b', {}); <\/script><\/span><!-- end HubSpot Call-to-Action Code --><\/p>\n","protected":false},"excerpt":{"rendered":"<p>mod_userdir It is an Apache module that allows you to create a separate website for each user on a server. These sites can all be accessed by going to, http:\/\/servername.com\/~username&hellip;<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_lmt_disableupdate":"","_lmt_disable":"","footnotes":""},"categories":[5,1],"tags":[],"class_list":["post-21","post","type-post","status-publish","format-standard","hentry","category-general-topics","category-miscellaneous"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/posts\/21","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/comments?post=21"}],"version-history":[{"count":9,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/posts\/21\/revisions"}],"predecessor-version":[{"id":13222,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/posts\/21\/revisions\/13222"}],"wp:attachment":[{"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/media?parent=21"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/categories?post=21"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/tags?post=21"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}