VirtualHost Differenct DocumentRoot and Directory

xFreddie

Registered
Nov 8, 2020
4
0
1
Germany
cPanel Access Level
Root Administrator
Hey,

in order to install Shopware 6 it's required to set the

DocumentRoot to /home/USER/public_html/public

and let the Directory be

<Directory /home/USER/public_html/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>

How can I reach this?
I tried to edit the documentroot in "/var/cpanel/userdata/user/domain & ssl, but this will change DocumentRoot and Directory.
I tried to follow this: Modify Apache Virtual Hosts with Include Files | cPanel & WHM Documentation , but when regenerating the httpd.conf I'll get the error: <VirtualHost> cannot occur within <VirtualHost> section

How can I reach what I want?
 
Last edited by a moderator:

xFreddie

Registered
Nov 8, 2020
4
0
1
Germany
cPanel Access Level
Root Administrator
Setting the documentroot in the userdata will also change the directory.
I need the document root to be public_html/public and the directory to point at public_html
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
7,519
1,028
313
cPanel Access Level
Root Administrator
I guess I'm not sure what you mean. If the docroot is setup to point to one directory, that would also be the location you'd want to put the files that get displayed on the web.

It's important to note that changing the docroot doesn't remove the directory - /home/username/public_html will still exist, but just wouldn't be the primary docroot. You can still place data there and use it.
 

xFreddie

Registered
Nov 8, 2020
4
0
1
Germany
cPanel Access Level
Root Administrator
I guess I'm not sure what you mean. If the docroot is setup to point to one directory, that would also be the location you'd want to put the files that get displayed on the web.

It's important to note that changing the docroot doesn't remove the directory - /home/username/public_html will still exist, but just wouldn't be the primary docroot. You can still place data there and use it.
In order to install shopware 6 the VHost for the domain must look like this

Code:
<VirtualHost *:80>
ServerName "_HOST_NAME_"
DocumentRoot _SHOPWARE_DIR_/public

<Directory _SHOPWARE_DIR_>
  Options Indexes FollowSymLinks MultiViews
  AllowOverride All
  Order allow,deny
  allow from all
</Directory>

</VirtualHost>
So in my case the VHost should look like this

Code:
<VirtualHost *:80>
ServerName test.com
DocumentRoot /home/test/public_html/public

<Directory /home/test/public_html>
  Options Indexes FollowSymLinks MultiViews
  AllowOverride All
  Order allow,deny
  allow from all
</Directory>

</VirtualHost>
How can I reach this?
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
7,519
1,028
313
cPanel Access Level
Root Administrator
Thanks for the additional details - that's exactly what I needed to see.

I checked the Shopware directions on my end as well, and that also seems to indicate these should be different.

The only way you could change this would be to modify the Apache default template, but then the change would be applied to all vhosts on the system. You may want to confirm with Shopware is this is something that is required or just something they recommend to split up the two areas, as I haven't run across an instance before where they are required to be different.
 

xFreddie

Registered
Nov 8, 2020
4
0
1
Germany
cPanel Access Level
Root Administrator
Thanks for the additional details - that's exactly what I needed to see.

I checked the Shopware directions on my end as well, and that also seems to indicate these should be different.

The only way you could change this would be to modify the Apache default template, but then the change would be applied to all vhosts on the system. You may want to confirm with Shopware is this is something that is required or just something they recommend to split up the two areas, as I haven't run across an instance before where they are required to be different.
Sadly it's required, that's confirmed already.
Changing the template for all vhosts is no solution as well.

We tried shopware with one of your competitor and with wamp only, where you can change vhosts for every domain & it's working fine.
Pointing to the public folder is not enough.

It would be great if we could find a solution here, because I really like WHM / cPanel.
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
7,519
1,028
313
cPanel Access Level
Root Administrator
It looks like there isn't a way to separate this on a cPanel machine as the docroot will always match the Directory value. If you have other non-cPanel systems using this software, it might be best to continue to use those for this specific tool.

It might be a good test to just set one up without changing the Directory value just to see if it works, but this seems like something that should be adjusted by Shopware to make that installation easier across multiple systems.