403 Forbidden apache mac os - macos

Help set up a virtual host. In the file /etc/apache2/httpd.conf I uncommented this line here:
# Virtual hosts
Include /private/etc/apache2/extra/httpd-vhosts.conf
Next, the file is opened, and in the end ordered a new virtual host:
<VirtualHost *:80>
ServerName localhost
DocumentRoot "/Library/WebServer/Documents/"
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot "/Users/igor/sites/advanced"
ServerName advanced
ErrorLog "/private/var/log/apache2/lab.domain-error_log"
CustomLog "/private/var/log/apache2/lab.domain-access_log" common
<Directory "/Users/igor/sites/advanced/">
Options Indexes MultiViews
AllowOverride All
Allow from all
Require all granted
</Directory>
</VirtualHost>
Then added to the hosts 127.0.0.1 advanced. Restart Apache, but the browser displays a 403 error! What could it be?

Related

csrf_token error in virtual host in Ubuntu

My laravel project working fine on 127.0.0.1 but when trying to run on a virtual host I am getting a csrf_token mismatch error.
This is my .conf file code
<VirtualHost *:80>
ServerAdmin admin#server.in
ServerName test.local
ServerAlias test.local
<Directory /var/www/html/test/development/public>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
DocumentRoot /var/www/html/test/development/public/
</VirtualHost>

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 create virtual host in Xampp windows 10

I want to setup virtual host for my local project.
I added this code into C:\xampp\apache\conf\extra\httpd-vhosts.conffile.
<VirtualHost *:80>
DocumentRoot "c:/xampp/htdocs/bab/"
ServerName bab.local
<Directory "c:/xampp/htdocs/bab/">
</Directory>
</VirtualHost>
I added this code into C:\Windows\System32\drivers\etc\hostsfile.
127.0.0.1 bab.local
please help.....
You need to correct your settings like below :- need to define {projectName}
<VirtualHost *:80>
DocumentRoot "c:/xampp/htdocs/bab/{projectName}"
ServerName bab.local
<Directory "c:/xampp/htdocs/bab/">
</Directory>
</VirtualHost>

Virtual Hosts with Laravel and Apache, cannot set ip to website name

I want to set the ip for my website to an alphabetized name (i.e. http://54.183.131.205 to http://www.rblog.com). Although I have configured my rblog.com.conf in /etc/apache2/sites-available, enabled it and reloaded my apache server, and then adding to my /etc/hosts file 54.183.131.205 www.rblog.com (a tab between the ip and website name), typing in www.rblog.com into my browser doesn't redirect me to my index.php file. However, note that when I type in the ip address in the browser it takes me to my index.php file (I believe this means my rblog.com.conf file is correct?).
<VirtualHost *:80>
ServerAdmin webmaster#rblog.com
ServerName www.rblog.com
ServerAlias www.rblog.com
DocumentRoot /var/www/html/rblog/public
<Directory /var/www/html/rblog/public>
Options -Indexes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
<FilesMatch \.php$>
</FilesMatch>
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster#rblog.com
ServerName rblog.com
ServerAlias www.rblog.com
DocumentRoot /var/www/html/rblog/public
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
We can use the a2ensite tool to enable each of our sites like this:
sudo a2ensite example.com.conf
sudo a2ensite test.com.conf
When you are finished, you need to restart Apache to make these changes take effect:
sudo service apache2 restart
/etc/hosts file
54.183.131.205 rblog.com

Apache gives me 403 Access Forbidden when DocumentRoot points to two different drives

I am getting an 403 access forbidden when attempting to open a page under a vhost where the document root is sitting on a different drive than where apache is sitting. I installed using the apachefriends release. This is my httpd-vhosts.conf file:
NameVirtualHost 127.0.0.1
<VirtualHost 127.0.0.1>
ServerName foo.localhost
DocumentRoot "C:/xampp/htdocs/foo/public"
</VirtualHost>
<VirtualHost 127.0.0.1>
ServerName bar.localhost
DocumentRoot "F:/bar/public"
</VirtualHost>
When opening bar.localhost in my browser, Apache is giving me 403 Access Forbidden. I tried setting lots of different access rights, even full rights to everyone, but nothing I tried helped.
Edit: Thanks! For future reference, add 'Options indexes' within to show directory indexes.
You did not need
Options Indexes FollowSymLinks MultiViews Includes ExecCGI
AllowOverride All
Order Allow,Deny
Allow from all
Require all granted
the only thing what you need is...
Require all granted
...inside the directory section.
See Apache 2.4 upgrading side:
http://httpd.apache.org/docs/2.4/upgrading.html
Somewhere, you need to tell Apache that people are allowed to see contents of this directory.
<Directory "F:/bar/public">
Order Allow,Deny
Allow from All
# Any other directory-specific stuff
</Directory>
More info
For Apache 2.4.2: I was getting 403: Forbidden continuously when I was trying to access WAMP on my Windows 7 desktop from my iPhone on WiFi. On one blog, I found the solution - add Require all granted after Allow all in the <Directory> section. So this is how my <Directory> section looks like inside <VirtualHost>
<Directory "C:/wamp/www">
Options Indexes FollowSymLinks MultiViews Includes ExecCGI
AllowOverride All
Order Allow,Deny
Allow from all
Require all granted
</Directory>
I have fixed it with removing below code from
C:\wamp\bin\apache\apache2.4.9\conf\extra\httpd-vhosts.conf file
<VirtualHost *:80>
ServerAdmin webmaster#dummy-host.example.com
DocumentRoot "c:/Apache24/docs/dummy-host.example.com"
ServerName dummy-host.example.com
ServerAlias www.dummy-host.example.com
ErrorLog "logs/dummy-host.example.com-error.log"
CustomLog "logs/dummy-host.example.com-access.log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster#dummy-host2.example.com
DocumentRoot "c:/Apache24/docs/dummy-host2.example.com"
ServerName dummy-host2.example.com
ErrorLog "logs/dummy-host2.example.com-error.log"
CustomLog "logs/dummy-host2.example.com-access.log" common
</VirtualHost>
And added
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot "c:/wamp/www"
ServerName localhost
ErrorLog "logs/localhost-error.log"
CustomLog "logs/localhost-access.log" common
</VirtualHost>
And it has worked like charm
Solved 403: Forbidden when visiting localhost. Using ports 80,443,3308 (the later to handle conflict with MySQL Server installation)
Windows 10, XAMPP 7.4.1, Apache 2.4.x My web files are in a separate folder.
httpd.conf - look for these lines and set it up where you have your files, mine is web folder.
DocumentRoot "C:/web"
<Directory "C:/web">
Changed these 2 lines.
<VirtualHost *:80>
ServerAdmin webmaster#localhost.com
DocumentRoot "C:/web/project1"
ServerName project1.localhost
<Directory "C:/web/project1">
Order allow,deny
allow from all
</Directory>
</VirtualHost>
to this
<VirtualHost *:80>
ServerAdmin webmaster#localhost.com
DocumentRoot "C:/web/project1"
ServerName project1.localhost
<Directory "C:/web/project1">
Require all granted
</Directory>
</VirtualHost>
Add your details in your hosts file
C:\Windows\System32\drivers\etc\hosts file
127.0.0.1 localhost
127.0.0.1 project1.localhost
Stop start XAMPP, and click Apache admin (or localhost) and the wonderful XAMPP dashboard now displays! And visit your project at project1.localhost

Resources