403 Forbidden Error setting up Virtual Hosts - apache

I've run into this problem on other servers before, but this time I can't figure it out. I've tried looking at all the solutions on Stack Overflow, but no luck so far.
The Error: domain1 works just fine, but trying to access the index on domain2 fails.
Forbidden
You don't have permission to access /index.html on this server.
My httpd.conf
Note: domain1 is a symfony site, so the web root is /web, where as domain2 is just a static html site.
LoadModule vhost_alias_module modules/mod_vhost_alias.so
DocumentRoot "/var/www/html/domain1.com/web"
<Directory "/var/www/html/domain1.com/web">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin jason#domain2.com
DocumentRoot /var/www/html/domain2.com
ServerName domain2.com
ErrorLog logs/domain2.com-error_log
CustomLog logs/domain2.com-access_log common
</VirtualHost>
<Directory "/var/www/html/domain2.com">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride None
Allow from all
</Directory>
ls -l in /var/www/html
drwxr-xr-x 2 apache apache 4096 Jan 12 17:06 domain2.com
drwxr-xr-x 8 apache apache 4096 Jan 12 15:58 domain1.com
Other
I've already tried disabling selinux with "setenforce 0"
I've made sure to restart apache each time after changing httpd.conf by running "service httpd restart"
I've rebooted the server itself
Apache Version: 2.2.15
CentOS Version: 6.5

Related

incorrect redmine installation

I am trying to install redmine 3.2.0 like in the following article.
The point 2.4 Test Redmine works fine, i.e. I am able to open redmine using http://MY_IP:3000.
After this, I did:
sudo chown -R www-data files log tmp public/plugin_assets
sudo chmod -R 755 files log tmp public/plugin_assets
sudo ln -s /opt/redmine/redmine-3.2.2/public/ /var/www/html/redmine
Added Listen 89 into /etc/apache2/ports.conf.
Created the following sudo vim /etc/apache2/sites-available/redmine.conf:
<VirtualHost MY_IP:89>
ServerAdmin email#example
DocumentRoot /var/www/html/
<Location /redmine>
RailsEnv production
RackBaseURI /redmine
Options -MultiViews
</Location>
</VirtualHost>
Enabled redmine.conf: sudo a2ensite redmine.conf.
Added PassengerUser www-data into /etc/apache2/mods-available/passenger.conf. Now passenger.conf contains the following:
<IfModule mod_passenger.c>
PassengerRoot /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini
PassengerDefaultRuby /usr/bin/ruby
PassengerUser www-data
</IfModule>
And restarted apache: sudo service apache2 restart.
So /var/www/html/ contains:
drwxr-xr-x 2 root root 4096 Jan 25 09:32 .
drwxr-x--x 7 root root 4096 Jan 22 07:21 ..
-rw-r--r-- 1 root root 11104 Jan 22 02:57 index.html
lrwxrwxrwx 1 root root 34 Jan 25 09:32 redmine -> /opt/redmine/redmine-3.2.0/public/
Now if I am going to http://MY_IP:89 then /var/www/html/index.html is opened instead of redmine home page.
Could you please advise where I did an error?
Thanks in advance!
UPDATE:
If I use the following redmine.conf:
<VirtualHost MY_IP:89>
DocumentRoot /var/www/html/redmine
<Directory /var/www/html/redmine>
RailsBaseURI /
PassengerResolveSymlinksInDocumentRoot on
AllowOverride None
RailsEnv production
Options -MultiViews
</Directory>
</VirtualHost>
Redmine won't start, only shows index of (/var/www/html/redmine/).
I SOLVED THE ISSUE:
I did gem install passenger. And I use the following redmine.conf:
<VirtualHost MY_IP:89>
DocumentRoot /var/www/html/redmine
<Directory /var/www/html/redmine>
RailsBaseURI /
PassengerResolveSymlinksInDocumentRoot on
AllowOverride None
RailsEnv production
Options -MultiViews
</Directory>
</VirtualHost>
From passenger 5.2.0 which was released in January 2018 "PassengerResolveSymlinksInDocumentRoot on" is no longer supported
in your /etc/apache2/sites-available/xxx.conf
make the following changes:
# Not supported from passenger 5.2.0 on wards
# PassengerResolveSymlinksInDocumentRoot on
PassengerAppRoot /opt/redmine/redmine-3.2.0/public/
My redmine works on apache with this config.
LoadModule passenger_module /usr/local/rvm/gems/ruby-1.9.3-p551/gems/passenger-5.0.21/buildout/apache2/mod_passenger.so
<IfModule mod_passenger.c>
PassengerRoot /usr/local/rvm/gems/ruby-1.9.3-p551/gems/passenger-5.0.21
PassengerDefaultRuby /usr/local/rvm/gems/ruby-1.9.3-p551/wrappers/ruby
</IfModule>
<VirtualHost redmine.domain:80>
ServerName redmine.domain
ServerAlias redmine
DocumentRoot /opt/redmine/redmine-3.2.0/public/
<Directory /opt/redmine/redmine-3.2.0/public/>
# This relaxes Apache security settings.
AllowOverride all
# MultiViews must be turned off.
Options -MultiViews
allow from all
</Directory>

