Can we make use of php.ini variables in other configurations - config

Can we make use of php.ini variables in other configuration files like log4php configuration file?
In log4php I am using LoggerAppenderRollingFile appender and I have used log file location as /var/www/MyProject/logs/log.text, But I want to externalize the project root ( /var/www/MyProject ) instead of hardcoding and I thought of having it in php.ini.
Is it possible to do it using php.ini, or can you suggest me a way to do it?

I'm not sure it's a great idea to put application specific configurations in php.ini, but regardless if you use php.ini or another ini file you can use parse_ini_file or parse_ini_string for loading data from it.

Related

Is there an alternate way to set directory wide config in dbt? (not dbt_project.yml)

I have been using a config macro in each model of my project, and many of them have the same exact config.
I know you can set general settings on a folder in dbt_project.yml, but we have many developers and many directories and having the configuration there gets messy very fast.
I'm wondering if there’s an alternate way to set such a config on a directory level? Like with a config.yml in the directory itself?

How do you disable "/controlpanel" directory redirect to :2083 in WHM?

I've used WHM and cpanel for years but recently noticed that after an update the "/controlpanel" directory has been automatically added allowing domain.com/controlpanel to redirect to domain.com:2083
How do you disable this redirect that is public facing?
The /controlpanel and /securecontrolpanel are controlled by ScriptAliasMatch in httpd.conf which cannot by modified directly as WHM/cPanel will rebuild it again as it where before the manual modifications. So it will be better if modifications done through one of the following options:
SSH access is needed to apply any one of these
Modify the yaml file which used in the rebuild apache configuration process, the file can be found under /var/cpanel/conf/apache/local or /var/cpanel/conf/apache/main then rebuild apache configuration by running /scripts/rebuildhttpdconf then restart apache by running /usr/local/cpanel/scripts/restartsrv_httpd
Modify the template file which used to parse the previous yaml file in order to generate the configuration file. First copy this file /var/cpanel/templates/apache2_4/ea4_main.default to /var/cpanel/templates/apache2_4/ea4_main.local then start modifying it then rebuild and restart apache.
And my vote goes to the first option to keep it clean and simple as possible but it worth knowing both ways so you can extend the functionality as much as you can.
For more details:
Apache Global Configuration docs
Apache Custom Templates docs

Apache log4php LoggerAppenderDailyFile maxBackupIndex

In Apache's log4php LoggerAppenderDailyFile appender, is it possible to limit the number of backup files kept?
Like what is done with the LoggerAppenderRollingFile appender's maxBackupIndex parameter.
See: https://logging.apache.org/log4php/docs/appenders/daily-file.html
No configuration available by default from Log4j.
https://logging.apache.org/log4php/docs/appenders/daily-file.html
shows the configuration maxBackupIndex is not available for LoggerAppenderDailyFile unlike LoggerAppenderRollingFile (https://logging.apache.org/log4php/docs/appenders/rolling-file.html)
One hack is to create a crontab entry to do the same
see this link http://www.howtogeek.com/howto/ubuntu/delete-files-older-than-x-days-on-linux/

Can openshift/rhcloud variables be used in an .htaccess file

Openshift sets several environment variables that can be used.
See here (variables: OPENSHIFT_*) https://developers.openshift.com/en/managing-environment-variables.html
Has anyone used these variables in their .htaccess file or can anyone assist in doing so?
My use specifically applies to a Mojolicious app as getting it to work on Openshift requires the following line in the .htaccess file. [ID HERE] refers to the OPENSHIFT_APP_UUID value. I manually type the value there now, and in theory, it should not change but I'd like to allow the app to be deployed by different users without needing them to look for their ID and edit the .htaccess file.
PerlSetVar psgi_app /var/lib/openshift/[ID HERE]/app-root/runtime/repo/perl/index.pl
You might be best off using an action_hook to write that .htaccess file post deploy and have it dynamically include the values of the environment variables that you want, something like this in your .openshift/action_hooks/post_deploy
echo "PassEnv ${OPENSHIFT_REPO_DIR}" >> ${OPENSHIFT_REPO_DIR}.htaccess
echo "PerlSetVar psgi_app ${OPENSHIFT_REPO_DIR}perl/index.pl" >> ${OPENSHIFT_REPO_DIR}.htaccess

Variables in Redis configuration file

I would like to set a REDIS_ROOT in my redis.conf file and be able to reuse that same variable across a number of other configuration points. I want to have all my logs, dumps, etc. go somewhere in this directory... something like $REDIS_ROOT/logs/redis.log.
Is there a way to set a variable of this kind in the Redis configuration file? Or am I stuck retyping it over and over (or doing some find-replace wizardry before using the conf file).
There does not appear to be any way to do this with Redis config files. However, there are only a couple places you should need to use a directory, unless you are doing a lot of includes. Redis configuration just isn't very complicated.