Computer >> कंप्यूटर >  >> प्रोग्रामिंग >> HTML

WordPress फ़ाइल संरचना और डेटाबेस को समझने के लिए शुरुआती मार्गदर्शिका

सामान्य परिस्थितियों में, वर्डप्रेस फ़ाइल संरचना . के बारे में चिंतित होने की कोई वास्तविक आवश्यकता नहीं है . वर्डप्रेस में एक बेहतरीन wp-admin इंटरफ़ेस है जो आपको यह जाने बिना कि इंजन हुड के तहत कैसे काम करता है, अपनी साइट को चलाने पर ध्यान केंद्रित करने में सक्षम बनाता है।

हालांकि, आपकी साइट के नट और बोल्ट को जानना उपयोगी हो सकता है। यह विशेष रूप से सच है जब आप किसी अनपेक्षित समस्या का सामना कर रहे हों , और सभी सहायता किसी विशेष वर्डप्रेस फ़ाइल को संशोधित करने या डेटाबेस में एक मान को रीसेट करने के बारे में बात करती है।

शायद आप किसी समस्या का सामना नहीं कर रहे हैं लेकिन बैकअप या सुरक्षा के बारे में पढ़ रहे हैं। कोर फाइल्स और डेटाबेस, या wp-config.php और wp-uploads जैसे शब्दों का उल्लेख अक्सर संदर्भ में किया जाता है।

विषय की सूक्ष्म समझ हासिल करने के लिए इन शर्तों को समझना बेहद मददगार है और इस प्रकार अपनी साइट के लिए सर्वोत्तम संभव निर्णय लें

यदि आपके पास कभी इस तरह के प्रश्न हों:

  • कोर फाइलें क्या हैं?
  • प्लगइन्स और थीम कहाँ संग्रहीत हैं?
  • डेटाबेस में क्या शामिल है?
  • wp-uploads फ़ोल्डर एक सुरक्षा चिंता का विषय क्यों है?
  • WordPress फ़ाइल और फ़ोल्डर संरचनाएं क्या हैं?

आप सही जगह पर हैं। इस लेख में, हम आपको आपकी साइट के पर्दे के पीछे ले जाएंगे, ताकि आप विश्वास के साथ कह सकें कि आप वर्डप्रेस फ़ाइल और फ़ोल्डर संरचना को समझते हैं।

टीएल; डॉ वर्डप्रेस साइट के दो भाग होते हैं:फाइलें और डेटाबेस। ये दोनों आपकी साइट के कामकाज के लिए महत्वपूर्ण हैं। यदि आप समझते हैं कि वे कैसे काम करते हैं, तो आप एक पावर उपयोगकर्ता बन जाएंगे और इस प्रकार समस्याओं का निवारण करने और अपनी साइट के लिए अच्छे निर्णय लेने में सक्षम होंगे। आपके द्वारा किए जा सकने वाले सर्वोत्तम निर्णयों में से एक है अपनी वर्डप्रेस साइट की सुरक्षा करना। एक अच्छा सुरक्षा प्लगइन स्थापित करें और बैकअप में निवेश करें।

अक्सर, हम अपनी वेबसाइट में परिवर्तन करना चाहते हैं, और कैसे-कैसे लेख हमें हमारे साइट कोड में इधर-उधर देखने का निर्देश देते हैं। यदि यह पर्याप्त रूप से बुरा नहीं था, तो अपनी साइट की फ़ाइलों और फ़ोल्डरों पर एक नज़र डालने के लिए किसी FTP क्लाइंट या फ़ाइल प्रबंधक का उपयोग करना सभी काफी हैरान करने वाला लग सकता है।

प्रत्येक साइट फ़ोल्डर और फ़ाइल महत्वपूर्ण लगती है, और यह अक्सर होता है! गंभीर चेतावनियाँ जो कहती हैं कि छोटी से छोटी त्रुटि के परिणामस्वरूप साइट क्रैश हो सकती है, निशान से बहुत दूर नहीं हैं।

