How do I get linux server to use local PHP.ini in a shared environment? - fastcgi

I'm on shared server environment (Dreamhost.com uses Linux/Debian).
I followed their instructions # http://wiki.dreamhost.com/Advanced_PHP_configuration
on setting up a local PHP5 instance on my user account so that I could use APC (php5 accelerator)
A couple of caveats is that I dont have php5 installed on the root directory "/home/php5" as assumed by the instructions/install script
rather I have it in another directory "home/subdir-path/php5", so I had to change the script to address that.
I tried adding this dir to the env $PATH
but when I do phpinfo(), i see that it's not using the local php.ini settings =[
Any thoughts on how to remedy this is greatly appreciated.
==OR==
If someone could show me the right steps to setup a custom php5 instance, with fastcgi, and APC (php cache/accelerator) that'd be just as great.

symlink from the expected location to the location where php.ini really is

Related

Why isn't telegraf reading environmental variables?

My goal is to put my telegraf config into source control. To do so, I have a repo in my user's home directory with the appropriate config file which has already been tested and proven working.
I have added the path to the new config file in the "default" environment variables file:
/etc/default/telegraf
like this:
TELEGRAF_CONFIG_PATH="/home/ubuntu/some_repo/telegraf.conf"
... as well as other required variables such as passwords.
However, when I attempt to run
telegraf --test
It says No config file specified, and could not find one in $TELEGRAF_CONFIG_PATH etc.
Further, if I force it by
telegraf --test --config /home/ubuntu/some_repo/telegraf.conf
Then the process fails because it is missing the other required variables.
Questions:
What am I doing wrong?
Is there not also a way of specifying a config directory too (I would like to break my file down into separate input files)?
Perhaps as an alternative to all of this... is there not a way of specifying additional configuration files to be included from within the default /etc/telegraf/telegraf.conf file? (I've been unable to find any mention of this in documentation).
What am I doing wrong?
See what user:group owns /etc/default/telegraf. This file is better used when running telegraf as a service via systemd. Additionally, if you run env do you see the TELEGRAF_CONFIG_PATH variable? What about your other variables? If not, then you probably need to source the file first.
Is there not also a way of specifying a config directory too (I would like to break my file down into separate input files)?
Yes! Take a look at all the options of telegraf with telegraf --help and you will find:
--config-directory <directory> directory containing additional *.conf files
Perhaps as an alternative to all of this... is there not a way of specifying additional configuration files to be included from within the default /etc/telegraf/telegraf.conf file? (I've been unable to find any mention of this in documentation).
That is not the method I would suggest going down. Check out the config directory option above I mentioned.
Ok, after a LOT of trial and error, I figured everything out. For those facing similar issues, here is your shortcut to the answer:
Firstly, remember that when adding variables to the /etc/default/telegraf file, it must effectively be reloaded. So for example using ubuntu systemctl, that requires a restart.
You can verify that the variables have been loaded successfully using this:
$ sudo strings /proc/<pid>/environ
where <pid> is the "Main PID" from the telegraf status output
Secondly, when testing (eg telegraf --test) then (this is the part that is not necessarily intuitive and isn't documented) you will have to ALSO load the same environmental variables into the current user (eg: SET var=value) such that running
$ env
shows the same results as the previous command.
Hint: This is a good method for loading the current env file directly rather than doing it manually.

Why is my WSL2 enviornment referencing Java folder outside its virtual environment?

When I start my development rails server I get this following message first. To my knowledge WSL2 is a virtual environment.
I would have expected it to now reference a Java directory that resides on my Windows host. Is this likely something I carried over in the project from when I was using WSL1? How would I safely correct this?
/home/daveomcd/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/railties-6.0.3.2/lib/rails/app_loader.rb:53:
warning: Insecure world writable dir /mnt/c/Program Files (x86)/Common Files/Oracle/Java/javapath
in PATH, mode 040777
I experienced the same problem when trying to fix the slowness of WSL2. The recommended solution was to move the files from the mounted NTFS drive to the root ext4 filesystem (using \\$wsl\<distroname>), so I did that.
I set up /etc/wsl.conf as below:
# Enable extra metadata options by default
[automount]
enabled = true
root = /mnt/
options = "metadata,umask=0033"
mountFsTab = false
[interop]
enabled = true
appendWindowsPath = true
And ran rails bundle to update dependencies.
Also make sure that your file permissions and owner settings are updated. Hope it helps.
Sorry, I'd love to make this more of a comment to see if I'm on the right track before committing to an answer. However, since there's too much info here for that, I'll make an attempt at getting you an answer here.
While it is a virtual environment, by default WSL provides several "Windows Interop" features that allow it to:
automatically mount Windows drives in /mnt/{c,d,...}
append the Windows path to the Linux path
run Windows executables inside Linux
share Windows environment variables with Linux (although this is not something that happens by default)
I can't be sure (long, long time since I've used Rails), but it looks like something in the app_loader.rb is checking permissions on Java directories in the path. It may be using some logic like "check each path entry and look for a java or java.exe there. If found, check permissions." Or something like that. That means that (2) and (3) above may be confusing it.
You can see this in action with which java.exe, which will likely return a Windows path. Or run notepad.exe, which will launch the Windows Notepad executable from within Linux/WSL (magic! 😉).
These are both very useful features, so I hate to disable them completely, but it's the easiest way to figure out if that's the problem. Create a /etc/wsl.conf with the following contents:
[interop]
enabled=false
appendWindowsPath=false
Exit your WSL instance and then:
(from PowerShell, CMD, or Windows Start) Run wsl --list --verbose to see the name of your distribution (most likely Ubuntu)
Likewise, run wsl --terminate <distro> to terminate that distribution.
Restart your WSL instance
Try running /mnt/c/Windows/system32/notepad.exe (assuming a normal C:\Windows installation) (should fail, since interop is disabled)
Try which notepad.exe (should fail, since the Windows path should no longer be appended to the Linux path)
Try to start your Rails dev server again - Might work (might not, I could easily be wrong about the root-cause here)
If it does work, then you can try to correct the situation with several less invasive methods than disabling those features entirely:
If you plan on only using WSL for your development, then you could remove the Windows JDK.
Or at least remove the Windows JDK from the PATH in Windows.
Or, if you want to keep it installed and in the Windows path, you could have a shell startup file (e.g. .bashrc) that removes it from the path only in WSL. I'll point you to this question which contains multiple techniques for doing so.
Or you could keep the appendWindowsPath=false in your /etc/wsl.conf but then add back in the paths you want manually in your startup config.

Jenkins service start error on red hat linux

The jenkins service does not start when ever i run jenkins service start . It says
Starting Jenkins bash: /usr/bin/java: No such file or directory
[FAILED]
I have java installed at /usr/lib/jvm/jdk1.7.0_51. The JAVA_HOME variable is also set. Also tried adding this java to /etc/init.d/jenkins file. I need to use the sun jdk, not open jdk.
Tried some of the alternatives from stackoverflow as well but did not work out.
Any suggestions will be of great help.
Thanks,
Bhargav
Thanks Paul. The script inside /etc/sysconfig/jenkins needs to be edited. Else it uses the default java.
JENKINS_JAVA_CMD="path of java installation"
Along with the above script, one can make changes to /etc/init.d/jenkins file if needed to add the path of java installation in your system.
I'd guess that there's a script that has /usr/bin/java hardcoded. When you find the culprit, remove the /usr/bin so that it uses the default. Or you can change it to use the JAVA_HOME path, something like this:
JAVA_EXECUTABLE=$JAVA_HOME/bin/java
$JAVA_EXECUTABLE $JAVA_OPTS etc.. etc..

Setting $PATH and $JAVA_HOME from IzPack install.xml

I see that $JAVA_HOME is a built-in variable in IzPack. Can I assign to it in a pre-install script and have the installer use that? Currently I am stuck on a machine that defaults to an open-source JRE that runs horribly and I need to reassign it to the Sun JRE so that the installer will run properly.
In the pre-install script, can I append to the $PATH with:
${ENV[PATH]} = ${ENV[PATH]}:/usr/local/java/bin
Let me know what I can do, I cannot get access to write to the .cshrc or .cshrc.login and I cannot tell my users to set the environment variables themselves.
The answer to this for me was that I had to write a python script that set the environment variables and then called a subprocess to launch the installer. This is far from ideal, but it seems like if your machine is stuck by default with an open source JRE, then you can't fix that any other way.

Including ~/opt/lib libraries in a Passenger Rails App

I'm having trouble getting a rails app on Dreamhost's Passenger to see compiled libraries in my ~/opt/lib directory. I have to put them here because I don't have root access.
I can boot up my app in ./script/console and it sees them libraries just fine because I updated my .bash_profile's LD_LIBRARY_PATH environment variable to include ~/opt/lib.
I've tried putting ENV['LD_LIBRARY_PATH'] = '~/opt/lib' in my environment.rb file but it doesn't seem too help. I get the following error from Passenger when I navigate to my site:
libodbcinst.so.1: cannot open shared object file: No such file or directory - /home/username/opt/lib/odbc.so
Anyone have experience with this?
Thanks
I had similar issue with Passenger that I described in http://blog.rayapps.com/2008/05/21/using-mod_rails-with-rails-applications-on-oracle/
But in your case this migth not work as you will not be able to change Dreamhost's httpd.conf file.
Other thing that you can try is to set LD_LIBRARY_PATH in .bashrc - according to http://www.wavethenavel.com/jonathanpenn/2008/09/08/bootstrapping-a-dreamhost-account-for-rails-and-git/ this has worked in Dreamhost's case. Have not verified that Passenger will execute .bashrc before launching ruby.
Using .bashrc won't work, as the library path that Passenger uses is the one that Apache loads on boot. There is no way it would look at a user's directory as that would be a major security issue.
The environment.rb way sounds like the way to go, though you might want to append to LD_LIBRARY_PATH instead. Also I'd make sure to use the full path to that directory just in case.
Alternatively you might be able to use .htaccess directives, similar to what is described # http://wiki.rubyonrails.org/rails/pages/HowToUseOracleWithFastCGI
This is an old thread, but for completeness this is how to achieve your goal:
Do not set the LD_LIBRARY_PATH if possible - it's horrendous.
As you do not have control over the environment that the Apache
user's environment, attempting to set a LD_LIBRARY_PATH env var per
the methods above will not work anyway.
Set the LDFLAGS environment variable with link and record path flags set prior to compiling the library files to set the correct search paths - e.g.:
export LDFLAGS="-L$HOME/opt/lib -R$HOME/opt/lib"
Once compiled, the files will have the correct links set to the relevant libraries. You can check this using the ldd command line tool - e.g.:
ldd /$HOME/your/custom/complied/library/file.so

Resources