Javatpoint Logo
Javatpoint Logo

What Is Public_html directory?

On machines running Apache web servers, all HTML files and other web content that may be accessed online are kept under the directory named public html. Each page loads from the public html directory when a user visits a website on the Internet.

The folder containing all website files that will be displayed to a visitor to your website is called public html or public_html. It is placed in the directories of your website. What distinguishes this file from the others? The index file in that directory is typically opened by yoursite.com, and all the files in that directory may be open to the public. The HTTP protocol does not allow access to other directories (directories outside of the public html). The directory of www. serves as a shortcut to the public html directory as a whole. It means that accessing public html requires typing www.

What Is Public_html directory

Permissions for public html :

0750 permissions should always be set for the public html folder. The public html folder should have 0755 permissions on every folder inside. The public html folder's files should all have 0755 or 0644 permissions.

To guarantee the security of your website and all associated data, directory rights, such as Linux permissions, are crucial. Although permissions may vary depending on how your server is configured, in most cases, the following default permissions should be used:

  • The public html folder needs to have 750 permissions. In this instance, only the owner is able to read, write, and execute; everyone else is unable to do any of these things.
  • The public html folder should have 755 permissions for all of its subfolders. In addition to others being able to read and execute, owners can also write and read.
  • The permissions for files in the public html folder should be 644. Owners are literate (readers and writers), while others are not.

What should store in the public html folder?

Keep all of your website's files that are a part of your main domain in this folder (public html) which is where your main domain's files are kept. Every page that is loaded when a user accesses a website loads from the public html directory. Thus it is where you should store all of the website files that you want to show up when someone searches for your primary domain.

What should be kept out of public html?

The public html folder shouldn't contain any of the following: some PHP files, logs, emails (if an email server is hosted there), or any other files or scripts that are for service purposes and shouldn't be viewable as part of the content or be executable by users who aren't admins. For security reasons, it's also crucial to make sure that users cannot access any files or folders outside of public html and that they are not set to be public.

How is the public html folder accessed?

You can access the public html folder via the cPanel interface. For information on how to access your public html folder from your cPanel account, please refer to the instructions listed below.

  1. Enter your cPanel login
  2. Go to Files >> File Manager by selecting it.
  3. The public html folder is visible on your File Management

Extra Domains &Subdomains:

Moreover, you can make Subdomains and Addon domains, and they will make use of a subdirectory inside public html.

Examples:

A subfolder with the name /public html/addondomain.com/ can be used to create an Addon domain with the name addondomain.com (unless you specified otherwise). Alternatively, you could create a Subdomain named gatorhost.example.com and utilize a subfolder that looks something like /public html/gatorhost/.

The following examples are applicable if addondomain.com is defined as an addon domain and gatorhost.example.com is defined as a subdomain:

Change example.com to your account's primary domain (the one you originally signed up with unless you changed it). The extra domain you added in the "addon domains" section of cPanel should be substituted for addondomain.com.

The preferable option is a reseller, VPS, or dedicated hosting because you can keep each domain in its own cPanel and keep it separate from other domains if you do not want other domains to be subfolders of public html. As shared accounts only receive one cPanel, all addon domains are located inside the public html subdirectory.







Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA