cgi-bin configure fro httpd - php

I am trying to configure cgi with apache
I did following changes in httpd.conf file
uncommented
AddHandler cgi-script .cgi
<Directory "/var/www/cgi-bin">
AllowOverride None
Options +ExecCGI
Require all granted
</Directory>
service httpd restart
But unable to execute, its giving following error in logs/error_log file
[Wed Mar 26 17:08:22.088316 2014] [mime_magic:error] [pid 7760] [client ::1:59024] AH01512: mod_mime_magic: can't read `/var/www/cgi-bin/hello.cgi'
[Wed Mar 26 17:08:22.089486 2014] [cgi:error] [pid 7760] [client ::1:59024] AH01215: (13)Permission denied: exec of '/var/www/cgi-bin/hello.cgi' failed
[Wed Mar 26 17:08:22.090045 2014] [cgi:error] [pid 7760] [client ::1:59024] End of script output before headers: hello.cgi

From here:
The problem is the security of SELinux is preventing mod_mime_magic access to the testprogram.
This happens when context of the program (in this case testprogram) does not match the directory.
To change to the appropriate context, use the UNIX command "chcon".
Read the following article for details: Apache and SELinux

Related

AH00894: declining URL fcgi

I'm trying to set up a server that parses .HTML file for PHP.
Operating System: Amazon Linux 2
PHP version: 8.0.8
Apache version: 2.4.51
/etc/httpd/conf.d/php.conf
#
# Allow php to handle Multiviews
#
AddType text/html .php
#
# Add index.php to the list of files that will be served as directory
# indexes.
#
DirectoryIndex index.php index.html
#
# Redirect to local php-fpm (no mod_php in default configuration)
#
# Enable http authorization headers
SetEnvIfNoCase ^Authorization$ "(.+)" HTTP_AUTHORIZATION=$1
<FilesMatch \.(php|phar)$>
SetHandler "proxy:unix:/run/php-fpm/www.sock|fcgi://localhost"
</FilesMatch>
The change I'm making is adding HTML to the FilesMatch clause here:
<FilesMatch \.(php|phar|html)$>
SetHandler "proxy:unix:/run/php-fpm/www.sock|fcgi://localhost"
</FilesMatch>
When I do that I see these errors:
[proxy_fcgi:debug] [pid 20974] mod_proxy_fcgi.c(1063): [client 1.1.1.1:49893] AH01078: serving URL fcgi://localhost/home/web-system-sites/dev.example.com/index.html
[proxy:debug] [pid 20974] proxy_util.c(2528): AH00942: FCGI: has acquired connection for (*)
[proxy:debug] [pid 20974] proxy_util.c(2583): [client 1.1.1.1:49893] AH00944: connecting fcgi://localhost/home/web-system-sites/dev.example.com/index.html to localhost:8000
[proxy:debug] [pid 20974] proxy_util.c(2620): [client 1.1.1.1:49893] AH02545: fcgi: has determined UDS as /run/php-fpm/www.sock
[proxy:debug] [pid 20974] proxy_util.c(2806): [client 1.1.1.1:49893] AH00947: connected /home/web-system-sites/dev.example.com/index.html to httpd-UDS:0
[proxy:debug] [pid 20974] proxy_util.c(3177): AH02823: FCGI: connection established with Unix domain socket /run/php-fpm/www.sock (*)
[proxy_fcgi:error] [pid 20974] [client 1.1.1.1:49893] AH01071: Got error 'Access to the script '/home/web-system-sites/dev.example.com/index.html' has been denied (see security.limit_extensions)'
After reading my error messages a second time I saw this, "see security.limit_extensions" and then I added .HTML here:
; Limits the extensions of the main script FPM will allow to parse. This can
; prevent configuration mistakes on the web server side. You should only limit
; FPM to .php extensions to prevent malicious users to use other extensions to
; exectute php code.
; Note: set an empty value to allow all extensions.
; Default Value: .php
security.limit_extensions = .php .html
and it works like a charm

IBM HTTP Server (Apache2) error