कहा जा रहा है, ज्ञान शक्ति है। वर्डप्रेस फ़ाइल और निर्देशिका संरचना को समझना आपकी वेबसाइट में परिवर्तन करने की आपकी क्षमता में विश्वास पैदा करने में एक लंबा रास्ता तय करेगा, या वास्तव में छोटी समस्याओं का निवारण करेगा। सभी मामलों में, हम दृढ़ता से अनुशंसा करते हैं कि आप अपनी साइट के साथ छेड़छाड़ करने से पहले हमेशा बैकअप लें।

WordPress फ़ाइल और निर्देशिका संरचना को समझना

वर्डप्रेस फ़ाइल और फ़ोल्डर संरचना आपकी साइट का इंजन है। फ़ाइलों में कोड होता है जो आपकी साइट को शक्ति प्रदान करता है। चूंकि इसमें से अधिकांश अदृश्य है - जैसा कि होना चाहिए - यह समझने में थोड़ा भ्रमित करने वाला हो सकता है और कार के हुड के नीचे देखने जैसा है।

वर्डप्रेस रूट निर्देशिका

वर्डप्रेस का उपयोग करने के लिए, आपको पहले इसे अपने सर्वर पर स्थापित करना होगा। जब आप पहली बार वेब होस्ट खाता बनाते हैं तो अधिकांश वेब होस्ट आपके लिए यह स्वचालित रूप से करेंगे। वैकल्पिक रूप से, आप वर्डप्रेस डाउनलोड कर सकते हैं, और इसे स्वयं सर्वर पर अपलोड कर सकते हैं।

एक इंस्टॉलेशन का मतलब है कि सभी मूल वर्डप्रेस फाइलों की एक नई स्थापना आपके सर्वर पर डाल दी गई है। यह आपकी साइट का आधार है।

आमतौर पर, वर्डप्रेस इंस्टॉलेशन एक public_html . में जाएगा या सार्वजनिक फ़ोल्डर। इस फ़ोल्डर को वर्डप्रेस रूट निर्देशिका, या बस रूट के रूप में जाना जाता है, और वह जगह है जहां आपको वर्डप्रेस कोर फाइलें और फ़ोल्डर्स मिलेंगे। फ़ोल्डर को पूरी तरह से कुछ और कहा जा सकता है, लेकिन अक्सर यह public_html फ़ोल्डर होगा। It is worth knowing which folder is the root, as it is an important location for several site admin tasks, like migration or backups.

The WordPress root directory contains the following files and folders:

  • wp-admin
  • wp-content
  • wp-includes
  • .htaccess
  • index.php
  • license.txt
  • readme.html
  • wp-active.php
  • wp-blog-header.php
  • wp-comments-post.php
  • wp-config-sample.php
  • wp-cron.php
  • wp-links-opml.php
  • wp-load.php
  • wp-login.php
  • wp-mail.php
  • wp-settings.php
  • wp-signup.php
  • wp-trackback.php
  • xmlrpc.php
  • wp-feed.php

WordPress core files and folders

WordPress Core files and folders are those installed during the WordPress installation. These files power everything from the login page and the admin dashboard, to the database connection and managing users. There are 2 core WordPress folders:wp-admin and wp-includes , and several core files.

wp-admin folder

As the name suggests, this folder manages the entire experience of your WordPress wp-admin dashboard. There are seven folders in the wp-admin folder as follows:

  • css
  • images
  • includes
  • js
  • maint
  • network
  • user

There are lots of files too, the important ones being:

  • admin.php – core file that manages the wp-admin dashboard
  • index.php – loads pages in response to visitor requests
  • install.php – installs WordPress
  • plugins.php – controls all the plugins, active or inactive
  • themes.php – controls all the installed themes
  • users.php – manages users and their permissions

Most of the files are fairly self-explanatory as to their function. Essentially, all the WordPress folders and files within the wp-admin folder centre around the admin.php file , which controls the dashboard and all the functionality within it.

wp-includes folder

wp-includes contains all the core software for your WordPress site . You’ll see this referred to in a variety of ways:packages, code libraries, and WordPress source code. The nomenclature isn’t important here, but the code is critical.

Therefore, it is inadvisable to modify anything in the wp-includes directory ever, because it can and will break your site. Plus, there is no good reason to do so. Rarely will you come across a tutorial that advises you to alter any of the code contained in the wp-includes folder.

