문제

I see some projects using the Magento 2 root folder as webroot and other projects using the pub folder as the web root, independently of using Apache or NGINX, both worked.

Which webroot folder should I use in a new Magento 2 installation and why?

도움이 되었습니까?

해결책

You should you the pub folder as webroot, it improves security. The rest of the Magento file system is vulnerable because it is accessible from a browser. Setting the webroot to the pub/ directory prevents site visitors from accessing sensitive areas of the Magento file system from a browser.

For example:

/var/www/html/magento2/pub

Remember to edit your env.php to have this following node:

'directories' => [
    'document_root_is_pub' => true
]

Reference: Magento 2 DevDocs - Modify docroot to improve security

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 magento.stackexchange
scroll top