Adding a flag to Apache launch (-D MY_FLAG)
I want to add a flag (environment variable) to Apache when it starts, adding "-D MY_FLAG" to the Apache launch command. I did it on other servers but have a problem doing it on my cPanel VPS.
I use this flag for managing a conditional configuration of a virtual host: the same conf file (included in httpd.conf) will then work on both my LOCAL, DEV and PROD environments. The advantage of doing so is that I can version a single project's virtual host conf file in the project's git repo and auto deploy it when it changes, auto relaunch the Apache server, etc.
I managed to configure this on my local environment (Mac OS) and the dev server (another CentOS server without cPanel) using the $OPTIONS variable in apachectl: in /etc/sysconfig/httpd I have uncommented the "$OPTIONS" line and set $OPTIONS to "-D MY_ENV_FLAG". This flag is then added automatically whenever Apache starts so I can then use in apache conf files. Neat!
The problem is that it doesn't work on my cPanel server: from what I've read on the web, the /usr/sbin/apachectl file that I edited is not used by EasyApache, which uses the apachectl located in /usr/local/apache/bin. This second apachectl is an older version that doesn't take into account an $OPTIONS parameter. I could edit this file and add $OPTIONS to the launch command lines... but editing an EasyApache "core" file doesn't sound good. I will do it only if I have no other solution.
I found this page in the documentation that explains how to add environment variables to EasyApache, but I understand this process adds the variables to the compiled Apache: building Apache again is needed for the new variable to be taken into account. This doesn't suit my needs, why should I compile the server when I only want to add a flag at launch command, which is a native feature of Apache?
So, do you guys see a way of adding this flag at launch?
Please sign in to leave a comment.
Comments
0 comments