The one possible exception to this rule is the functions.php फ़ाइल। The functions.php file contains all the code for all the functions on your site. It is a special case because it works in tandem with the functions.php file that exists in your active theme as well. Typically, things like Google Analytics code and other tracker code are added to the theme’s functions.php file, but are liable to get lost if the theme is changed. That’s why you may come across advice to add the tracking code to the core functions.php file instead. However, we recommend against changing anything in the core files. You can always copy code from an old theme to a new theme easily, without endangering your entire site.

We strongly recommend against making changes to WordPress core files and folders, because they control your site. Even small errors can lead to your site crashing completely. If at all you absolutely must make changes, please make sure to take a full site backup just before. In any event, every time WordPress is updated, these files are overwritten, and any changes you do make will be lost.

WordPress core files

In the root folder, you will also see several files. While all of them are important, some of them are worth noting.

index.php

An index.php file is responsible for showing your site in response to a visitor request. It initialises and loads the right core files when a page is requested. This concept is better understood by seeing what happens when there isn’t an index file.

If your root folder didn’t have an index file, when someone tries to visit your site, the contents of the root folder will be displayed on the browser. Apart from the terrible unintended user experience, this is also a security issue.

The index file is a directory-level file and will be visible in most folders and sub-folders. For instance, it also exists in the wp-content folder. If that file was missing, the contents of the folder would be visible. As it stands, a blank white screen is shown instead.

Apart from the one in the root folder, the index.php file is often a blank file with a single-line comment:“Silence is golden.”

WordPress configuration files

There is a special subset of core files known as configuration files. Configuration files are the only core files that you can reasonably expect to edit. That is not to say that they aren’t equally important as the other core files, however, there is certain site functionality that you can only toggle from within a configuration file.

Ideally, you should use a plugin wherever possible to make these changes. For instance, it is vastly better and easier to use a plugin to implement geo-blocking, rather than modifying the .htaccess file. However, if you are creating a multisite, then you would need to add code to the configuration files manually during the network setup.

wp-config.php

The wp-config file is used to store database connection info, security keys and salts, and the database prefix . It is often targeted by hackers for this reason, as the database credentials are stored in cleartext, as are the security keys and salts.

Security keys and salts are an encryption mechanism used by WordPress to authenticate logged-in users securely. We have a step-by-step guide on how to change your security keys and salts, in case you think that a user account has been compromised.

The wp-config file also contains the built-in WordPress debugging feature . By default, the debugging feature is disabled. Once enabled from the wp-config file, it will show all errors, warnings, and notices. This is different from typical behaviour which may only show critical errors or fatal errors.

In a lot of security articles, you will see advice to move the wp-config file to another location, out of the root. But this is of limited value, because every WordPress site has a wp-config file somewhere in the installation, and a determined hacker with requisite access will find it eventually. A better way to secure your WordPress site is to install a security plugin; preferably one with a good firewall.

.htaccess

The .htaccess file is another important configuration file that is used to manage site links. Things like permalink structure, URL redirects, IP address blocking , and so on are managed by the .htaccess file. For instance, if you ever want to implement geoblocking manually, you will need to modify the .htaccess file, although we definitely don’t recommend it. In addition to links, the .htaccess file can also be used to password-protect your site.

Both the .htaccess and the wp-config files are generated on WordPress installation, and thus would not be visible in a downloaded installation package. Even once installed, the .htaccess file is hidden. To be able to see it, enable the option to view hidden files on your FTP client.

The .htaccess file is a configuration file specifically for Apache web servers. Some web hosts use nginx instead of Apache servers, so there will be no .htaccess file for your site altogether.

wp-content folder

Plugin and theme files and folders are, as the names suggest, installed with plugins and themes. For instance, if you install a contact form plugin, the code for that plugin will be in these files. Similarly, with the theme; the code for displaying images and fonts are in these files.

All plugins and themes are generally found in the wp-content folder, unless in special circumstances. For example, a firewall plugin would be located at the root level, so it loads before the rest of the site. This concept is known as load order, which is often seen in relation to WordPress security.

