Forbidden: CGI Programming With Apache and Perl on Mac OS X - perl

I'd like to do the CGI programming with Apache and Perl in Max OS X 10.8.5.
I followed the guide : CGI Programming With Apache and Perl on Mac OS X. The steps are:
edit /etc/apache2/httpd.conf, uncomment the following:
AddHandler cgi-script .cgi .pl
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
edit /etc/apache2/userName.conf:
Options MultiViews Indexes SymLinksIfOwnerMatch Includes ExecCGI
DirectoryIndex index.html index.cgi
AllowOverride None
Order allow,deny
Allow from all
start apache:
sudo apachectl restart
put a cgi file into the folder: ~/Sites. I have update the privilege of test.cgi:
sudo chmod 755 test.cgi
That's all I have done. However, when I visit :
ht tp://localhost/~userName/test.cgi, the result:
Forbidden
You don't have permission to access /~username/test.cgi on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
I try to put a html into the ~/Sites, and it can be shown correctly. It seems there is something wrong with the cgi configurations, but I can't find it. Could anyone give some guides?
thanks!

The following steps worked for me on High Sierra running Apache 2.4
( Based on the following excellent tutorial: http://www.cgi101.com/book/connect/mac.html , updated with additional steps for version differences)
1) Move the file to:
/Library/WebServer/CGI-Executables
2) Verify that the file has execution permissions:
ls -l /Library/WebServer/CGI-Executables
If not use:
chmod -x /Library/WebServer/CGI-Executables/myfile.cgi
3) Uncomment the following lines in /etc/apache2/httpd.conf
AddHandler cgi-script .cgi .pl
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
LoadModule cgi_module libexec/apache2/mod_cgi.so
4) Also change the Directory "/Library/WebServer/CGI-Executables" stanza to:
<Directory "/Library/WebServer/CGI-Executables">
AllowOverride None
Options ExecCGI
Require all granted
</Directory>
5) Then restart Apache:
sudo apachectl -k restart
Almost with every new Mac OS version, the changes will become lost and you will need to redo the work, and even do different steps to fix it. Your best friend are the Apache logs located in /var/log/apache2/ (/var/log/apache2/error_log)

The OSX Apache serves "two" servers. One public directly for the localhost and one for each user. Check out the configuration of your user directories in /etc/apache2. There is a users directory having each OSX user on that machine a own configuration like that:
<Directory "/Users/markus/Sites/">
Options Indexes MultiViews FollowSymLinks Includes ExecCGI
AllowOverride All
Allow from all
</Directory>
<VirtualHost *:80>
ServerName sencha
DocumentRoot "/Users/markus/Sites/sencha"
</VirtualHost>
Also make sure, the userprofiles are enabled in the httpd.conf
# User home directories
Include /private/etc/apache2/extra/httpd-userdir.conf

The steps in CGI Programming With Apache and Perl on Mac OS X are correct. If restarting apache does not work, restart the mac! And Now I can use the cgi!

Related

Where will be the myserver.conf, hosts, and ports.conf in cPanel/WHM?

I want to customize my client's site with virtual host block. Manually I did this request on the Ubuntu server 18.04. But now I have the cPanel and the WHM access.
I read these official links.
Modify Apache Virtual Hosts with Include Files
Modify Virtualhost Containers With Include Files
But I messed regrading the include files and those directories as,
/usr/local/apache/conf/userdata/ssl/2_2/$user/$domain/$includename.conf
and
/etc/apache2/conf.d/userdata/ssl/2_4/user/domain/includename.conf
And the following scripts
To rebuild the httpd.conf file, run the following script:
/usr/local/cpanel/scripts/rebuildhttpdconf
To restart Apache, run the following script:
/usr/local/cpanel/scripts/restartsrv_httpd
Please clearly tell how can I merge this to be put using cPanel and WHM.
vhost
<VirtualHost *:9876>
ServerName 139.59.xxx.xxx
DocumentRoot /home/username/newfile/doneapi/public
<Directory /home/username/newfile/doneapi/public>
AllowOverride All
</Directory>
</VirtualHost>
hosts file
127.0.0.1 139.59.xxx.xxx
ports.conf
Listen 9876
Thanks in advance

MAMP Pro /MAMP/ start page not accessible on local network

