Apache httpd got 403 forbidden on MacOS High Sierra - macos

I tried to install Apache HTTPD via Homebrew with brew install apache2, it worked well with default configuration http://localhost:8080
However, once I added more virtual host, to another folder (actually just clone the www folder to new one), and then tried to access to that new virtual host, I got 403 Forbidden error.
I don't think there was any wrong configuration, because it worked well with Apache2 on Ubuntu, but don't know why it's broken on MacOS, even I changed permission to 777 for that new www folder
Thanks

I hit the same wall, so I'd like to share my experience and hope it can help.
First of all, look at the error message in the log file that you specified for your virtual host.
If you see something like:
[authz_core:error] [pid 57233] [client 127.0.0.1:55693] AH01630: client denied by server configuration: /opt/local/www/your_vhost/
which indicates the module authz_core cause the forbidden. In this case, add Require all granted in your VirtualHost block can solve the problem.
There are different modules can cause the same problem, so you'd better to see the message in the log first.

The Apache2 error log helped me solved the mystery. It turned out that 127.0.0.1 is pointed to a VH with folder location in where there is no index.html. I thought it was pointing to my Docroot as in the case of the localhost.

Related

Apache gives Access denied on macOS Catalina

I have Apache webserver (the one supplied by Apple) running on my Macbook and it ran flawlessly, until I upgraded to Catalina 10.15.
I used the same httpd.conf, but now it is displaying
You don't have permission to access this resource.Server unable to read htaccess file, denying access to be safe
I thought is was folder access by Catalina, but I don't know how to let Apache access the web root folder (which is inside my /Users/me/Documents folder)as Apache is not a normal /Application.
Port 80 is open when I check with lsof -nP -i4TCP:80 | grep LISTEN op nmap, so Apache does start.
I set a simple index.html in the root folder, but the problem persists.
And when I remove the .htaccess from the Apache root folder I get:
You don't have permission to access this resource.
Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.
What can be the problem here ?
I have found the solution, myself.
It is a Catalina issue:
Go to System Preferences => Security & Privacy => Full Disk Access
Click on the "+" button to add an app and go to the root folder of the disk and press
Cmd + Shift + .(dot)
Go to /usr/sbin/ and select httpd.
That worked for me.
i had the same error, the problem in my case was that macOS Catalina comes with the php module disable by default, in the error log apear as:
tail /private/var/log/apache2/error_log
[Wed Feb 26 18:10:57.123036 2020] [autoindex:error] [pid 3145] [client
127.0.0.1:53734] AH01276: Cannot serve directory /Library/WebServer/Documents/subdir/: No matching DirectoryIndex
(index.html) found, and server-generated directory index forbidden by
Options directive
the apache server was loking for index.html instead of index.php so it was blocking the list directory, I uncommented the line #LoadModule php7_module libexec/apache2/libphp7.so in /etc/apache2/httpd.conf and restart the apache server
sudo apachectl restart
and it just work. hope it helps.
The above answer save my life!
I tried all the different Apache configs possible, nothing worked.
Just a small correction for step 2 - click on the "+" sign to add an app, navigate to the root folder then press Cmd + Shift + .(dot) which will show all hidden folders and allow you to see the folder in step 3 (/usr/sbin/)
I wish Apple would have at least shown some error in such a case...
Mac catalina apache forbidden issue
Step 1: sudo code /etc/apache2/httpd.conf
Step 2:search for line #LoadModule php7_module libexec/apache2/libphp7.so
and uncomment no need to delete it.
Step 3: sudo apachectl restart
Step 4: open Web browsers type localhost
Step5: Done

Laravel ReST API URL 404 not found on AWS EC2 in Apache + mySQL environment - The request URL was not found on this server

This question is on AWS Laravel Implementation on Apache + mySQL AWS EC2 instance.
After copying the working Laravel folder from xampp/htdocs/my_project_name, migration to create tables in mySQL database and seeder are working.
However, I could not connect to my APIs using Postman. (404 not found)
I following these solution links
laravel the requested url was not found on this server
https://laracasts.com/discuss/channels/general-discussion/laravel-5-the-requested-url-was-not-found-on-this-server
I managed to modify the httpd.conf. However, I could not find file .htaccess
(
where .htacces i can find? Sorry for stupid question, but i can't find :) – MilanNz Mar 11 '15 at 12:30
#MilanNz The .htaccess can be found in the public directory of your application. However the code from this answer goes inside a vhost file. The location of that depends on your server. (e.g. for apache2 and unix it's usually at /etc/apache2/sites-available)
)
Also, I was not able to reboot my Apache using "service apache2 restart".
So I "sudo reboot"ed the EC2 instance and reconnected using Postman, the API urls were still not found.
There is a possibility that my URL is wrong. So I attach it here:
The URL used is http://ec2-??-??-???-??.us-east-2.compute.amazonaws.com/my_project_name/public/api/resultCRUD/list
The working xampp URL is http://localhost/my_project_name/public/api/resultCRUD/list
The Laravel project folder is located at /var/www/html/my_project_name on AWS EC2.
http://ec2-??-??-???-??.us-east-2.compute.amazonaws.com/phpinfo.php and
http://ec2-??-??-???-??.us-east-2.compute.amazonaws.com/phpMyAdmin/ are working.
Any help is greatly appreciated. Thanks!
It's finally working.
The reason I was stuck is because most of the answers are for ubuntu while I am using RedHat.
For RedHat EC2 instance, need first change the content of /etc/httpd/conf/httpd.conf following https://pinecode.io/article/setting-up-laravel-56-on-aws-linux,
In this step, I actually changed all "AllowOverride None"s to "AllowOverride All" instead of only line 151 of httpd.conf.
Then need to restart httpd using sudo service httpd restart
following https://gistpages.com/posts/enable_mod_rewrite_in_apache2_on_red_hat_linux
Then it is working all fine.
I didn't restart my apache service after saving changes to httpd.conf when I was asking this question.