Each plugin or theme will mostly have its own folder with the files it needs to function correctly. In fact, plugin and theme installation files can be uploaded via FTP directly to the wp-content folder and then unzipped there.

Themes

Plugins have enormous variety, so rarely conform to a template. Themes, on the other hand, usually affect the same elements of a site, so they can look quite similar at a code level.

For instance, every theme has a functions.php file . We briefly referred to this while speaking about the functions.php file in the wp-includes folder. The theme functions.php file contains all the code needed to execute the theme. It also often has the extra code needed to run analytics and trackers on your site. When changing over to a new theme, you need to backup the functions.php file to make sure that you don’t lose any of that customisation.

Interestingly, although a WordPress site will work without a single plugin—albeit be very boring—it cannot function without a theme. The active theme is indicated in a required field in the database and has to be available for the site to load at all.

wp-uploads

The wp-uploads folder is where the files that visitors upload to the site are stored. It correlates directly to everything visible in the site’s media library. The files are stored in yearly and then monthly folders for retrieval.

The wp-uploads folder is universally accessible by default, so it often poses a security risk. This is why the folder shouldn’t have any executable files ever.

It is important to remember that we are talking about the boilerplate installation of WordPress. Since customisation of plugins, themes, and of WordPress itself can vary significantly from site to site, this is by no means an exhaustive list. The WordPress codex has a full list of WordPress files that come with the basic installation.

You may or may not see some of the files in the folders as described above, depending on how the installation is configured. Alternatively, you may not see the .htaccess file in your FTP client, because it is a hidden file. You will need to enable that setting to see it.

Understanding WordPress database tables

A database is a system used to store, organize, and retrieve data to run your website. Along with the files, it forms the other crucial part of your site. The WordPress database is used to store user-generated content like posts, pages, comments, etc. in tables.

Note:this is often the reason why advice on how to backup your WordPress site often suggests you backup only the database, assuming you can download everything else. This is not good practice, as you should always backup your entire site.

WordPress uses a MySQL database to store site information in tables, SQL commands to manipulate the data within, and the programming language PHP to communicate between the files and database. Therefore, when you install WordPress for the first time, during the installation you will need to create a MySQL user for the database. And, as we will see later, you can use an interface like phpMyAdmin or Adminer to access your site’s database.

Each site has a single associated database, and each database consists of multiple tables. The core WordPress tables are:

  • wp_options
  • wp_users
  • wp_usermeta
  • wp_posts
  • wp_postmeta
  • wp_terms
  • wp_term_relationships
  • wp_term_taxonomy
  • wp_comments
  • wp_commentmeta
  • wp_links

These tables are installed with WordPress. Over the course of time, as the site grows and plugins are added, the database grows with more tables and therefore more data.

The important thing to remember is that the tables often work in tandem with each other. That means data can be drawn from different tables. For instance, comments on posts are stored in the wp_comments table, but wp_commentmeta also is important for retrieval. This is especially true for WooCommerce sites, where order and product data is stored across multiple tables.

We have a full article with more information on how the WordPress database functions.

How to access the WordPress files, directories, and database

Your WordPress site is stored on a web host server, which is essentially a remote computer. To access the WordPress file structure and database, you need to connect to this computer. There are several ways to do this though. Each method has its pros and cons, so it is worth reading about all the methods and deciding which one works best for you.

cPanel

The most common method talked about in WordPress tutorials is to use cPanel. cPanel is a control panel software offered by most web hosts. It has a variety of tools for different tasks. The ones that we are most interested in for the purposes of viewing WordPress files and the database are the File Manager and phpMyAdmin क्रमश।

To access cPanel on your site, enter yourdomain.com in the URL bar, followed by /cpanel. Login with cPanel credentials, which are different from your wp-admin ones.

Under the Files section, you will find an icon for File Manager.

File Manager is a bit like your computer’s file explorer. You will see WordPress folders and files in a similar interface. To edit any of the files, you need to download them, edit them on your local machine, and then reupload them to the correct folder, after deleting the existing file.

To access the database, look for the phpMyAdmin icon under the Databases section on cPanel.

phpMyAdmin is separate from cPanel, so the icon is merely a shortcut to access it. If you aren’t logged in automatically, you can find the database login credentials in the wp-config.php file.