I have configured IBM HTTP Server as follow:
<IfModule mod_fastcgi.c>
Options Indexes MultiViews ExecCGI
FastCGIServer "c:/php7.1/php-cgi.exe"
SetHandler fastcgi-script
</IfModule>
<Directory "C:/IBM/HTTPServer85/htdocs/public">
AddHandler fastcgi-script .php
Options FollowSymLinks Indexes MultiViews ExecCGI
AllowOverride None
Order allow,deny
Allow from all
</Directory>
I get the following errors:
[Mon Jan 29 12:17:22 2018] [notice] Child 8328: Starting 600 worker threads.
[Mon Jan 29 12:17:22 2018] [notice] FastCGI: process manager initialized
[Mon Jan 29 12:17:22 2018] [warn] FastCGI: server "C:/php7.1/php-cgi.exe" started (pid 4636)
[Mon Jan 29 12:17:22 2018] [notice] Child 8328: Listening on port 443.
[Mon Jan 29 12:17:22 2018] [notice] Child 8328: Listening on port 8443.
[Mon Jan 29 12:17:24 2018] [error] [client 192.168.107.169] (OS 2)The system cannot find the file specified. : FastCGI: stat() of "C:/IBM/HTTPServer85/htdocs/public/login/" failed
[Mon Jan 29 12:17:24 2018] [crit] (OS 193)%1 is not a valid Win32 application. : FastCGI: can't start (dynamic) server "C:/IBM/HTTPServer85/htdocs/error/500/index.php": spawn_fs_process() failed
[Mon Jan 29 12:17:24 2018] [crit] [Mon Jan 29 12:17:24 2018] file G:\\blddir\\IHS85\\apache\\modules\\fastcgi\\fcgi_pm.c, line 1787, assertion "s->procs[i].pid < 0" failed
What is wrong with my http.conf?
It looks like you have a hybrid/partial config of multiple ways to configure fastcgi.
In the era of mod_fastcgi (IHS 8.5.5 and earlier), you'd typically see the "Action" directive here which results in a request for foo.php to be passed to the PHP interpreter as an argument.
Since you don't have action, and your SetHandler does not limit to
any particular extension, mod_fastcgi tries to invoke your php script
directly as an executable. On Windows, this association of what intepreter to use is the global one of the OS.
If you stick with mod_fastcgi, I'd suggest using the boilerplate examples with Action you see everywhere. But there's no reason to torture yourself with this when even IHS 9 has mod_proxy_fcgi and you could instead configure that and php-fpm instead.

mod_authz_core denied : Laravel 5 + Apache 2.4 + Xampp: showing 403, using ElCapitan

I have a new Laravel 5 project on my Mac. Everything from github is set up and should work. It actually works on http://localhost:8000/ after running this command:
php artisan serv
But, i am seeing a 403 error when I type myprojectname.local in the browser when i want to use virtualhost.
I have several noframework projects in Php and they are still working fine, I can run them through my browser (Chrome) using otherproject.local Therefore I don't think VirtualHosts si the reason.
I am thinking about an authorization problem, so I checked the Owner and the group of my folder (/Users/username/Documents/foldername) but they are similar to the configuration in /private/etc/apache2/httpd.conf see bellow
<IfModule unixd_module>
#
# If you wish httpd to run as a different user or group, you must run
# httpd as root initially and it will switch.
#
# User/Group: The name (or #number) of the user/group to run httpd as.
# It is usually good practice to create a dedicated user and group for
# running httpd, as with most system services.
#
User username
Group staff
but there are so many "httpd.conf" in XAMPP and in private/etc etc... that I feel a bit lost.
On my errorlog (that i already set up in debug mode) here is what i see:
[Fri Aug 12 16:15:34.606324 2016] [authz_core:debug] [pid 40647] mod_authz_core.c(809): [client ::1:52290] AH01626: authorization result of Require all denied: denied
[Fri Aug 12 16:15:34.606428 2016] [authz_core:debug] [pid 40647] mod_authz_core.c(809): [client ::1:52290] AH01626: authorization result of <RequireAny>: denied
[Fri Aug 12 16:15:34.606436 2016] [authz_core:error] [pid 40647] [client ::1:52290] AH01630: client denied by server configuration: /Users/username/Documents/foldername/public/
[Fri Aug 12 16:15:34.606527 2016] [authz_core:debug] [pid 40647] mod_authz_core.c(809): [client ::1:52290] AH01626: authorization result of Require all granted: granted
[Fri Aug 12 16:15:34.606533 2016] [authz_core:debug] [pid 40647] mod_authz_core.c(809): [client ::1:52290] AH01626: authorization result of <RequireAny>: granted
[Fri Aug 12 16:15:34.606591 2016] [charset_lite:debug] [pid 40647] mod_charset_lite.c(219): [client ::1:52290] AH01448: incomplete configuration: src unspecified, dst unspecified
[Fri Aug 12 16:15:34.607115 2016] [authz_core:debug] [pid 40647] mod_authz_core.c(809): [client ::1:52290] AH01626: authorization result of Require all granted: granted
[Fri Aug 12 16:15:34.607130 2016] [authz_core:debug] [pid 40647] mod_authz_core.c(809): [client ::1:52290] AH01626: authorization result of <RequireAny>: granted
[Fri Aug 12 16:15:34.607139 2016] [charset_lite:debug] [pid 40647] mod_charset_lite.c(219): [client ::1:52290] AH01448: incomplete configuration: src unspecified, dst unspecified
Finally found out:
The file that I needed to modify was located here:
/Applications/XAMPP/xamppfiles/etc/httpd.conf
What I needed to add inside this file was:
<Directory "/Users/username/Documents/foldername">
Options +Indexes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
Explanation:
The reason why I needed to insert the bloc above is: at the begining of httpd.conf, this part sets every folder as follows:
<Directory />
AllowOverride none
Require all denied
</Directory>
Which very probably causes Laravel to be denied from accessing the project folder
Now the error-log looks good:
[Tue Aug 16 14:47:12.326388 2016] [authz_core:debug] [pid 13960] mod_authz_core.c(809): [client ::1:52515] AH01626: authorization result of <RequireAny>: granted
Looking at it now, the difficult part was to fin the proper httpd.conf, among the numerous files named the same. I hope it will help