Apache virtualhost with debian 8

I would like to configure an apache virtualhost with Debian 8
I have installed apache2
I have create a configuration in sites-available
<VirtualHost *:80>
ServerName wiki.domain.com
ServerAlias wiki.domain.com
DocumentRoot /home/www/htdocs/wiki/
<Directory /home/www/htdocs/wiki/>
Options -Indexes FollowSymLinks
AllowOverride All
</Directory>
ErrorLog /home/www/logs/wiki/wiki_error.log
LogLevel warn
CustomLog /home/www/logs/wiki/wiki_access.log combined
ServerSignature Off
</VirtualHost>
Create a symbolic link in sites-enabled
ln -s /etc/apache2/sites-available/wiki /etc/apache2/sites-enabled/wiki
And reboot apache
/etc/init.d/apache2 restart
This configuration works with Debian 7 but with Debian 8 i am not redirected to my wiki directory when I use my domain wiki.domain.com
Add Require all granted in the directory to allow apache to access to your directory
Here is an easiest and recommanded way to enable a site with apache2:
a2ensite wiki && service apache2 restart

How to configure Apache to serve Drupal 6 Multisite configuration

I am trying to setup Apache to serve a Drupal 6 multi-site configuration, but I cannot seem to get it properly set up.
In my httpd.conf:
DocumentRoot "/Users/kevinyoung/Sites/drupal"
<Directory "/Users/kevinyoung/Sites/drupal">
Options FollowSymLinks Multiviews Indexes
MultiviewsMatch Any
AllowOverride All
Require all granted
</Directory>
DirectoryIndex index.html index.php
In httpd-vhosts.conf:
<VirtualHost *:80>
DocumentRoot "/Users/kevinyoung/Sites/drupal"
ErrorLog "/private/var/log/apache2/error_log"
CustomLog "/private/var/log/apache2/access_log" common
</VirtualHost>
<VirtualHost *:80>
ServerName drupal.local
ServerAlias *.drupal.local
DocumentRoot /Users/kevinyoung/Sites/drupal
ErrorLog "/private/var/log/apache2/error_log"
CustomLog "/private/var/log/apache2/access_log" common
</VirtualHost>
In /etc/hosts:
127.0.0.1 drupal.local
127.0.0.1 <site_name>.drupal.local
Navigating to http://localhost shows "It Works!".
Navigating to drupal.local takes me to the default site for my D6 multi-site setup.
Now lets say I have another site directory (site_A.drupal.local) as another site inside drupal/sites/. Now I go to site_A.drupal.local, but it still takes me to the default site. Why would this be happening?
Any ideas why I can't access any other site besides my default site in this Drupal 6 multi-site configuration?
I am running Apache 2.4 on Mac OSX 10.10 Yosemite with Drupal 6, mysql 5.1.73, and php 5.5.14.

Apache redirecting to removed virtual host