Under the Databases tab or from the left side panel, find the database that is associated with your site if there is more than one database.

Clicking on your database will open it to display all the tables within. Further, clicking on a table name will display the rows and values.

Some web hosts don’t provide cPanel, and may have an alternative control panel software like Plesk or Webmin. Others may not have any options at all, in which case you would need to use FTP to access your site files.

FTP/SFTP

File Transfer Protocol or FTP is an alternative to HTTP. We are all familiar with HTTP, which is a protocol used to transfer information over the internet. They work in different ways and are used interchangeably to access data on a server.

FTP is different from HTTP in one key way, which is that it requires authentication. That means you have to provide login credentials to be able to access the server.

To use FTP or SFTP, which is more secure, you need to download and install a client, like FileZilla. For the purposes of this article though, we are going to use Cyberduck.

First, locate your FTP credentials on your web host dashboard.

Next, create a new connection on the FTP client, and plug in the credentials.

Once the connection has been established, you can view the WordPress files and folders on the server.

If your web host doesn’t have cPanel access, they may not use phpMyAdmin either. However, most web hosts do provide a link to the website database from the dashboard.

In this example, Cloudways has a button to Launch Database Manager from the website dashboard. Cloudways uses Adminer instead of phpMyAdmin.

On the other hand, Dreamhost does, and you can find a Manage link on the website panel.

SSH

Short for ‘secure shell’, SSH is a way to connect securely to a remote computer over potentially insecure networks. In the case of WordPress, you can use it to access files on your site server from anywhere else.

SSH uses a command-line interface to interact with and control the site files and folders instead of a browser. Like with FTP, you may need a client to use SSH, although most systems have the ability built-in. We used the Terminal on macOS to open a connection to our web server.

Similar to FTP again, you will need credentials to log in:server address, username, and password. You may or may not need the port number. To connect to your server with SSH, type in ssh username@serveraddress. You will be prompted for a password, and once that is in, you will be able to interact with your site files.

With SSH, you need to have some familiarity with the command-line interface or be prepared to look through a ton of documentation. This list of commands can help you get started, although it is not comprehensive.

Note:Using the command-line interface, you can also leverage WP-CLI commands. WP-CLI is a tool to interact specifically with WordPress site files and its database, and thus has commands that are specific to WordPress.

Plugins

If you want to avoid cPanel and FTP altogether, you can also install a plugin to view and interact with WordPress files and folders.

The advantage of using a plugin is that you can see the files directly on your wp-admin dashboard, without needing to log in separately. The disadvantage is that if your site crashes for any reason and you want to fix an errant plugin or theme, you won’t be able to use these plugins to do so. However, it is still a viable alternative in most cases.

We tried out WP File Manager, and it was a breeze to use. Find the plugin from the plugins directory, install it, and you’re done.

The dashboard clearly shows all the files of your site, right from wp-admin.

One word of caution here is that searching for ‘file manager’ plugins also lists results for media library file managers. Those plugins serve an entirely different purpose.

Similarly, you can install a plugin to view the site database as well.

We tried Database Admin and saw that we could select our site database without logging in.

The interface is very basic though, and it helps to have a little understanding of SQL to navigate more effectively.

We also tried WP Adminer as an alternative.

It was very similar to accessing the database directly. The plugin appears as a shortcut in the Tools menu.

Why you should learn about WordPress file and directory structure

Your site is working, and working well at that. So why should you spend time learning about WordPress file structure? Apart from the simple reason of understanding how your site works, there are several good reasons:

  • Solve minor issues on your own steam, like disabling a plugin or theme that is acting up.
  • In case you face a major issue, it is important to be able to distinguish between good and bad advice . There is a ton of poor, although well-meaning advice, especially with respect to WordPress security. A little knowledge can help you ask the right questions when needed, and discard poor advice immediately.
  • Understanding the file structure of your site makes you a power user . You may be able to accomplish a great deal more than previously. It is a stepping stone to learning WordPress development as well, should you be so inclined. For instance, suppose you need to add redirects to your site, you can do so by modifying the .htaccess file without needing developer intervention.
  • It will also prevent you from deleting or changing critical files or database values, knowing that this will cause your site to crash.
  • Setting file permissions will become easier once you know the interplay between different files, and which users need access to them. At first glance, the strongest permissions and tightest security rules seem like the best option. This is not true at all. Remember that files need to communicate with each other, and therefore need appropriate permissions to do so.

