Author Topic: Example vhost conf template file for Codeigniter 4  (Read 100 times)

0 Members and 1 Guest are viewing this topic.

Offline
*
Example vhost conf template file for Codeigniter 4
« on: January 08, 2022, 08:42:58 AM »

Me too was surprised by the recent change where vhost config files in Apache are overwritten by the cronjob.
This is how I added my own templates, described also by the docs here:

http://wiki.centos-webpanel.com/webservers-vhost-templates

The vhost config are automatically rebuild with a cron job. (/etc/cron.daily/cwp)
If you need some custom entries in your vhost configs, they now will be deleted/overwritten.
This was a recent change in CWP Pro.

So you need to make custom template configs for your domains:

1. First check what your Webserver configuration is

mine is:

Webserver config:[/size] nginx ->apache ->php-fpm

2. Create templates files

The easiest way for me was with terminal/root:

in this directory: (or copy the existing default files)

Code: [Select]
cd /usr/local/cwpsrv/htdocs/resources/conf/web_servers/vhosts/httpd/php-fpm
Code: [Select]
cp default.stpl default_ci4_public.stpl
Code: [Select]
cp default.tpl default_ci4_public.stpl
NOTE: the template name for https and http MUST be the same, use only .tpl and .stpl as extension

3. Codeigniter edit config template to serve "/public" folder.

edit default_ci4_public.stpl and default_ci4_public.tpl and add "/public" to the following:

    DocumentRoot %docroot%/public
and
    <Directory "%docroot%/public">

4. Then create a custom config for your Domain

add the just created template files to the specific user and domain,
select the just created templates as defaull

From CWP Pro GUI:

   WebServers Domain Conf > select username > Custom config

Here you should see and choose your custom config templates:

The Apache Configuration

  Apache default vhost template type: php-fpm
  Apache default vhost template: default_ci4_public

5. rebuild the Webservers conf

Now your site should stay online, also after the cron job with CWP pro






In the first image you see the webserver config with the apache default vhost template: default_ci4_public,
which we just made





In this image you see the list with all the templates and also our custom template for codeigniter 4