Laravel - Generic Apache 500 error with Envoyer directory structure

I am trying to deploy my Laravel 5 site to my VPS using Envoyer. I changed the document root in the site's Apache settings to /current/public (settings below), when I do this I receive a generic Apache 500 error. If I use the old public directory, everything loads properly.
I also tried chmod 777 -R storage, no luck. There are no log entries in the Laravel log, everything deploys fine without errors.
I did notice that if I create a plain HTML document and deploy it via Envoyer, I am able to access it directly with the /current/public document root, anything related to Laravel (and only using current/public), results in the 500.
Ideas? Would a symlink be a possible solution? Oddly, my Forge configuration on my other Envoyer site has the document root set to public, yet there is no symlink to current/public that I can see. It may be set to current/public and just not displaying that for some reason.
customlog:
-
format: combined
target: /usr/local/apache/domlogs/mydomain.org
-
format: "\"%{%s}t %I .\\n%{%s}t %O .\""
target: /usr/local/apache/domlogs/mydomain.org-bytes_log
documentroot: /home/eyf/current/public
group: eyf
hascgi: 1
homedir: /home/eyf
ifmoduleconcurrentphpc: {}
ifmodulemodsuphpc:
group: eyf
ip: MY.IP.ADDR
owner: root
phpopenbasedirprotect: 1
port: 80
scriptalias:
-
path: /home/eyf/public/cgi-bin
url: /cgi-bin/
-
path: /home/eyf/public/cgi-bin/
url: /cgi-bin/
serveradmin: webmaster#mydomain.org
serveralias: www.mydomain.org
servername: mydomain.org
usecanonicalname: 'Off'
user: eyf
userdirprotect: ''
Okay, so I encountered two separate problems here.
The first problem was the fact that I was deploying code as root and trying to access a site owned by a cPanel user (eyf in this case). Because the files/directories were deployed as root, an ownership issue caused the generic 500 error page.
I then tried to connect via Envoyer with eyf and there was some sort of SSH key issue - even though I added the key to eyf via cPanel, it did not seem to take. Repeated attempts to connect from Envoyer eventually lead the IP address to be blacklisted.
In response to this, Envoyer simply said "Failed" when trying to connect to the server. Immediately after saying "Failed," a warning message would appear saying that there was a problem with PHP-FPM.
Taylor says that this PHP-FPM warning message appears because the connection was unsuccessful and Envoyer could not connect to PHP-FPM. Well, this is totally misleading because I do not have PHP-FPM installed on this server and it has absolutely nothing to do with why the connection failed (it was an SSH authentication problem).
I asked him to please improve the warnings/errors for things like this, it stretched what should have been a quick fix into a several hour long tail chasing session. Dploy.io, a competitor, clearly showed an SSH connection issue when I first attempted to connect and had forgot the SSH key - "d'oh! Let me fix that," problem solved in less than a minute.
Anyway, back to Envoyer bliss - just a bit ticked. ;) The IP addresses were whitelisted, I added the SSH key manually for the cPanel user (/.ssh/id_rsa), and now everything works.

Apache, permission denied accessing the web app folder after upgrading OSX to 10.9.2

My Apache used to work fine, but I assume that problems came after upgrading OSX to 10.9.2, (anyway not certain about when the problem came) Apache was not working with the current configuration.
I tried apachectl configtest so I found out that the Apache's file structure on my machine was changed, from Library/WebServer/Documents/ to Library/WebServer/Apache Home so I edited the DocumentRoot of httpd.conf to point to the new folder.
But the problem I still cannot fix is about the permission. I got 403 Forbidden, You don't have permission to access / on this server.
Extra Information
I hosted all my web projects at /Users/myname/home_www this folder and it's sub folders belong to _www group, and has 775 access permission. I created a symlink at Library/WebServer/Apache Home (all these setup used to work fine)
I noticed some strange thing that the Library/WebServer/ and its sub folders belong to wheel group, I never paid attention to these folders before that what group they belong to.
OSX: 10.9.2
Apache: 2.2.26
As I said in my case all problems seem to come after upgrading to 10.9.2, these are steps I have done to solve my problems.
Edit DocumentRoot to DocumentRoot "/Library/WebServer/Apache Home"
Edit <Directory> to <Directory "/Library/WebServer/Apache Home">
This step may not be necessary but just in case, brew upgrade
Chenge owner and group of /usr/local/var/mysql/ to *mysql using sudo chown -R _mysql:_mysql /usr/local/var/mysql/, otherwise mysql.server start will fail

Joomla Extension Manager issue - Getting an HTTP 500 Server error

I am using Joomla on my website. Now when i try to access the Extension Manager under Extensions, it gives me the following server error
The website encountered an error while retrieving
http://myURL/upload/administrator/index.php?option=com_installer.
It may be down for maintenance or configured incorrectly.
How do i fix it?
Thanks
You should definitely find more information in the error log, but a few things to look at are:
permissions: com_installer may need the tmp folder to be writable
configuration: is your tmp folder configured properly (you can check in system information)
corruption: try reinstalling the update package of Joomla over your current installation (the update package) with ftp/shell
improper routing configuration: you may have some wrong configuration either in your httpd.conf or .htaccess file (try renaming them quickly to see if this is the issue; look for an .htaccess in the administrator folder, and each parent up to the web root (so ./uploads/administrator, ./uploads, . )
I repeat, reading the error log (apache error_log or php error, or turn on debug in Joomla) should give you more than enough information to pinpoint the issue.
I had the same issue when I had forgotten to rename htaccess.txt to .htaccess

Resources