how to set env variable for apache on Mac OS X - macos

I am using Snow Leopard and Apache 2.2. I want to set APACHE_ERROR_LOG used in virtual host log settings.
Somehow my Errorlog setting is getting prefixed with usr/$. I am guessing it must be in some setting which right now I can't figure out.
I get error in apache log as:
[error] (2)No such file or directory: could not open transfer log file /usr/$PATH_SPECIFIED_FOR_VIRTUAL_HOST_LOGS

Here is what was wrong. In one of the virtual host i has typo and it started with #. The http.conf has server-root configuration which says
# Do not add a slash at the end of the directory path. If you point
# ServerRoot at a non-local disk, be sure to point the LockFile directive
# at a local disk. If you wish to share the same ServerRoot for multiple
# httpd daemons, you will need to change at least LockFile and PidFile.
#
ServerRoot "/usr"
It was terrible typo mstake.

The easiest way to set an environment variable permanently in mac OS:
Open terminal application:
open -a /Applications/TextEdit.app ~/.bash_profile
In the recently open textedit window add at the bottom of the file the given environment variable, for example:
export JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_66.jdk/Contents/Home/"
NOTE: Make sure you use: (") instead of (“)

Related

Apache -> Ruby locale

I've got the following code checking the default encoding for read files (I'm on Linux, Ubuntu 16 x64), just for testing:
File.read("/bin/ls").encoding
If Apache calls my code through FastCGI then the output is US_ASCII (C locale), but if I run my code manually from anywhere in the system, I get en_US.UTF-8 encoding.
Changing the LANG env variable in /etc/apache2/envvars does not have any effect. Changing the ENV config in /etc/init.d/apache2 doesn't either (after service restart of course). /etc/default/locale is set to en_US.UTF-8. Playing with the virtualhost in my conf file and adding default char sets doesn't help either.
Checking the ENV array when called from Apache is almost empty (only the PATH variable is set), while checking it when run manually is full of variables like LANG etc. So it is obviously an environmental setting problem.
There is an external GEM that I use for my project and it's got a bug when run in a non-unicode environment. I could patch it manually but it's not a good solution because an update will overwrite it.
How could I get Apache to run my code called in a unicode environment?
The solution is: https://httpd.apache.org/mod_fcgid/mod/mod_fcgid.html#fcgidinitialenv
edit /etc/apache2/mods-available/fcgid.conf
FcgidInitialEnv LC_ALL en_US.UTF-8
service apache2 restart

nativescript installation don't work everywhere

