Apache2 setup macOS Monterey error Forbidden - macos

I'm looking for a way to use multiple DocumentRoots on the local Apache server of MacOs Monterey. localhost works very well but for the other locations I have an error "Forbidden You don't have permission to access this resource."
I tried to use VirtualHost but it doesn't work
httpd.conf
ServerName localhost:80
#
# Deny access to the entirety of your server's filesystem. You must
# explicitly permit access to web content directories in other
# <Directory> blocks below.
#
<Directory />
AllowOverride none
Require all denied
</Directory>
#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "/Library/WebServer/Documents"
<Directory "/Library/WebServer/Documents">
Options FollowSymLinks Multiviews
MultiviewsMatch Any
AllowOverride All
Require all granted
</Directory>
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>
<Directory "/Library/WebServer/CGI-Executables">
AllowOverride None
Options None
Require all granted
</Directory>
Include /private/etc/apache2/other/*.conf
extra/httpd-vhosts.conf
# Virtual Hosts
Listen 80
<VirtualHost *:80>
ServerName localhost
DocumentRoot "/Library/WebServer/Documents"
</VirtualHost>
<VirtualHost *:80>
ServerAdmin example#example.com
DocumentRoot "/Users/TooikLeChevalier/Documents/IUT/S3/Prog-Web-Serveur"
ServerName iut.local
# ServerAlias iut
ErrorLog "/Users/TooikLeChevalier/Documents/IUT/S3/Prog-Web-Serveur/crash_log/Error"
CustomLog "/Users/TooikLeChevalier/Documents/IUT/S3/Prog-Web-Serveur/crash_log/Custom" common
<Directory "/Users/TooikLeChevalier/Documents/IUT/S3/Prog-Web-Serveur">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerAdmin example#example.com
DocumentRoot "/Users/TooikLeChevalier/Documents/Perso/EclypseGames/Local_Dev"
ServerName eclypsegames.local
ErrorLog "/Users/TooikLeChevalier/Documents/Perso/EclypseGames/Local_Dev/crash_log/Error"
CustomLog "/Users/TooikLeChevalier/Documents/Perso/EclypseGames/Local_Dev/crash_log/Custom" common
<Directory "/Users/TooikLeChevalier/Documents/Perso/EclypseGames/Local_Dev">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
../hosts
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
127.0.0.1 iut.local
127.0.0.1 eclypsegames.local
I have enclosed with you all the documents that could be useful in solving my problem.
Thanks in advance for your help

Related

Apache 2.4.46 virtual hosts on windows 10

I have a virtual host configure in my httpd-vhosts.conf, and when i enable (uncommented) virtual hosts on httpd.conf and try to access localhost or any link inside local that is not configured in v-host, always show me Forbidden You don't have permission to access this resource.
(httpd-vhosts.conf)
<VirtualHost *:80>
ServerName workshop.test
ServerAlias www.workshop.test
DocumentRoot "C:/Apache24/htdocs/workshop/workshop_app/public"
ErrorLog "logs/workshop.test-error.log"
CustomLog "logs/workshop.test-access.log" common
</VirtualHost>
(httpd.conf)
Include conf/extra/httpd-vhosts.conf
Add this within your workshop.test vhost block:
<Directory "C:/Apache24/htdocs/workshop/workshop_app/public">
DirectoryIndex index.php
Options Indexes FollowSymLinks ExecCGI Includes
AllowOverride All
Require all granted
</Directory>

How to set up a virtual host on ubuntu

I am trying to make to move to use Ubuntu for developing. I am working on an exciting Laravel project that is due to go live at the end of the month. I have cloned the repro and now trying to set up a virtual host ( my understanding is that you need this for the site work properly locally ). I have followed this video: https://www.youtube.com/watch?v=lkLAJd-Wb80&t=6s. But all I am getting is a 404 page not found. Hope someone can help with this.
<VirtualHost *:80>
<Directory /var/www/html/myapp/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
ServerName myapp.test
ServerAdmin info#myapp
DocumentRoot /var/www/html/myapp/public
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
I have also added myapp to the hosts file.
You missed the public directory while defining the path in <Directory>. It should be something like this:
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin info#myapp
ServerName myapp.test
ServerAlias myapp.test
DocumentRoot /var/www/html/myapp/public
<Directory /var/www/html/myapp/public>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
Allow from all
Require all granted
</Directory>
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
Hope this helps you.
Could you try with listening to 80 port like below?
Listen 80
<VirtualHost *:80>
<Directory /var/www/html/myapp/public>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
ServerName myapp.test
ServerAdmin info#myapp
DocumentRoot /var/www/html/myapp/public
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
My virtual host configuration is like bellow where I used 8080 port.
Listen 8080
<VirtualHost *:8080>
ServerAdmin info#gmail.com
DocumentRoot "D:/appinstall/htdocs/www/app-test-server/public"
ServerName localhost
ErrorLog "logs/app-test-server.log"
CustomLog "logs/app-test-server.log" common
</VirtualHost>

Vhost access error / wamp

I have a big problem with my vhost installation with my wamp server when i want to load my website, it display this :
"Forbidden
You don't have permission to access / on this server."
i have seen a lot of tutorials and i have try this, and it didn't work well :
in : C:\wamp64\bin\apache\apache2.4.23\conf\extra\httpd-vhosts.conf
# Virtual Hosts
#
<VirtualHost *:80>
ServerName localhost
DocumentRoot c:/wamp64/www
<Directory "c:/wamp64/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName panierdesaison79
DocumentRoot c:/wamp64/www/panierdesaison79/
<Directory "c:/wamp64/www/panierdesaison79/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
require all granted
</Directory>
</VirtualHost>
#
In : C:\Windows\System32\drivers\etc\hosts
#blablabla
# localhost name resolution is handled within DNS itself.
127.0.0.1 localhost
::1 localhost
127.0.0.1 panierdesaison79
::1 panierdesaison79
How it couldn't work?

WAMP 3.06, is Directory into Virtual Hosts broken?

I am using WAMP 3.06. I have a web site hosted in "c:/wamp64/www/webagenda"
When I try to access the site remotely using "http://cloudappoint.myvnc.com", I get:
Forbidden
You don't have permission to access /webagenda on this server.
Apache/2.4.23 (Win64) PHP/5.6.25 Server at agenda.myvnc.com Port 8000
My virtual host file is:
# Virtual Hosts
<VirtualHost *:8000>
ServerName localhost
DocumentRoot c:/wamp64/www
<Directory "c:/wamp64/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
#if I uncomment the next lines the problem is over
#<Directory "c:/wamp64/www/webagenda">
#Options Indexes FollowSymLinks Includes ExecCGI
#DirectoryIndex index.php
#AllowOverride None
#Require all granted
#</Directory>
<VirtualHost *:8000>
ServerName cloudappoint
ServerAlias cloudappoint.myvnc.com
DocumentRoot c:/wamp64/www/webagenda
ErrorLog "logs/agenda-error.log"
CustomLog "logs/agenda-access.log" common
<Directory "c:/wamp64/www/webagenda/">
Options +Indexes +FollowSymLinks +MultiViews
DirectoryIndex index.php
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
As you can see from my comments, if I I uncomment the next lines the problem is over:
<Directory "c:/wamp64/www/webagenda">
Options Indexes FollowSymLinks Includes ExecCGI
DirectoryIndex index.php
AllowOverride None
Require all granted
</Directory>
What is wrong here, please?
If moving the <Directory> block out of the <VirtualHost> block causes access to be allowed then it is a fair assumption that there is something wrong with the <VirtualHost> definition.
Can I suggest that you try this change in your definition
<VirtualHost *:8000>
ServerName cloudappoint.myvnc.com <--change
ServerAlias www.cloudappoint.myvnc.com <--change
DocumentRoot c:/wamp64/www/webagenda
ErrorLog "logs/agenda-error.log"
CustomLog "logs/agenda-access.log" common
<Directory "c:/wamp64/www/webagenda/">
Options +Indexes +FollowSymLinks +MultiViews
DirectoryIndex index.php
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
EDIT
I assume you are adding the non standard port number to the url when trying to access the site?
http://cloudappoint.myvnc.com:8000
When I add the :8000 I do not get the error I get an offline page saying
The site you have requested is currently unavailable,
please try back again later.

MAC OSX: Cannot run multiple local domains

i am trying to add another local domain to my mac osx:
No matter what i do when visiting say 'domainnumber2.dev' it always displays the first host in my list.
If i swop them around in my httpd-vhosts file then i get the domainnumber2.dev site.
How can i run multiple localhost site on my mac.
I have a simple set up as below:
<VirtualHost *:80>
ServerName mydomain.dev
ServerAlias mydomain.dev
DocumentRoot "/Users/UserName/Sites/mydomain/"
</VirtualHost>
<VirtualHost *:80>
ServerName mydomainTwo.dev
ServerAlias mydomainTwo.dev
DocumentRoot "/Users/UserName/Sites/mydomainTwo/"
</VirtualHost>
I have also had the more details set up adding the below for both
<Directory "/Users/UserName/Sites/mydomain/">
DirectoryIndex index.php
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
</Directory>
In my hosts file i have:
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost
127.0.0.1 mydomain.dev
127.0.0.1 mydomainTwo.dev
which ever VirtualHost is first is the site that is served up
I stumbled across this same problem...
In your httpd-vhosts.conf file (/private/etc/apache2/extra/httpd-vhosts.conf after showing hidden files) add the following for each domain...
<VirtualHost *:80>
ServerName mysubdomain.dev
CustomLog "/root/to/site/logs/mysubdomain.dev-access_log" combined
ErrorLog "/root/to/site/logs/mysubdomain.dev-error_log"
DocumentRoot "/root/to/site/mysubdomain.co.uk"
<Directory "/root/to/site/mysubdomain.co.uk">
DirectoryIndex index.php
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
</Directory>
</VirtualHost>
Then restart apache. Everything else you have seems to be the same as my setup.
Make sure you have the correct permissions to be able to write the log files etc too.

Resources