How to enable mod_info in Apache? - apache

I've gone through the Apache guide to enable to mod_info.
As per doc:
To configure mod_info, add the following to your httpd.conf file.
<Location /server-info>
SetHandler server-info
</Location>
You may wish to use mod_access inside the <Location> directive to limit access to your server configuration information:
<Location /server-info>
SetHandler server-info
Order deny,allow
Deny from all
Allow from yourcompany.com
</Location>
Once configured, the server information is obtained by accessing
http://your.host.dom/server-info
In my case this link is not giving any info. Is there anything I need to install as mod_info.c or something? Is there anything I need to put as AddModule or something?

There should be a mod_info.so that must be on a path Apache 2 can find. For example, I have:
kdp#darwin ccl $ locate mod_info.so
/usr/lib64/apache2/modules/mod_info.so
Then, I have these in my httpd.conf:
ServerRoot "/usr/lib64/apache2"
LoadModule info_module modules/mod_info.so
This is made available by a snippet in /etc/apache2/modules.d/00_mod_info.conf:
<IfDefine INFO>
# Allow remote server configuration reports, with the URL of
# http://servername/server-info
<Location /server-info>
SetHandler server-info
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Location>
</IfDefine>
(The IfDefine is only needed because of the way stuff is set up on Gentoo.)

Check if info_module is loaded.
% /usr/local/sbin/httpd -t -D DUMP_MODULES | grep info_module
If it is not loaded, add following line to httpd.conf. Note that path/to must be replaced with appropriate path.
LoadModule info_module path/to/mod_info.so

I got the solution.
When I check ./apachectl -l, mod_info has not been installed.
To install the Mod_info or any module, First Compile and install Apache by ./configure --enable-info make make install
More info for install module : http://publib.boulder.ibm.com/httpserv/manual60/install.html
Check ./apachectl -l, mod_info would be there in the list
Enable server-info by updating httpd.conf
invoke url http://your.host.dom/server-info
One thing I am not sure why apache mod_info not installed default installation.

Related

How to run multiple PHP version with XAMPP?

I have multiple projects based on PHP. Some require PHP version 5.x to run and other strictly require PHP 7.0 or above. I am working on these simultaneously. Is there a way to run multiple PHP versions such that I can switch between them when working on different projects.
Try these steps:
Stop LAMP if running.
Download libphp7.so if you don't have
https://github.com/prashant-techindustan/php7module_library/blob/master/libphp7.so
Edit /opt/lampp/etc/extra/httpd-xampp.conf (Comment out one of the following which is not needed):
LoadModule php5_module modules/libphp5.so
LoadModule php7_module modules/libphp7.so
Start LAMP
>> Open C:\xampp\apache\conf\extra\httpd-xampp.conf
>> Write Following code at Bottom of this (httpd-xampp.conf) file
ScriptAlias /php56 "C:/xampp/php56"
<Directory "C:/xampp/php56">
AllowOverride None
Options None
Require all denied
<Files "php-cgi.exe">
Require all granted
</Files>
</Directory>
>> Open C:\xampp\apache\conf\extra\httpd-vhosts.conf\httpd-vhosts.conf
>> Create a virchual host in Different post By Writing Following code
<VirtualHost *:8081>
UnsetEnv PHPRC
<FilesMatch "\.php$">
php_flag engine off
SetHandler application/x-httpd-php5_6
Action application/x-httpd-php5_6 "/php5_6/php-cgi.exe"
</FilesMatch>
DocumentRoot "C:/xampp/htdocs/myphp5_6_project"
</VirtualHost>
>> Create a folder "myphp5_6_project" in htdocs of xampp
>> Open C:\xampp\apache\conf\httpd.conf
>> Write Listen 8081 (any where or Below Listen 80 line)
>> Restart Apache Services

Apache httpd server-info and server-status

I am on Windows 7, using Apache 2.2.29.
I modified my httpd.conf file to load moduels for mod-info.so and mod-status.so
and in my extra/httpd-info.conf, I updated server-status and server-info Location stancas to allow from
So, in my httpd.conf, I uncommented these:
LoadModule info_module modules/mod_info.so
LoadModule status_module modules/mod_status.so
and in my extra/httpd-info.conf, I modified as below to add my ip-address in "Allow from":
<Location /server-status>
SetHandler server-status
Order deny,allow
Deny from all
Allow from my-ip-address:no-port#
</Location>
<Location /server-info>
SetHandler server-info
Order deny,allow
Deny from all
Allow from my-ip-address-no-port
</Location>
If I just enter my-ip-address:my-port in browser, I get
"It Works!"
However, when I try to get info and status of my server, I get
for server-info:
Not Found
The requested URL /server-info was not found on this server.
for server-status:
Forbidden
You don't have permission to access /server-status on this server.
I am new to Apache, please provide explanation.
Much appreciated,
On modern windows, If you edit httpd.conf from your normal user account you can end up creating a 2nd copy specific to your userid that the server doesn't see. Make sure to edit it as Administrator.

trying to enable mod_status but I get "Syntax error..."

