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

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

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

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

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 …

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.

1 Like

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.

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?

This didn’t work … error 500 … checking log

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

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

I added a PR to document this.

you can see the the rendered readme from that PR here, can you test those steps out and comment on the PR if this works?

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

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.

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?

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

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.

My public_html folder

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