In which directories should you place files and scripts on the server?
For the administration and management of a website on a hosting server, it is critical to know in which directories files and scripts should be placed for the site to function correctly. The directory structure might seem a bit complicated at first, but a clear understanding will help in efficient file management.
The main directory public_html
The public_html directory is where website files and scripts must be uploaded so that they are available to website visitors. Here's what should be located here:
- Main website files (e.g., index.html, index.php).
- Subfolders for additional website pages or sections.
- Images, .css files, JavaScript files, and other resources used by the website.
Other standard directories
Besides public_html, hosting servers may have several other important directories.
- tmp: This directory is used for storing temporary files, such as files generated by sessions or scripts. Do NOT place site files in this directory, as they can be automatically deleted by the server.
- logs: Contains access and error logs for the website. These files are useful for debugging. Again, do NOT place site files here, as this directory is usually cleaned up periodically to save storage space.
- backup: If the server allows or has sufficient storage space, you can store website backups in this directory.
Managing files with a CMS
If you are using a CMS, such as WordPress, its installation and setup automatically create a file structure.
Main WordPress directories
- wp-admin: Contains files for the WordPress administration interface. This directory should not be modified, except in exceptional cases for debugging specific errors. If this folder is missing or corrupted, the WordPress administration panel will not work.
- wp-content: This is where themes, plugins, and uploaded files are located. This is the most important directory for customization, where you can delete or edit files (these actions are done automatically, but for more precise control, manual uploading is also possible).
- wp-includes: Contains the main WordPress files, such as additional libraries, PHP functions, or additional applications that the site depends on. Nothing should be modified in this directory.
Main WordPress files
- index.php: The main file that loads the WordPress application.
- wp-config.php: This is where the WordPress website configuration is stored. It can be edited to change the database connection.
- .htaccess: This file contains server rules, such as redirects or access blocking.
- xmlrpc.php: Allows connecting to WordPress via external applications.