I am trying to access the MAMP Pro /MAMP/ start page over the local network, but I get the following error in the apache log:
[Wed Feb 24 12:21:03 2016] [error] [client 192.168.1.63] client denied by server configuration: /Library/Application Support/appsolute/MAMP PRO/mamp
I have locally mapped http://dev in my host file to the ip of the server, and I am able to view the websites hosted by MAMP, but not the start page.
Some facts that may be of use to diagnose:
I am using MAMP Pro 3.5
The document root has been changed to ~/Sites
If I run normal MAMP I can access the start page fine from the local
network. This is using the same ports as MAMP Pro, the same
document root, and the same PHP version.
I am under the impression that for some reason MAMP Pro uses a different location for the mamp start page files than that of MAMP? I have found the files in:
/Library/Application Support/appsolute/MAMP PRO/mamp
and
/Applications/MAMP/bin/mamp
and the permissions seem to be the same, as is the user.
Any clues?
Thanks in advance.
Had this in the past, just use IP address of the MAMP Mac.
Sometimes I had to configure the Apache http settings and set my other local IP address in to the ALLOW part.
Greetings,
Peter
#PeterInWiesbaden's answer was helpful in pointing me in the right direction. The issue was that in my (normal) MAMP httpd.conf file I had set all the paths of the MAMP start files to be similar to the following:
Alias /MAMP "/Applications/MAMP/bin/mamp"
<Directory "/Applications/MAMP/bin/mamp">
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
but when I edited them in the httpd.conf file directly used by MAMP Pro, these get overwritten each time the server starts, as it uses a template for each Server Name.
To edit httpd.conf for MAMP Pro, it must be done through going to the following in the menu bar:
File->Edit Template->Apache->httpd.conf
And changing the MAMP Pro start pages sections similar to the following:
Alias /MAMP "/Library/Application Support/appsolute/MAMP PRO/mamp"
<Directory "/Library/Application Support/appsolute/MAMP PRO/mamp">
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>

/phppgadmin Forbidden You don't have permission to access /phppgadmin/ on this server

I recently upgrade my server from Debian Wheezy to Debian Jessie (Debian 8).
A lot of packages was updated and now, I don't have the right to access to phppgadmin from http://myIP/phppgadmin
Forbidden
You don't have permission to access /phppgadmin/ on this server.
I try a lot of thinks to solve the problem but absolutely nothing works...
In /etc/apache2/conf.d/phppgadmin:
Alias /phppgadmin /usr/share/phppgadmin
<Directory /usr/share/phppgadmin>
DirectoryIndex index.php
AllowOverride None
order allow,deny
# deny from all
allow from 127.0.0.0/255.0.0.0 ::1/128
allow from all
In /etc/apache2/sites-enabled/000-default.conf I add:
<Directory /usr/share/phppgadmin/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
I try to change the permissions of /usr/share/phppgadmin/, /var/www...
And I have the same message even if I uninstall the package phpgpadmin !
apt-get remove phppgadmin
Big thanks for help...
In Debian 8, apache2 configurations are now in /etc/apache2/conf-available and soft-linked from /etc/apache2/conf-enabled when enabled, just like virtualhosts or modules.
The phppgadmin package in its latest version comes with a predefined configuration file:
/etc/apache2/conf-available/phppgadmin.conf
This configuration should be activated by default, but otherwise it can be activated with a2enconf phppgadmin
Your old configuration /etc/apache2/conf.d/phppgadmin should be removed as well as the mentioned addition in /etc/apache2/sites-enabled/000-default.conf.
Then edit phppgadmin.conf and remove the Require local directive that you don't want if you previously had Allow from all.
you can easily solve this problem by replacing Require local directive to Allow from all in configuration file /etc/apache2/conf-available/phppgadmin.conf

AH01630: client denied by server configuration

I am assuming that I have tried all possible solutions mentioned here, but I am still unable to fix the problem.
The problem is with the httpd.conf and .htaccess files.
If I run tail -f access.log I get :
AH01630: client denied by server configuration: /opt/rpkica/share/rpki/wsgi/rpki.wsgi
This is the configuration I'm using :
<Directory /opt/rpkica/share/rpki/wsgi>
Order allow,deny
AllowOverride All
Allow from All
#Require all granted
</Directory>
Try to find .htaccess file recursively from "document root" for that virtual host. .htacces have a precedence over main configuration so check if you have deny configuration in any .htaccess file.
you need to check httpd.conf file
<Directory /path/to/directory>
Options FollowSymlinks
AllowOverride none
Require all granted
</Directory>
If you may get an error on XAMPP server, open httpd-xampp.conf file under the path /opt/lampp/etc/extra
<LocationMatch "^/(?i:(?:xampp|security|licenses|phpmyadmin|webalizer|server-status|server-info))">
# Require local
ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
</LocationMatch>
Just command the "Require local" then restart your lampp service
# /opt/lampp/lampp restart

Zend .htaccess configuration not working in Ubuntu

Hi I am running Ubuntu 10.04 LTS - the Lucid Lynx
i create a project by
zf create project test
this command automatically generates a .htaccess file which didn't work
I configured my webserver (Apache2) by editing
/etc/apache2/sites-available/default file
setting
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
and i am getting the following error
Internal Server Error
/**************************************************************************************/
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, webmaster#localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Apache/2.2.14 (Ubuntu) Server at localhost Port 80
/****************************************************************************************/
please help me
You haven't loaded mod_rewrite, so Apache doesn't know what the RewriteEngine line means.
On ubuntu you can probably do (as a super user):
a2enmod rewrite
apache2ctl restart
Otherwise you'll have to edit the apache config and add a line like this to load the module
LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so
The path on your system may be different.