i'm beginer in nativescript,i have correctly install ANDROID_HOME environment variable which return my sdk path after echo $ANDROID_HOME but despite this it return me The ANDROID_HOME environment variable is not set or it points to a non-existent directory. You will not be able to perform any build-related operations for Android
but if i put my project in the same directory with sdk directory it return me
Cannot resolve the specified connected device by the provided index or identifier. To list currently connected devices and verify that the specified index or identifier exists, run 'tns device'
I also notice that after each computer restarting environment variable disappear and i must resume a same process , i have edit .profile file, .bashrc file and zshrc file for environnement variable i have a same result
please tell me what wrong ... thank in advance
my ~./bashrc file
export ANDROID_HOME=/home/user/Android/Sdk
export PATH=$PATH:/home/user/Android/Sdk/tools
export PATH=$PATH:/home/user/Android/Sdk/platform-tools
export LD_LIBRARY_PATH=/home/user/Android/Sdk/emulator/lib64
In /home/user/Android/Sdk should be tools and platform-tools folders.
That's enough for me. (Linux Mint 18)
Maybe this information will be useful to someone:
Linux environment variables configuration files
.bashrc
This file is a variable for a particular user. It is loaded every time the user creates a terminal session, that is, in other words, opens a new terminal. All the environment variables created in this file take effect every time a new terminal session begins.
.bash_profile
These variables take effect every time the user connects remotely over SSH. If this file is missing the system will look for .bash_login or .profile.
/etc/environment
This file is for creating, editing and deleting any environment variables at the system level. The environment variables created in this file are available for the entire system, for each user and even for a remote connection.
/etc/bash.bashrc
System bashrc. This file is executed for each user, each time he creates a new terminal session. This only works for local users, when connected through the Internet, such variables will not be visible.
/etc/profile
System file profile. All variables from this file are accessible to any user on the system only if he entered remotely. But they will not be available when creating a local terminal session, that is, if you just open the terminal.
All the Linux environment variables created with these files can be deleted only by removing them from there. Only after each change, you need to either log out and log in, or execute this command:
$ source file_name
So, the environment variable can be of three types:
Local environment variables
These variables are defined only for the current session. They will be irretrievably erased after the session is completed, whether it is remote access or terminal emulator. They are not stored in any files, but are created and deleted using special commands.
Custom shell variables
These shell variables in Linux are defined for a specific user and are loaded each time it logs in using the local terminal, or it is remotely connected. Such variables are usually stored in configuration files: .bashrc, .bash_profile, .bash_login, .profile or in other files located in the user's directory.
System environment variables
These variables are available throughout the system, for all users. They are loaded when the system starts from the system configuration files: / etc / environment, / etc / profile, /etc/profile.d/ /etc/bash.bashrc.
If you are using nvm to manage different nodejs version, then try disabling nvm and using only one global nodejs version.
Regarding the environment variables that are being volatile, make sure that you track down the proper profile file that is being parse and place your changes there.
It would help if you can be more specific about your current platform. Then, people will be able to respond with more precision.
hi i solve my problem by adding in profile file environnement variable
export ANDROID_HOME=~/Android/Sdk
export ANDROID_HOME=~/Android/Sdk/tools
export ANDROID_HOME=~/Android/Sdk/platforms-tools
then i erased all path generate by all commands line entries from my terminal in .bashrc file(i think that it was that the problem source) . finally it work well thanks a lot to everybody for your helps

www-data can't find the ruby gems on vagrant configured virtualbox