If you are reading this article to figure out which files to backup, then the answer is everything. Always take complete backups, and restore partially as and when required.

How to protect WordPress files, folders, and database from malware

Now that you have a good understanding of WordPress structure, both inside and out, you can take steps to protect it from hackers. In WordPress security, prevention is always better than cure, and doing the following will keep out the majority of malware attacks.

  • Install MalCare, a top-notch security plugin with an integrated firewall
  • Invest in site backups
  • Keep WordPress, plugins, and themes updated as far as possible
  • Use strong passwords, and a password manager to remember them
  • Implement a good user policy
  • Never use nulled software

We have compiled all our security expertise into actionable advice that you can use to protect your site in minutes.

निष्कर्ष

Now that you have a working knowledge of your site, it is sensible to take a backup every time you want to change something. This is your safety net in case anything goes awry and you have to restore in a hurry. BlogVault has the best WordPress backups and comes with a whole host of other great features to manage your site effectively.

अक्सर पूछे जाने वाले प्रश्न

What is WordPress file structure?

WordPress file structure is the site’s organisational system. WordPress sites use files that contain code to run and interact with a database, which stores data.

How are WordPress files organised?

WordPress files are organised in a hierarchical folder structure. The WordPress installation is in a root directory, generally public_html or public, and everything else comes within it. There are 3 core folders in the WordPress root directory:wp-content, wp-includes, and wp-admin.

What should be in the wp-includes folder?

The wp-includes folder contains WordPress core packages and code that are installed with WordPress. The wp-includes folder and its constituent files remain constant. If you suspect there are changes, you can download a fresh installation of WordPress and compare those files with what is on your site.

Where are WordPress files located?

WordPress files are installed in a root directory on your site server. The root directory is often named public_html or public. All WordPress files are stored within the root directory in a hierarchical system of files and folders.


  1. डेटाबेस

    रीयल-टाइम एडीडीएम के साथ ओरेकल डेटाबेस और सत्र लटकाए गए समस्या निवारण

    Oracle® Enterprise Manager (OEM) 12c और 13c में कई प्रदर्शन विश्लेषण उपकरण शामिल हैं, जिसमें एक समर्थन उपकरण शामिल है, जिसे OEM रीयल-टाइम स्वचालित डेटाबेस डायग्नोस्टिक मॉनिटर (रीयल-टाइम ADDM) कहा जाता है, Oracle DBA के लिए समस्या निवारण या रीयल-टाइम ट्यूनिंग, चल रहे प्रदर्शन का उपयोग करने के लिए मुद

  1. Redis

    रेडिस में एक पूर्णांक मान कैसे घटाएं - रेडिस डीईसीआर | डेक्रबी

    इस ट्यूटोरियल में, हम सीखेंगे कि रेडिस DECR का उपयोग करके रेडिस डेटास्टोर में एक कुंजी पर संग्रहीत एक पूर्णांक मान का प्रतिनिधित्व करने वाले स्ट्रिंग को कैसे घटाया जाए। और DECRBY आदेश। DECR कमांड DECR कमांड का उपयोग निर्दिष्ट कुंजी पर संग्रहीत पूर्णांक मान का प्रतिनिधित्व करने वाले स्ट्रिंग को एक

  1. HTML

    HTML DOM इनपुट दिनांक स्टेपडाउन () विधि

    HTML DOM इनपुट दिनांक स्टेपडाउन () विधि निर्धारित करती है कि दिनांक फ़ील्ड कितने दिनों में घटनी चाहिए। सिंटैक्स निम्नलिखित वाक्य रचना है - स्टेपडाउन को कॉल करना एक संख्या के साथ विधि, जो डिफ़ॉल्ट रूप से 1 के बराबर होती है inputDateObject.stepDown(number) उदाहरण आइए हम इनपुट दिनांक स्टेपडाउन . का