I am trying to enable mod_status on my server. I have mod_status.so module installed and the relevant part of my .conf file is (I plan to restrict access to only my IP once I get it running):
LoadModule status_module modules/mod_status.so
<Location /server-status>
SetHandler server-status
Order Allow,Deny
Allow from all
</Location>
I restart apache and get an error: "Syntax error on line 4 of /path/to/httpd.conf"...which points to the line:
Order Allow,Deny
I've tried all combinations of lowercase, uppercase and a space between the comma and "Deny". What am I doing wrong?
I am using Apache 2.2.25 (and I do have 2 virtualhosts)
Thanks!

Apache - how to get REMOTE_USER variable

Previously I used the IIS server as PHP server. Currently, it is the apache.
On IIS I could access to the variable $_SERVER ['REMOTE_USER'] which returns the username and domain (eg domain\user) but after installing XAMPP this variable is not available.
What I should do to get this variable get again?
My app is on local network with no-internet connection
Finally got it to works! :D
Download the module from here https://www.apachehaus.net/modules/mod_authnz_sspi/ (x86 for 32 bit and x64 for 64 bit apache)
Copy the mod_authnz_sspi.so from Apache24\modules folder and place it in the modules folder of your Apache folder on your webserver
Under the httpd.conf file (Config file for your apache) place this line of code. Try to load this as the last module:
LoadModule authnz_sspi_module modules/mod_authnz_sspi.so
Make sure that the following modules are uncommented
LoadModule authn_core_module modules/mod_authn_core.so
LoadModule authz_core_module modules/mod_authz_core.so
PS: both the above modules are required for this to work.
Place the following code in your httpd.conf file
<Directory "path/to/your/htcdocs/folder">
Options None
AllowOverride All
Order allow,deny
Allow from all
#AuthName "SSPI Protected Place"
AuthType SSPI
SSPIAuth On
SSPIAuthoritative On
SSPIOfferBasic On
SSPIOmitDomain On
Require valid-user
</Directory>
Restart your apache servive and hopefully it should restart without any issues.
Now in order to recognise the user , use the following code on a php page
echo $_SERVER['PHP_AUTH_USER'];
That's all.
I'm using:
XAMPP Control Panel 3.2.1
APACHE 2.4
<Directory "path/to/your/htcdocs/folder">
Options None
AllowOverride All
Order allow,deny
Allow from all
#AuthName "SSPI Protected Place"
AuthType SSPI
SSPIAuth On
SSPIAuthoritative On
SSPIOfferBasic On
SSPIOmitDomain On
Require valid-user
</Directory>
If you use ModRewrite or other I suggest you to keep
Options Indexes FollowSymLinks Includes ExecCGI
otherwise you'll get an error like
[rewrite:error]: Options FollowSymLinks and SymLinksIfOwnerMatch are both off, so the RewriteRule directive is also forbidden due to its similar ability to circumvent directory restrictions
You can only access the remote user if Apache has actually authenticated the user, check the apache auth howto.
I battled with this for a long time, it turned out that I had to install VC redistributable to make it work.

suPHP setting user/group to virtual host and using docroot

I am trying to get suPHP working, i followed tutorials and seem to have it installed correctly.
now my issue is this
1) i set docroot in the suphp.conf file, but its set to /var/www by default. The problem I have with this is that my domains are stored under another directory as well. So for instance i have my subdomains in one directory and my regular domains in another. So I get an error thrown to my browser telling me that a domain is resolving to a directory not in the configuration.
2) I would like to know how to use suPHP_UserGroup to set the user/group of a specific domain set under my VirtualHost configuration.
This is an example VirtualHost that I have to better show my issues.
<VirtualHost *:80>
ServerAdmin admin#domain.com
ServerAlias mail.domain.com
DocumentRoot /web/users/domain.com/subdomains/mail/webmail
<IfModule mod_suphp.c>
suPHP_UserGroup mail mail
</IfModule>
<Directory "/web/users/domain.com/subdomains/mail/webmail">
AllowOverride All
Order allow,deny
Allow from All
</Directory>
</VirtualHost>
When I reload apache I get an error:
Invalid command 'suPHP_UserGroup', perhaps misspelled or defined by a module not included in the server configuration
I configured suPHP with this:
./configure --prefix=/usr --sysconfdir=/etc --with-apr=/usr/bin/apr-1-config --with-apxs=/usr/sbin/apxs --with-apache-user=apache --with-setid-mode=owner --with-php=/usr/bin/php-cgi --with-logfile=/var/log/httpd/suphp_log --enable-SUPHP_USE_USERGROUP=yes
http://www.suphp.org/DocumentationView.html?file=apache/CONFIG
suPHP_UserGroup (expects user- and groupname)
Only supported when compiled with setid-mode "force" or "paranoid" *
Specify the user- and groupname to run PHP-scripts with. This setting
can only be used within a or context.
Example: suPHP_UserGroup foouser bargroup
./configure --prefix=/usr --sysconfdir=/etc --with-apr=/usr/bin/apr-1-config --with-apxs=/usr/sbin/apxs --with-apache-user=apache --with-setid-mode=paranoid --with-php=/usr/bin/php-cgi --with-logfile=/var/log/httpd/suphp_log --enable-SUPHP_USE_USERGROUP=yes
I add the following four lines to my vhost definitions. Line two is relevant to your question.
suPHP_Engine on
suPHP_UserGroup vhost_owner vhost_group
suPHP_AddHandler x-httpd-php
AddHandler x-httpd-php .php .php3 .php4 .php5