I'm trying to get a virtual server running using Vagrant and VirtualBox. For the VirtualBox I'm using scotch/box which got all the basic stuff for running a ubuntu server with some components (apache, mysql, php etc.) more on scotchbox can be found here.
Now I got the server up and running (running a Yii2 application) but as soon as the application starts I get an Yii error message sh: 1: sass: not found and because of that a SASS file couldn't be converted to CSS. So I went back to my server to check if sass was installed, it wasn't so I ran the command gem install sass and after that sass was installed. gem list sass -i returned true.
But still the problem stayed, sass couldn't be found. I went back to my console and of course apache is ran by user www-data and I logged in to ssh with the vagrant user. And this is were it gets a bit vague for me. In the environments variables of the apache service I added the paths to both ruby and the gems. But still the www-data user cannot find the sass command or the gem command or even the ruby command.
I also tried to change the owner of the apache service from www-data to the vagrant user that did kinda help but thats not the solution I want to accept. I want a solution that the apache service stays owned by the www-data user and not a root user like vagrant.
If more data needs to be added please let me know.
Envvars file
envvars - default environment variables for apache2ctl
# this won't be correct after changing uid
unset HOME
# for supporting multiple apache2 instances
if [ "${APACHE_CONFDIR##/etc/apache2-}" != "${APACHE_CONFDIR}" ] ; then
SUFFIX="-${APACHE_CONFDIR##/etc/apache2-}"
else
SUFFIX=
fi
# Since there is no sane way to get the parsed apache2 config in scripts, some
# settings are defined via environment variables and then used in apache2ctl,
# /etc/init.d/apache2, /etc/logrotate.d/apache2, etc.
export APACHE_RUN_USER=www-data
export APACHE_RUN_GROUP=www-data
# temporary state file location. This might be changed to /run in Wheezy+1
export APACHE_PID_FILE=/var/run/apache2/apache2$SUFFIX.pid
export APACHE_RUN_DIR=/var/run/apache2$SUFFIX
export APACHE_LOCK_DIR=/var/lock/apache2$SUFFIX
# Only /var/log/apache2 is handled by /etc/logrotate.d/apache2.
export APACHE_LOG_DIR=/var/log/apache2$SUFFIX
## The locale used by some modules like mod_dav
export LANG=C
## Uncomment the following line to use the system default locale instead:
#. /etc/default/locale
export LANG
## The command to get the status for 'apache2ctl status'.
## Some packages providing 'www-browser' need '--dump' instead of '-dump'.
#export APACHE_LYNX='www-browser -dump'
## If you need a higher file descriptor limit, uncomment and adjust the
## following line (default is 8192):
#APACHE_ULIMIT_MAX_FILES='ulimit -n 65536'
## If you would like to pass arguments to the web server, add them below
## to the APACHE_ARGUMENTS environment.
#export APACHE_ARGUMENTS=''
## Enable the debug mode for maintainer scripts.
## This will produce a verbose output on package installations of web server modules and web application
## installations which interact with Apache
#export APACHE2_MAINTSCRIPT_DEBUG=1
export GEM_HOME=/home/vagrant/.rvm/gems/ruby-2.1.3
export GEM_PATH=/home/vagrant/.rvm/gems/ruby-2.1.3:/home/vagrant/.rvm/gems/ruby-2.1.3#global
export MY_RUBY_HOME=/home/vagrant/.rvm/rubies/ruby-2.1.3
export IRBRC=/home/vagrant/.rvm/rubies/ruby-2.1.3/.irbrc
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
Try to find out whether the PATH that apache uses is indeed modified by your adjustments of the envvars file. You could do this by simply putting running this php code:
var_dump(getenv("PATH"));
die;
I've had the exact same problem. After a long time trying it turned out that service apache2 stop and start in vagrant is not working as expected. After setting the PATH variable in /etc/apache2/envvars try reloading apache by reloading vagrant instead: vagrant reload

Go CD - how to set PATH on OS X?

I'm trying to get various bin directories on the PATH for the Go Agent on OS X and I'm not having any luck. Googling around finds references to /etc/default/go-agent, which doesn't exist by default on the Mac and I can't find any documentation for OS X indicating that the Go Agent.app would use it if I created it.
Ideally, I don't want to modify anything like this and I'd rather manage the PATH through the Go Server UI - I see that I can set environment variables, but I can't find any docs on actually appending to the PATH - default UNIX syntax of $PATH:/some/new/path/bin doesn't work.
Any advice?
There are couple of ways to override PATH while starting the GoCD Agent app on OSX:
Overriding them during startup when starting from the terminal
PATH=$PATH:/usr/local/bin open /Applications/Go\ Agent.app
Overriding them using a file ~/Library/Application Support/Go Agent/overrides.env. This file is sourced during agent startup, and it can be setup to change environment variables.
PATH=$PATH:/usr/local/bin
Source: https://docs.go.cd/current/installation/install/agent/osx.html#overriding-default-startup-arguments-and-environment

how do I change the location of the httpd.conf for Apache on windows?

I am working on setting up a load balancing cluster on windows server 2012 and have a shared drive where I want the configuration files for Apache to exist at. This way each member of the LB can load the exact same config files. How do I change where the config file is located independently of where the ServerRoot is?
Start the Apache process with the -d parameter and give your alternative ServerRoot as an argument, though I'd imagine it would be a much better idea for you to use some mechanism to sync the files locally to each server.
Also read http://httpd.apache.org/docs/2.4/mod/core.html#mutex, as it's advised if you're running from a networked file system.
If you just want to specify the main config file, start the process with the -f parameter and the path to the config file as an argument.

Resources