Once you have created the account you can create the 'web' sub-directory in 'public_html.' You will be modifying an existing account so the account must be created first in WHM. On my VPS server, in WHM, I make the changes in the Terminal. Change the documentroot in Apache using the WHM Terminal Screen However, I have customers whose sites are hosted on shared hosting services with other companies and they are not able to change the documentroot. In my case, I have 2 VPS servers and since I manage the servers I can make whatever changes I need to the configuration. htaccess redirects but I've found these to be cumbersome to implement, and they do not play well with other redirects such as redirecting from to. However, this is not easy to configure on the live server. Modifying the documentroot is not a problem in a local dev environment because you can easily set up virtual hosts to point to the directory the site is installed in. You will be creating a private and a public directory as part of your Drupal installation and it is recommended, for security reasons that these directories, along with the vendor directory are not in the publicly accessible documentroot.Installing in a sub-directory maintains a clean file structure with your Drupal files kept separate from your web server system files.There are a number of reasons for why Drupal 8/9 are installed in a sub-directory. Advantages to Changing the documentroot for a Drupal Installation I'm going to talk a little bit about why we change the documentroot for Drupal, but I'm not not going to get into the specifics of installing Drupal, just the web server configuration to prepare for the installation.
The problem is that most web servers are configured to use 'public_html' as the documentroot by default, and there is no way to change it within the CPanel interface.Īdditionally, many web hosting companies will not allow the documentroot to be changed on a shared hosting account so if you must change the documentroot and your hosting company will not allow it you will need to switch to a host that allows you more control, or upgrade from a shared hosting account to a VPS. You can name the directory something other than 'web', but for this post we will use the default 'web' directory created during the installation of the Drupal 8/9 core-recommended profile.
With the release of Drupal 8, it's recommended to install Drupal in the 'public_html/web' directory.
With earlier versions Drupal was installed in the 'publlic_html' directory. Why do we Need to Change the Documentroot?ĭrupal 8 and onward represent a significant departure from previous versions of Drupal.
The specifics of installing Drupal will come in a later post. In particular, I'm going to focus on configuring the server for a new Drupal 8/9 installation. You will need to have access to your Apache web server configuration files, be comfortable navigating through directories in the terminal, and using the vi editor, or some other text editor, to modify files on your web server. If you are not comfortable modifying these files yourself contact tech support at your web hosting company. Of course, your web server may be configured differently so the instructions below are just a guide. To follow the guide below you should already be familiar with WHM/cPanel, and basic web server administration.
I'm going to describe how to change the document root on an Apache web server using WHM/cPanel.