AD0-E717 practice question 7 of 15

Which Magento project directory is the recommended webroot for the web server?

Full set: 77 questions
Answer options
A: Pub/ Correct answer
B: app/
C: bin/
Correct Answer:
A. Pub/
Explanation

The pub/ directory is the only directory designed to be publicly accessible from a web browser. It serves as the web server's document root (webroot) for security and performance reasons. This directory contains the application entry point (index.php) and all publicly accessible static assets like CSS, JavaScript, and images. Setting the webroot to pub/ prevents direct URL access to sensitive application code, configuration files, and directories like app/, vendor/, and var/, which is a critical security best practice for Magento.

Why Incorrect

B. app/: This directory contains sensitive application code and configuration files (e.g., app/etc/env.php with database credentials). Exposing it as the webroot would create a severe security vulnerability.
C. bin/: This directory contains the Magento command-line interface (CLI) executable. It is not intended for web access and does not contain the necessary files to serve the application via a browser.

References

1. Adobe Commerce Developer Documentation, "Apache web server": In the sample virtual host configuration, the DocumentRoot directive is explicitly set to the pub directory. The documentation states, "In the following example, the Magento installation directory is /var/www/html/magento2, and the DocumentRoot is set to the /var/www/html/magento2/pub directory."

Source: Adobe Experience League > Commerce Developer > Installation Guide > Set up the web server > Apache.

2. Adobe Commerce Developer Documentation, "Magento file system overview": This document describes the purpose of the top-level directories. For the pub directory, it states, "The publicly accessible files. The document root for the web server should be set to this directory."

Source: Adobe Experience League > Commerce Developer > Fundamentals > Magento file system overview.

3. Adobe Commerce Developer Documentation, "Nginx web server": Similar to the Apache documentation, the sample Nginx configuration file sets the webroot to the pub directory. The directive root /pub; is used to define the document root.

Source: Adobe Experience League > Commerce Developer > Installation Guide > Set up the web server > Nginx.

Scroll to Top