I have a strange issue with my Apache. I added a new virtual host and I noticed if I browse to it it redirects to another hosts home directory. I have host1, host2 and newly created host3. If I browse to address for host 3 it would take me to host1 site.
I removed host1 now but it still trying to take me to host1 (Apache log has"
[Thu Jul 24 16:31:33 2014] [error] [client 127.0.0.1] File does not exist: C:/WWW/htdocs/public/host1/index.html " which is home directory for host1 site which is removed from httpd.conf. Apache service restarted, all other .conf files checked - no mentioning of host1.
here how its configured:
################# host2 ############################
<VirtualHost host2.net:80>
DocumentRoot "C:/WWW/htdocs/host2/public/"
ServerName host2
ServerAlias host2.local
<Directory "C:/WWW/htdocs/host2/public/">
Options Indexes FollowSymLinks
DirectoryIndex index.php index.html
AllowOverride all
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
################# host3 ############################
<VirtualHost host3.net:80>
DocumentRoot "C:/WWW/htdocs/host3/public/"
ServerName host3
ServerAlias host3.local
<Directory "C:/WWW/htdocs/host3/public/">
Options Indexes FollowSymLinks
DirectoryIndex index.php index.html
AllowOverride all
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Thanks
In case anybody have the same issue - I just found one software on my PC that has been messing with port 80. Once that software removed - my apache works fine

Adding VirtualHost fails: Access Forbidden Error 403 (XAMPP) (Windows 7)

I've got a XAMPP installation running on Windows 7.
As soon as I add a VirtualHost to httpd-vhosts.conf, BOTH the 'regular' http://localhost AND the new dropbox.local aren't working.
This is what I added to my httpd-vhosts.conf:
<VirtualHost *:80>
ServerAdmin postmaster#dummy-host.localhost
DocumentRoot "E:/Documenten/Dropbox/Dropbox/dummy-htdocs"
ServerName dropbox.local
ServerAlias www.dropbox.local
ErrorLog "logs/dropbox.local-error.log"
CustomLog "logs/dropbox.local-access.log" combined
</VirtualHost>
So I looked up my dropbox.local-error.log for any information:
[Thu Feb 02 10:41:57 2012] [error] [client 127.0.0.1] client denied by server configuration: E:/Documenten/Dropbox/Dropbox/dummy-htdocs/
This error seems to be solved by adding
<directory "E:/Documenten/Dropbox/Dropbox/dummy-htdocs">
Allow from all
</directory>
But now I get this error in dropbox.local-error.log:
[Thu Feb 02 10:45:56 2012] [error] [client ::1] Directory index forbidden by Options directive: E:/Documenten/Dropbox/Dropbox/dummy-htdocs/
Furthermore when I try to access http://localhost, I dont get any error in the regular error.log, although I get the error 403 when I try to access it.
Can anybody help... It's driving me mad :S
EDIT:
Also in httpd.conf there is the following (I've seen it mentioned multiple times, so before anyone says it):
<IfModule dir_module>
DirectoryIndex index.php index.pl index.cgi index.asp index.shtml index.html index.htm \
default.php default.pl default.cgi default.asp default.shtml default.html default.htm \
home.php home.pl home.cgi home.asp home.shtml home.html home.htm
</IfModule>
Okay: This is what I did now and it's solved:
My httpd-vhosts.conf looks like this now:
<VirtualHost dropbox.local:80>
DocumentRoot "E:/Documenten/Dropbox/Dropbox/dummy-htdocs"
ServerName dropbox.local
ErrorLog "logs/dropbox.local-error.log"
CustomLog "logs/dropbox.local-access.log" combined
<Directory "E:/Documenten/Dropbox/Dropbox/dummy-htdocs">
# AllowOverride All # Deprecated
# Order Allow,Deny # Deprecated
# Allow from all # Deprecated
# --New way of doing it
Require all granted
</Directory>
</VirtualHost>
First, I saw that it's necessary to have set the <Directory xx:xx> options. So I put the <Directory > [..] </Directory>-part INSIDE the <VirtualHost > [..] </VirtualHost>.
After that, I added AllowOverride AuthConfig Indexes to the <Directory> options.
Now http://localhost also points to the dropbox-virtualhost. So I added dropbox.local to <VirtualHost *:80> which makes it as <VirtualHost dropbox.local:80>
FINALLY it works :D!
I'm a happy man! :) :)
I hope someone else can use this information.
For me worked when I changed "directory" content into this:
<Directory "*YourLocation*">
Options All
AllowOverride All
Require all granted
</Directory>
For me (also XAMPP on Windows 7), this is what worked:
<Directory "C:\projects\myfolder\htdocs">`
AllowOverride All
Require all granted
Options Indexes FollowSymLinks
</Directory>`
It is this line that would cause the 403:
Order allow,deny
I'm using XAMPP 1.6.7 on Windows 7. This article worked for me.
I added the following lines in the file httpd-vhosts.conf at C:/xampp/apache/conf/extra.
I had also uncommented the line # NameVirtualHost *:80
<VirtualHost mysite.dev:80>
DocumentRoot "C:/xampp/htdocs/mysite"
ServerName mysite.dev
ServerAlias mysite.dev
<Directory "C:/xampp/htdocs/mysite">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
After restarting the apache, it were still not working.
Then I had to follow the step 9 mentioned in the article by editing the file C:/Windows/System32/drivers/etc/hosts.
# localhost name resolution is handled within DNS itself.
127.0.0.1 localhost
::1 localhost
127.0.0.1 mysite.dev
Then I got working http://mysite.dev
Thank you, that worked! But I replaced this
AllowOverride AuthConfig Indexes
with that
AllowOverride All
Otherwise, the .htaccess didn't work: I got problems with the RewriteEngine and the error message "RewriteEngine not allowed here".
Above suggestions didn't worked for me. I got it running on my windows, using inspiration from
http://butlerccwebdev.net/support/testingserver/vhosts-setup-win.html
For Http inside httpd-vhosts.conf
<Directory "D:/Projects">
AllowOverride All
Require all granted
</Directory>
##Letzgrow
<VirtualHost *:80>
DocumentRoot "D:/Projects/letzgrow"
ServerName letz.dev
ServerAlias letz.dev
</VirtualHost>
For using Https (Open SSL) inside httpd-ssl.conf
<Directory "D:/Projects">
AllowOverride All
Require all granted
</Directory>
##Letzgrow
<VirtualHost *:443>
DocumentRoot "D:/Projects/letzgrow"
ServerName letz.dev
ServerAlias letz.dev
</VirtualHost>
Hope it helps someone !!
After so many changes and tries and answers.
For
SOs: Windows 7 / Windows 10
Xampp Version: Xampp or Xampp portable 7.1.18 / 7.3.7 (control panel v3.2.4)
Installers: win32-7.1.18-0-VC14-installer / xampp-windows-x64-7.3.7-0-VC15-installer
Do not edit other files like httpd-xampp
Stop Apache
Open httpd-vhosts.conf located in **your_xampp_directory**\apache\conf\extra\ (your XAMPP directory might be by default: C:/xampp/htdocs)
Remove hash before the following line (aprox. line 20): NameVirtualHost *:80 (this might be optional)
Add the following virtual hosts at the end of the file, considering your directories paths:
##127.0.0.1
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs"
ServerName localhost
ErrorLog "logs/localhost-error.log"
CustomLog "logs/localhost-access.log" common
</VirtualHost>
##127.0.0.2
<VirtualHost *:80>
DocumentRoot "F:/myapp/htdocs/"
ServerName test1.localhost
ServerAlias www.test1.localhost
ErrorLog "logs/myapp-error.log"
CustomLog "logs/myapp-access.log" common
<Directory "F:/myapp/htdocs/">
#Options All # Deprecated
#AllowOverride All # Deprecated
Require all granted
</Directory>
</VirtualHost>
Edit (with admin access) your host file (located at Windows\System32\drivers\etc, but with the following tip, only one loopback ip for every domain:
127.0.0.1 localhost
127.0.0.2 test1.localhost
127.0.0.2 www.test1.localhost
For every instance, repeat the second block, the first one is the main block only for "default" purposes.
I am using xampp 1.7.3. Using inspiration from here: xampp 1.7.3 upgrade broken virtual hosts access forbidden
INSTEAD OF add <Directory> .. </Directory> in httpd-vhosts.conf, I add it in httpd.conf right after <Directory "D:/xampplite/cgi-bin"> .. </Directory>.
Here is what I add in httpd.conf:
<Directory "D:/CofeeShop">
AllowOverride All
Options All
Order allow,deny
Allow from all
</Directory>
And here is what I add in httpd-vhosts.conf
<VirtualHost *:8001>
ServerAdmin postmaster#dummy-host2.localhost
DocumentRoot "D:/CofeeShop"
ServerName localhost:8001
</VirtualHost>
I also add Listen 8001 in httpd.conf to complete my setting.
Hope it helps
For many it's a permission issue, but for me it turns out the error was brought about by a mistake in the form I was trying to submit. To be specific i had accidentally put a "greater than" sign after the value of "action". So I would suggest you take a second look at your code.