Best Practice ISPConfig 3 Composer and CodeIgniter 4

Discussion in 'HOWTO-Related Questions' started by SupportMyster, Aug 15, 2022.

  1. SupportMyster

    SupportMyster New Member

    First off, Thanks to Till and the team for a great product, wonderful setup tutorials and unparalleled support.

    I have setup ISPConfig 3 via the Perfect Server (w/ Apache, php7.4 on Ubuntu 20) guidance and it works wonderfully.
    I have gotten Composer installed globally and placed in the Jail for the shell user and can run composer.
    My problem comes when trying to install CI4. My lack of knowledge about ISPConfig's inter-workings with Apache brings me here.

    Where should I create the project? With CI3 I could put it in the web folder and go. I can do that with a Manual installation of CI4 but my project requires Composer to install other components so I need to get CI4 installed via Composer first.

    I thought because of the way I had setup CI3 that I should create the project in the web folder but CI4 comes with a 'public' folder which is supposed to be the only folder public facing. So I thought I needed to be one folder up in jailed root (just above web).

    When I try to setup the project with 'web' as the project folder from jailed root, Composer complains about web not being empty. When I try to create it with another name composer says it cannot mkdir.

    Would best practice be to setup the project in a different folder under home/shell_user and somehow change the publicly accessible folder from web to CI4's public (I assume through the site options, manual edit of vhost file or use of .htaccess) or change the CI4 to use web as the public folder? Or am I completely off base and should do something completely different? Does either scenario require directives to make CI4 files in the home/shell_user folder accessible for use by the site?

    Thank you so much for your time and assistance,
     
    Last edited: Aug 15, 2022
  2. nhybgtvfr

    nhybgtvfr Well-Known Member HowtoForge Supporter

    not absolutely 100% on this. i don't know anything about codeigniter.
    but some of our developers use composer to install software and create their own app and this method works for them.

    you could try just ssh'ing in as that web user, switching to the /web folder, and then just running composer install as you normally would,
    yes, it would create a /web/public folder, and pub other files in /web, but that's not a problem.
    then under web options in the ispconfig control panel, add this to the apache directives:
    Code:
    DocumentRoot "{DOCROOT_CLIENT}/public"
    
    although it appears that the other files in /web are ostensibly visible/available to external visitors, the change of docroot will block direct access to them. anyone trying to visit the domain itself, or any other /web/<filename> or /web/<subdirectory> will just get given the default index file of /web/public/ *

    * all the files in /web will still be directly accessible to any ssh / ftp users.
     
    ahrasis likes this.
  3. SupportMyster

    SupportMyster New Member

    Thank you for the response.
    In CI4, the composer command is:
    composer create_project codeigniter4/appstarter <project_name>
    which will create folder <project_name> in the web folder in that case.
    Simply updating the apache directive to reflect that.
    This worked wonderfully. Thanks so much.
     
    Last edited: Aug 15, 2022
  4. Steb

    Steb New Member

    Thanks for the solution, work also for me ISP3.2.9 with CI4.2.11 on Ubuntu 22.04
     

Share This Page