WAMP 403 forbidden from external sources

I have read a ton of threads here and elsewhere but none of the suggestions have worked. I installed the latest version of WAMP 64 bit on a fresh install of Windows Server 2012 R2.
I created a subdirectory within the www directory called andrew. In that is an index.html file.
I added the following to the hosts file:
127.0.0.1 andrew
::1 andrew
I added the following to the httpd-vhosts.conf file:
<VirtualHost *:80>
DocumentRoot "c:/wamp64/www/andrew"
ServerName andrew
<Directory "c:/wamp64/www/andrew">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
I uncommented the virtual hosts line in httpd.conf
I stopped and started net dnscache
I restarted the WAMP services
I "Put Online" the WAMP server
Regardless, when I access the server from another machine like [server IP address]*/andrew/index.html I get a 403 Forbidden error.
Here is the apache error log ("[SERVER IP]" is really the server's actual IP):
[Fri Apr 22 17:10:32.628356 2016] [mpm_winnt:notice] [pid 4680:tid 424] AH00422: Parent: Received shutdown signal -- Shutting down the server.
[Fri Apr 22 17:10:34.656507 2016] [mpm_winnt:notice] [pid 4444:tid 312] AH00364: Child: All worker threads have exited.
[Fri Apr 22 17:10:34.672087 2016] [mpm_winnt:notice] [pid 4680:tid 424] AH00430: Parent: Child process 4444 exited successfully.
[Fri Apr 22 17:10:34.921723 2016] [auth_digest:notice] [pid 4724:tid 416] AH01757: generating secret for digest authentication ...
[Fri Apr 22 17:10:34.952892 2016] [mpm_winnt:notice] [pid 4724:tid 416] AH00455: Apache/2.4.17 (Win64) PHP/5.6.16 configured -- resuming normal operations
[Fri Apr 22 17:10:34.952892 2016] [mpm_winnt:notice] [pid 4724:tid 416] AH00456: Apache Lounge VC14 Server built: Oct 11 2015 11:49:07
[Fri Apr 22 17:10:34.952892 2016] [core:notice] [pid 4724:tid 416] AH00094: Command line: 'C:\\wamp64\\bin\\apache\\apache2.4.17\\bin\\httpd.exe -d C:/wamp64/bin/apache/apache2.4.17'
[Fri Apr 22 17:10:34.952892 2016] [mpm_winnt:notice] [pid 4724:tid 416] AH00418: Parent: Created child process 4388
[Fri Apr 22 17:10:35.140157 2016] [auth_digest:notice] [pid 4388:tid 312] AH01757: generating secret for digest authentication ...
[Fri Apr 22 17:10:35.171357 2016] [mpm_winnt:notice] [pid 4388:tid 312] AH00354: Child: Starting 64 worker threads.
[Fri Apr 22 17:10:49.899265 2016] [authz_core:error] [pid 4388:tid 1040] [client 73.82.23.97:57193] AH01630: client denied by server configuration: C:/wamp64/www/andrew/index.html
[Fri Apr 22 17:10:50.055249 2016] [authz_core:error] [pid 4388:tid 1040] [client 73.82.23.97:57193] AH01630: client denied by server configuration: C:/wamp64/www/favicon.ico, referer: http://[SERVER IP]/andrew/index.html
I am now thinking it has to do with some setting on Windows 2012 Server, but I can't figure it out. Help.
Because Apache doesn't know to associate the IP address with your virtual host, it uses the main server settings. Probably you don't need a virtual host at all, but try this anyway:
<VirtualHost *:80>
DocumentRoot "c:/wamp64/www/andrew"
ServerName andrew
#of course, enter your IP address here
ServerAlias 1.2.3.4
<Directory "c:/wamp64/www/andrew">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
please don't forget to edit phpMyAdmin.conf file. It will save your time to face 403 Error (403 Forbidden). You should set Require all granted into it as follows (indipendently by used phpMyAdmin version):
Alias /phpmyadmin "c:/wamp64/apps/phpmyadmin5.0.2/"
<Directory "c:/wamp64/apps/phpmyadmin5.0.2/">
Options +Indexes +FollowSymLinks +MultiViews
AllowOverride all
Require all granted
# To import big file you can increase values
php_admin_value upload_max_filesize 128M
php_admin_value post_max_size 128M
php_admin_value max_execution_time 360
php_admin_value max_input_time 360
</Directory>

PHP file is not executing code

My PHP code is not executed when I access the root directory with
http://localhost/sample.php
The code I want to run is:
<?php phpinfo(); ?>
But my code is just shown on the browser, it is not executing.
I tried to:
restart all services several times including putting WampServer online;
changing the listening port in httpd.conf to 8080.
There is not any error in the PHP error log But in Apache Error Log there are errors as following:
[Tue Jun 09 08:53:52 2015] [notice] Apache/2.2.21 (Win32) PHP/5.3.10 configured -- resuming normal operations
[Tue Jun 09 08:56:30 2015] [error] [client ::1] client denied by server configuration: C:/wamp/www/
[Tue Jun 09 08:56:30 2015] [error] [client ::1] client denied by server configuration: C:/wamp/www/favicon.ico, referer: http://localhost/
[Tue Jun 09 09:22:23 2015] [error] [client ::1] (20023)The given path was above the root path: Cannot map GET /C:/wamp/www HTTP/1.1 to file
[Tue Jun 09 09:22:24 2015] [error] [client ::1] client denied by server configuration: C:/wamp/www/favicon.ico, referer: http://localhost/C:/wamp/www
[Tue Jun 09 09:26:26 2015] [error] [client ::1] client denied by server configuration: C:/wamp/www/
[Tue Jun 09 09:26:26 2015] [error] [client ::1] client denied by server configuration: C:/wamp/www/favicon.ico, referer: http://localhost/
[Tue Jun 09 09:26:46 2015] [error] [client ::1] client denied by server configuration: C:/wamp/apps/phpmyadmin3.4.10.1/
[Tue Jun 09 09:26:46 2015] [error] [client ::1] client denied by server configuration: C:/wamp/www/favicon.ico, referer: http://localhost/phpmyadmin/
[Tue Jun 09 09:30:10 2015] [error] [client ::1] client denied by server configuration: C:/wamp/apps/phpmyadmin3.4.10.1/
[Tue Jun 09 09:30:10 2015] [error] [client ::1] client denied by server configuration: C:/wamp/www/favicon.ico, referer: http://localhost/phpmyadmin/
[Tue Jun 09 09:31:21 2015] [error] [client ::1] client denied by server configuration: C:/wamp/apps/phpmyadmin3.4.10.1/
[Tue Jun 09 09:31:21 2015] [error] [client ::1] client denied by server configuration: C:/wamp/www/favicon.ico, referer: http://localhost/phpmyadmin/
Your problem is that your browser has decided to use the IPV6 stack rather than the IPV4 stack hence the ip address ::1 in the error messages rather that the more usual `127.0.0.1' IPV4 loopback address.
As IPV6 was very new when the version of WAMPServer that comes with Apache/2.2.21 Apache was released, and is not configured to expect access from the IPV6 loopback address ::1 so you will have to amend the config.
Edit httpd.conf using the wampmanager menus to make sure you edit the correct file. Then look for this section, it will probably look something like this :-
<Directory "c:/wamp/www/">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.2/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride all
#
# Controls who can get stuff from this server.
#
# onlineoffline tag - don't remove
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</Directory>
So change these lines as follows
# onlineoffline tag - don't remove
Order Deny,Allow
Deny from all
Allow from 127.0.0.1 ::1 localhost <-- this line
See I have added the ip address ::1 and also localhost
You will also have to change the file that controls access to phpMyAdmin in the same way :-
Edit \wamp\alias\phpmyadmin.conf and change
Order Deny,Allow
Deny from all
Allow from localhost 127.0.0.1
To
Order Deny,Allow
Deny from all
Allow from localhost 127.0.0.1 ::1
You may also need to amend the sqlbuddy and webgrind configs in the same way if you actually use those features.
I assume that you are using windows 8.
Try these:
1. In httpd.conf file, change
Listen 80 line with Listen 127.0.0.1:8080
2. Disable windows firewall. If it works that way, you need to open your port 8080 (adding an exception to windows firewall).
3. If there are any services using port 8080, stop these services, restart wampserver and try again.
4. If none of these works for you, try to change these lines in your wampserver apache configuration file (httpd.conf) and after saving, restart the apache server.
Order Deny, Allow
Deny from all
Allow from 127.0.0.1 :: 1 localhost
Allow from 192.168
Allow from 10.186
First check your localhost is running or not by
http://localhost
if it was not working then it could because of 8080 port conflict assign some other port to apache.Even this could not solve your problem then fastest and easiest way to get rid of this thing is by reinstalling your wampserver download it from here http://www.wampserver.com/en/ a nice installation description provided there.

Categories