Apache log4php LoggerAppenderDailyFile maxBackupIndex - log4php

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/

Related

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

Dynamically disabling/omitting Apache configuration directives (DRY)

I am working on a product that runs Apache, and i'm trying to make the configuration more DRY — right now there are many different vhost configs that get loaded in different situations but are 90% identical, and this is very tedious to deal with when a change needs made. I don't think Apache is really designed with this kind of dynamic environment in mind, but w/e, here i am anyway.
So i've first turned to environment variables — i have a small boot-strap script that determines the necessary configuration and dumps variables into /etc/apache2/envvars (which is loaded by apache2ctl and similar on Ubuntu). This allows me to do things like this:
envvars:
export MYKEY='/path/to/mykey'
export MYCERT='/path/to/mycert'
export MYBUNDLE='/path/to/mybundle'
vhost config:
SSLCertificateKeyFile ${MYKEY}
SSLCertificateFile ${MYCERT}
SSLCACertificateFile ${MYBUNDLE}
This works fine, but only as long as MYKEY, &al., are non-empty variables referencing non-empty files. In some configurations, for example, no CA bundle is required, so i tried just pointing MYBUNDLE to /dev/null. Apache considers this a 'syntax error' because /dev/null is an empty file, and refuses to start.
My question: Is there any way i can dynamically disable/omit configuration directives in the Apache config (based on environment variables or a similar mechanism) without having to maintain separate files for each possible scenario?
Alternative question: Is there any way i can provide an empty value/certificate to this particular directive (SSLCACertificateFile) in a manner that Apache won't consider invalid?
Ubuntu 12.04.5
Apache 2.2.22
Looks like what you want is a management tool for your configuration.
Now I'm not sure how often you deploy but you probably could make a script that generates your templates for you?
If you have a greater need, maybe consider automation software and use some kind of template? I'm thinking something like chef (https://www.chef.io/) or puppet (http://puppetlabs.com/) or ... They all support template and you can provide value based on environment / server / moods for the different values.

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

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.

Configure Apache to use different Unix User Accounts (www-data) per Site

An Apache 2.x Webserver with default configurations from the ubuntu/debian repositories will use the www-data unix account for apache2 processes handling web requests. Assuming that apache is serving two different sites (domain1.com and domain2.com), is it possible for apache to use unix user www-data1 when handling requests to domain1.com, and use unix user www-data2 when handling requests to domain2.com? The motivation is to isolate the code for each domain name from one another.
Take a look at suEXEC.
suPHP is also a nice thing to look into:
"suPHP is a tool for executing PHP scripts with the permissions of their owners. It consists of an Apache module (mod_suphp) and a setuid root binary (suphp) that is called by the Apache module to change the uid of the process executing the PHP interpreter."
-http://www.suphp.org/
You can use apache2-mpm-itk to achieve this.
You will be able to run each vhost using group and user of your choice.
Check this article for details:
http://www.howtoforge.com/running-vhosts-under-separate-uids-gids-with-apache2-mpm-itk-on-ubuntu-9.04
I used this on my development machine (Ubuntu), If you're using for production please read this page carefully:
http://mpm-itk.sesse.net/

Apache: I want to enable SSI. Can anyone furnish an example config file?

Yes - Google abounds with information about configuring Apache to support SSI.
But unfortunately, I still cannot seem to get it right.
My questions:
Can anyone furnish me a full-fledged example config file that enables SSI on an Apache server?
Also can you please tell me where I should drop this config file (i.e. which
directory)?
Apache probably wouldn't run if you didn't already have a fully-fledged config file. Try an
apachectl configtest
and see what happens.
My site is hosted at 110mb.com.
Interestingly enough, here is the solution:
Rename all files which have server-side includes to *.shtml.