# How to install Composer mautic in a docroot of your choosing?

**URL:** <https://forum.mautic.org/t/how-to-install-composer-mautic-in-a-docroot-of-your-choosing/23956>\
**Category:** Product Support\
**Created:** [May 2, 2022, 3:22pm UTC](https://forum.mautic.org/t/how-to-install-composer-mautic-in-a-docroot-of-your-choosing/23956 "2022-05-02T15:22:54Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![techbill](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/techbill/32/8325_2.png) [@techbill](https://forum.mautic.org/u/techbill)\
**Post date:** [May 2, 2022, 3:22pm UTC](https://forum.mautic.org/t/how-to-install-composer-mautic-in-a-docroot-of-your-choosing/23956/1 "2022-05-02T15:22:55Z")

</div>

Our docroot is public\_html.

When we tried installing composer in public\_html, it create a new a /docroot/ within the public\_html which don’t want since it a sub-domain and we prefer having docroot to be /public\_html/

How do we set up composer to install mautic using /public\_html/ as the docroot?

Our server is CentOS 7 with cPanel as the web management

Thank you

---

<div class="post-metadata">

**Author:** ![techbill](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/techbill/32/8325_2.png) [@techbill](https://forum.mautic.org/u/techbill)\
**Post date:** [May 2, 2022, 3:24pm UTC](https://forum.mautic.org/t/how-to-install-composer-mautic-in-a-docroot-of-your-choosing/23956/2 "2022-05-02T15:24:16Z")

</div>

We already tried downloading git folder into public\_html and did a composer install which works but we noticed that composer update give us errors so we are unable to upgrade it

---

<div class="post-metadata">

**Author:** ![techbill](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/techbill/32/8325_2.png) [@techbill](https://forum.mautic.org/u/techbill)\
**Post date:** [May 2, 2022, 3:28pm UTC](https://forum.mautic.org/t/how-to-install-composer-mautic-in-a-docroot-of-your-choosing/23956/3 "2022-05-02T15:28:50Z")

</div>

When we installed using this command

`composer create-project mautic/recommended-project:^4 public_html --no-interaction`

It does not install htaccess in /public\_html/ pointing it to the /docroot/ subfolder so we prefer avoid thig method and have it install in /public\_html/ instead of creation of another subfolder to be directed as htaccess

Here the link of folder install in our /public\_html/ folder

```auto
public_html]$ ls -ls
total 696
  0 drwxrwxr-x. 2 techbill techbill 23 May 2 14:54 app
  0 drwxrwxr-x. 2 techbill techbill 38 May 2 14:54 bin
  4 -rw-rw-r--. 1 techbill techbill 3828 May 2 14:54 composer.json
572 -rw-rw-r--. 1 techbill techbill 585516 May 2 14:53 composer.lock
  0 drwxrwxr-x. 7 techbill techbill 229 May 2 14:54 docroot
  4 -rw-rw-r--. 1 techbill techbill 1859 May 2 14:54 Gruntfile.js
  4 -rw-rw-r--. 1 techbill techbill 424 May 2 14:54 package.json
100 -rw-rw-r--. 1 techbill techbill 101625 May 2 14:54 package-lock.json
  8 -rw-rw-r--. 1 techbill techbill 5131 Apr 26 15:20 README.md
  4 drwxrwxr-x. 75 techbill techbill 4096 May 2 14:54 vendor

```

No htaccess was added by composer install …

---

<div class="post-metadata">

**Author:** ![aerendir](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/aerendir/32/1050_2.png) [@aerendir](https://forum.mautic.org/u/aerendir)\
**Post date:** [May 3, 2022, 9:57am UTC](https://forum.mautic.org/t/how-to-install-composer-mautic-in-a-docroot-of-your-choosing/23956/4 "2022-05-03T09:57:12Z")

</div>

Simply move the folder at the same level of `public_html`, delete the already present `public_html`, rename the folder created by Composer to `public_html`. Done.

---

<div class="post-metadata">

**Author:** ![techbill](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/techbill/32/8325_2.png) [@techbill](https://forum.mautic.org/u/techbill)\
**Post date:** [May 3, 2022, 2:47pm UTC](https://forum.mautic.org/t/how-to-install-composer-mautic-in-a-docroot-of-your-choosing/23956/5 "2022-05-03T14:47:09Z")

</div>

Do you mean the other folders need to be on same directory of public\_html directory as well too?

When I tried to install it in the folder which the public\_html reside in, it give me error folder not empty. It won’t let me install it there unless I delete everything in there which I can’t because it is needed for the cPanel operation to maintain a website for clients.

---

<div class="post-metadata">

**Author:** ![techbill](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/techbill/32/8325_2.png) [@techbill](https://forum.mautic.org/u/techbill)\
**Post date:** [May 3, 2022, 3:05pm UTC](https://forum.mautic.org/t/how-to-install-composer-mautic-in-a-docroot-of-your-choosing/23956/6 "2022-05-03T15:05:39Z")

</div>

So I would need to install it in a empty directory then move the main contents installed into a folder which public\_html is in

and then move web contents from docroot folder into public\_html folder?

Is this what I need to do?

---

<div class="post-metadata">

**Author:** ![techbill](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/techbill/32/8325_2.png) [@techbill](https://forum.mautic.org/u/techbill)\
**Post date:** [May 3, 2022, 3:13pm UTC](https://forum.mautic.org/t/how-to-install-composer-mautic-in-a-docroot-of-your-choosing/23956/7 "2022-05-03T15:13:13Z")

</div>

This didn’t work … error 500 … checking log

---

<div class="post-metadata">

**Author:** ![techbill](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/techbill/32/8325_2.png) [@techbill](https://forum.mautic.org/u/techbill)\
**Post date:** [May 3, 2022, 3:16pm UTC](https://forum.mautic.org/t/how-to-install-composer-mautic-in-a-docroot-of-your-choosing/23956/8 "2022-05-03T15:16:20Z")

</div>

`PHP Fatal error: require(): Failed opening required '/home/-omitted-/vendor/composer/../../docroot/app/AppKernel.php'`

It still expected it to be in the /docroot/ folder after installed so moving web contents to public\_html folder doesn’t work

---

<div class="post-metadata">

**Author:** ![techbill](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/techbill/32/8325_2.png) [@techbill](https://forum.mautic.org/u/techbill)\
**Post date:** [May 3, 2022, 8:43pm UTC](https://forum.mautic.org/t/how-to-install-composer-mautic-in-a-docroot-of-your-choosing/23956/9 "2022-05-03T20:43:37Z")

</div>

I may have found a solution but I don’t know how reliable this solution is with composer installed Mautic.

Here what I did on cpanel …

Via ssh go to your home dir /home/yourusername

at prompt type:  
composer create-project mautic/recommended-project:^4 mautic --no-interaction

It’ll create a mautic folder in your home dir and install mautic in that folder /home/yourusername/mautic/\*

Delete or rename /home/yourusername/public\_html folder

At prompt type:  
ln -s /home/yourusername/mautic/docroot /home/yourusername/public\_html

That will create a symbolic link between the docroot and public\_html

Complete installing Mautic via web browser

---

<div class="post-metadata">

**Author:** ![mollux](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/mollux/32/10618_2.png) [@mollux](https://forum.mautic.org/u/mollux)\
**Post date:** [May 4, 2022, 8:08am UTC](https://forum.mautic.org/t/how-to-install-composer-mautic-in-a-docroot-of-your-choosing/23956/10 "2022-05-04T08:08:46Z")

</div>

I added a [PR](https://github.com/mautic/recommended-project/pull/18) to document this.

you can see the the rendered readme from that PR [here](https://github.com/mautic/recommended-project/blob/89ce75e57d08c3a17d02dc8b65f141cb88178acf/README.md#how-do-i-use-another-folder-than-docroot-as-webroot), can you test those steps out and comment on the PR if this works?

---

<div class="post-metadata">

**Author:** ![techbill](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/techbill/32/8325_2.png) [@techbill](https://forum.mautic.org/u/techbill)\
**Post date:** [May 4, 2022, 3:41pm UTC](https://forum.mautic.org/t/how-to-install-composer-mautic-in-a-docroot-of-your-choosing/23956/11 "2022-05-04T15:41:44Z")

</div>

Here the result …

changed all  
`docroot` → `../public_html`

Then did a  
`composer install`

public\_html had all the file installed in it

When I tried to set up Mautic for first time, I get this error

```auto
Mautic Installation - Environment Check
Major Problems that need to be fixed now
We have detected 1 major problems. You must fix them before continuing:

Vendor libraries must be installed. If you are running Mautic from source, please run 'composer install'. If you downloaded Mautic, please check for the 'vendor' folder.

```

---

<div class="post-metadata">

**Author:** ![techbill](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/techbill/32/8325_2.png) [@techbill](https://forum.mautic.org/u/techbill)\
**Post date:** [May 5, 2022, 9:24pm UTC](https://forum.mautic.org/t/how-to-install-composer-mautic-in-a-docroot-of-your-choosing/23956/12 "2022-05-05T21:24:52Z")

</div>

I tried different ways and all come up the same result that it’s missing Vendor folders.

It will install Mautic in the correct docroot folder but when I go try to install it for first time then it give me the same error as above. “missing. vendor folder”

Did I miss a step maybe?

---

<div class="post-metadata">

**Author:** ![techbill](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/techbill/32/8325_2.png) [@techbill](https://forum.mautic.org/u/techbill)\
**Post date:** [May 10, 2022, 4:42pm UTC](https://forum.mautic.org/t/how-to-install-composer-mautic-in-a-docroot-of-your-choosing/23956/13 "2022-05-10T16:42:51Z")

</div>

I think I got it all sorted … Hopefully but I’m still doing some more testing…

Both cores and docroot need to be install together in public\_html folder. It seems that core/bin cannot be install outside of the public\_html folder probably due to strange permission setup on cpanel.

Still follow the same steps on [document the steps to change the webroot by mollux · Pull Request #18 · mautic/recommended-project · GitHub](https://github.com/mautic/recommended-project/pull/18/commits/8087474805de393ade7fb8a08f1b3c062cd1ed3f)

But I got mine working by using full cpanel path. We can’t just swap docroot with public\_html in composer.json instead we have to use full path as setup in cpanel

composer.json need to be in /public\_html/ folder

edit composer.json

replace `docroot` with `/home/cpanel-username/public_html`

open cpanel terminal (need to be your own account cpanel terminal to have the correct permission applied to the file during installation in a jailed “garden” account)

`composer install --no-interaction`

Like I said I haven’t done much testing and I just got it working with composer install.

---

<div class="post-metadata">

**Author:** ![techbill](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/techbill/32/8325_2.png) [@techbill](https://forum.mautic.org/u/techbill)\
**Post date:** [May 10, 2022, 5:55pm UTC](https://forum.mautic.org/t/how-to-install-composer-mautic-in-a-docroot-of-your-choosing/23956/14 "2022-05-10T17:55:10Z")

</div>

My public\_html folder

```auto
public_html]$ ls -lsA
total 788
  0 drwxrwxr-x. 8 techbill techbill 280 Apr 26 09:41 app
  4 -rw-rw-r--. 1 techbill techbill 216 May 10 16:14 autoload.php
  0 drwxrwxr-x. 2 techbill techbill 38 May 10 16:14 bin
  4 -rw-rw-r--. 1 techbill techbill 3923 May 10 16:14 composer.json
576 -rw-rw-r--. 1 techbill techbill 586030 May 10 16:13 composer.lock
  4 -rw-rw-r--. 1 techbill techbill 180 May 10 16:14 .env.dist
 16 -rw-rw-r--. 1 techbill techbill 12862 May 10 16:14 favicon.ico
  4 -rw-rw-r--. 1 techbill techbill 2440 May 10 16:14 .gitignore
  4 -rw-rw-r--. 1 techbill techbill 1859 May 10 16:14 Gruntfile.js
  8 -rw-rw-r--. 1 techbill techbill 5871 May 10 16:14 .htaccess
  4 -rw-rw-r--. 1 techbill techbill 682 May 10 16:14 index_dev.php
  4 -rw-rw-r--. 1 techbill techbill 621 May 10 16:14 index.php
  0 drwxrwxr-x. 7 techbill techbill 72 May 10 16:14 media
  4 -rw-rw-r--. 1 techbill techbill 4043 May 10 16:14 offline.php
  4 -rw-rw-r--. 1 techbill techbill 424 May 10 16:14 package.json
100 -rw-rw-r--. 1 techbill techbill 101625 May 10 16:14 package-lock.json
  4 drwxrwxr-x. 15 techbill techbill 4096 May 10 16:13 plugins
  4 -rw-rw-r--. 1 techbill techbill 224 May 10 16:14 robots.txt
  4 drwxrwxr-x. 23 techbill techbill 4096 May 10 16:14 themes
  0 drwxrwxr-x. 2 techbill techbill 23 May 10 16:14 translations
 36 -rw-rw-r--. 1 techbill techbill 35969 May 10 16:14 upgrade.php
  0 drwxr-xr-x. 5 techbill techbill 44 May 10 16:14 var
  4 drwxrwxr-x. 75 techbill techbill 4096 May 10 16:13 vendor

```

Still need to do more texting however so far it’s looking like successful composer install on cpanel
