setting apache environment variable - apache

My hosting environment using Server version: Apache/2.2.14 (Unix) and I am modifying
./usr/local/apache/conf/httpd.conf to set environment variable and restarting the server .
SetEnv XML-RPC-IPs 193.45.32.21
I did set it as a first entry in the file and restarted the server . But even restarting if I try to print it is still getting me black , Am I missing any thing ?
echo "My IP address ".$_SERVER['XML-RPC-IPs'];
Thanks for your help
Regards
Kiran

Environmental Variables are located in $_ENV superglobal.
What you are looking for is echo "My IP address ".$_ENV['XML-RPC-IPs'];

Related

how to associate windows hosts file entry with process running on WSL

I am running WSL2 (ubuntu) on Windows 10.
The WSL is running a process thats listening on a particular IP address - 192.168.3.1 (my apologies if I am not phrasing it correctly)
When I am in Windows browser, I want to type some name and have it resolved to the IP address inside WSL.
I have edited the Windows hosts file, and said something like:
192.168.3.1 alex
So now, in the browser, when I enter "alex" in the URL, I dont want it to search the internet -- I want it to get resolved to 192.168.3.1 inside WSL.
Thank you
Try this on WSL2:
cd /etc <br>
sudo mv hosts hosts_bkp <br>
sudo ln -s /mnt/c/Windows/System32/drivers/etc/hosts hosts
Now try to edit your hosts file by Windows.

Minishift: Could not resolve: *.192.168.64.2.nip.io

I have installed minishift on OSX with brew:
brew cask install minishift-beta
...
$ minishift version
Minishift version: 1.0.0
I have sucessfuly started minishift, and created node-ex example application and exported it:
$ oc get route
NAME HOST/PORT PATH SERVICES PORT TERMINATION WILDCARD
nodejs-ex nodejs-ex-myproject.192.168.64.2.nip.io nodejs-ex 8080-tcp None
However I can not reach .192.168.64.2.nip.io:
$ curl nodejs-ex-myproject.192.168.64.2.nip.io
curl: (6) Could not resolve host: nodejs-ex-myproject.192.168.64.2.nip.io
$ dig +short nodejs-ex-myproject.192.168.64.2.nip.io
$
All is working with minishift web console and oc command, but I can not reach the application domain.
Thank you #enj. The explanation at http://nip.io is clear about how it works.
I have seen that queries to 8.8.8.8 and to my ISP DNS are resolved to my private IP. But it is my router (my primary DNS) which do respond nip.io
My router run DD-WRT and has enabled
Rebind protection Discard upstream RFC1918 responses
then I add nip.io at
Domain whitelist nip.io
and now I resolve queries:
≻ dig +short test.10.0.0.1.nip.io
10.0.0.1
Is something on your machine or network blocking DNS queries to nip.io?
When playing with Minishift at home, where I am connected to the internet via Deutsche Telekom's VDSL and Speedport-Router, I cannot resolve these xip.io or nip.io addresses.
My workaround is to put 8.8.8.8 into /etc/resolv.conf
I had the same issue on Windows 10. My workaround was to add an entry in C:\Windows\System32\drivers\etc\hosts file. Here is an example
192.160.90.101 nodejs-ex-nodejs-echo.192.160.90.101.nip.io # needed for minishift to work

Lamp configuration on CentOS

I have installed LAMP on my CentOS server VM, where I want to access my server by the browser of my local machine, but it doesn't work. Please help me find the solution.
Are you sure it's running?
try
ps ax | grep httpd | grep -v grep
and if you see no output do:
/etc/init.d/httpd restart
The server will be accessible on your configured virtual host. Make sure you follow each step in this guide.
Is your VM network bridged or NAT'ted? If bridged, something on the VM is wrong as it should just show as a standard machine on your network. If NAT'ted, you will need to read up on NAT connections in your virtualisation documenation.

how to get the env variables set inside an apache server process

i am using an apache server.
Actually i have written a few modules which run when the apache service is started with
apachectl.
I have set certain env variables in envvars at
/usr/local/apache2/bin/envvars
Now i start the httpd process with
/usr/local/apache2/bin/apachectl -k start.
Now this apache process will initiate another child apache process.
I would like to know the enviroment variables set in both these processes? How can i see that?
ok sorry, i found it.
cat /proc//environ

Why does running "apachectl -k start" not work, but "sudo apachectl -k start" does?

I'm working on my OS X with the default installation of Apache. For some reason, when I run the "apachectl" command without the "sudo" I get "no listening sockets available / unable to open logs." I'm guessing this is a permissioning thing, so can someone help me out? I'm using Apache 2.2.
Also, side question, where the the Apache script file that is basically the "exe" that linux executes? I'm trying to intergrate my server with Aptana Studio, and it requires the path to the Apache install. I know in Windows, this would be "C:\path\to\httpd.exe", but I don't know how this works in linux.
Is your server listening on port 80? (Usually) only root is allowed to open ports below 1024. Hence the need for sudo.
As you can see, lots of people wonder how to get around this. One possible solution is to perform port-forwarding on your router. (I'm assuming here that you are behind a router...). Then incoming connections on port 80 can be forwarded to e.g. port 8080. Thus only locally does one need to connect to port 8080. (There may be more elegant solutions... somebody else will post them.)
I think generally (on both OS X and Linux - I'm not sure which one you're referring to) the httpd binary is located at: /usr/sbin/httpd
If you need to be able to restart Apache, and you can't do so as root (for whatever reason..), then you may have to settle for a non 'well known' port.
try this
(with php)
$a = shell_exec('sudo -u root -S /etc/init.d/apache2 restart < /home/$user/passfile');
password should stored in passfile