I'm just started using a VPS and i'm pretty new to Apache and everything.
So i have a few sites up and running, but for some reason i can't get Multiviews to work. I've searched on the internet and found an article that describes my problem, but their solution doesn't work. Also this thread on stackoverflow don't seem to work for me.
I started with the following (site.conf) configuration file in /etc/apache2/sites-availlable
<VirtualHost *:80>
ServerName site.com
DocumentRoot /var/www/vhosts/site.com/webroot/
<Directory /var/www/vhosts/site.com/webroot/>
Options Indexes FollowSymLinks Multiviews
AllowOverride all
</Directory>
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/site_acces.log combined
ErrorLog ${APACHE_LOG_DIR}/site_error.log
</VirtualHost>
Now when i go to www.site.com/index.php it works fine, but www.site.com/index gives me a 404 and the following log message:
[Tue Feb 24 10:18:45 2015] [error] [client 213.125.184.74] Negotiation: discovered file(s) matching request: /var/www/vhosts/site.com/webroot/index (None could be negotiated).
So i changed site.conf to the following:
<VirtualHost *:80>
ServerName site.com
DocumentRoot /var/www/vhosts/site.com/webroot/
<Directory /var/www/vhosts/site.com/webroot/>
Options Indexes +FollowSymLinks -Multiviews
AllowOverride all
</Directory>
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/site_acces.log combined
ErrorLog ${APACHE_LOG_DIR}/site_error.log
</VirtualHost>
Unfortunately, still the same error in my log file, so i disabled the negotiation module (as mentioned), but that just gives me this message:
[Tue Feb 24 10:21:02 2015] [error] [client 213.125.184.74] File does not exist: /var/www/vhosts/site.com/webroot/index
After all my modifications to site.conf i did an service apache2 restart and/or service apache2 reload
At this point i have no clue on how to solve this problem so i hope anyone point me in the right direction.
I think "Options Indexes FollowSymLinks Multiviews" is the correct configuration. And yes, you need do "apache reload" after you modify the configuration.
Also make sure you accept "php" in content Negotiation. (by default it might not accept)
Related
I'm sure this question has been asked and answered, but I'm not finding a solution. I have a virtual host I have just added SSL to, and it isns't working as expected. The non-SSL version is working properly. Below is what I've got in httpd.conf:
<VirtualHost mysite.com:443>
ServerAdmin email#myemail.com
ServerName mysite.com
ServerAlias www.mysite.com
DocumentRoot /var/www/html/www.mysite.com
<Directory /var/www/html/www.mysite.com>
DirectoryIndex index.html index.htm index.php
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
Require all granted
</Directory>
SSLEngine on
SSLCertificateFile /etc/pki/tls/certs/my.crt
SSLCertificateKeyFile /etc/pki/tls/private/my.key
</VirtualHost>
The error I'm getting is:
[Thu Jan 11 12:29:58.984354 2018] [autoindex:error] [pid 19998] [client
IP:38470] AH01276: Cannot serve directory /var/www/html/: No matching
DirectoryIndex (index.html,index.php) found, and server-generated directory
index forbidden by Options directive
Obviously, I've got the directory set as /var/www/html/www.mysite.com, but it's trying to serve content directly from /var/www/html.
I'm sure this is something simple, but my brain is already oatmeal from working on this site all day, so I'm probably just failing to see what's right in front of my face.
Thanks!
Fixed it. Simple enough, as I assumed. Change:
<VirtualHost mysite.com:443>
To:
<VirtualHost *:443>
So I've been reading up a lot on the subject but can't figure out what I'm doing wrong, I also tried a couple solutions found here but still...
I have multilple vhosts set up with Apache, everything working fine serving different files from both /home/usr1/html and /home/usr2/html.
Now I symlinked /home/usr1/html/thisfolder to /home/usr2/html/thatfolder, double checked the FollowSymlinks option is enabled both in apache2.conf and in vhost.conf, but I'm getting a 403 Error.
Why should this be about permits? I mean, www-data can read without any problem from both folders, how is it that when symlinked it just doesn't?
Thanks
EDIT:
Error returned by Apache: (notice the missing script filename, only extension is provided)
[Wed Apr 20 12:13:11.297208 2016] [authz_core:error] [pid 19883] [client 192.168.0.1:12345] AH01630: client denied by server configuration: /home/usr2/html/thatfolder/.php
Virtual Host conf file:
<VirtualHost *:80>
ServerName server.domain.lan
ServerAdmin adm#lan
DocumentRoot /home/usr2/html
<Directory /home/usr2/html>
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
<Directory /home/usr1/html/thisfolder> // original folder
Require all granted
</Directory>
</VirtualHost>
I noticed this by chance earlier and after a quick Google, really couldn't find anything to help. I'm genuinely having trouble even explaining the problem!
When I access http://mydomain.com/error/README I appear to be getting the error readme found in /var/www/error/README. My virtual host for mydomain.com is document root is pointing to /var/www/html/mydomain, and /var/www/html/mydomain/error/ does not exist.
Naturally I feel this shouldn't be happening and although I haven't been able to replicate it, my main concern is that a user could in fact access anything off of /var/www/ not just /var/www/error/
Linux version: CentOS release 6.5 (Final)
Apache version: Apache/2.2.15
My virtual host file is:
NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName mydomain.com
ServerAlias www.mydomain.com
DocumentRoot /var/www/html/mydomain
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/html/mydomain/>
Options FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
LogLevel error
CustomLog /var/log/httpd/mydomain_access.log combined
ErrorLog /var/log/httpd/mydomain_error.log
</VirtualHost>
Naturally I feel this shouldn't be happening and although I haven't been able to replicate it, my main concern is that a user could in fact access anything off of /var/www/ not just /var/www/error/
You probably have the following directive in your httpd.conf:
Alias /error/ "/var/www/error/"
This just redirects all your error queries to /var/www/error (e.g. if you need www.example.com/error/README it would redirect me to one of the README in that director). Removing the alias should fix your problem.
If you are concerned about access to your other directories then I, as a complete newbie to apache, would recommend.
Auditing your httpd.conf and removing any aliases that you don't need.
Modifying your containers to have "Deny from all" and "AllowOverride None" in all of them.
If you have selinux enabled, then remove the httpd security contexts from those directories.
Today I was updated Ubuntu server 13.04 (Raring Ringtail) → 13.10 (Saucy Salamander).
And my Apache 2 installation is broken.
Here my configuration:
File error.log
[Fri Oct 18 10:48:07.237170 2013] [:notice] [pid 8292:tid 139804677900160] FastCGI: process manager initialized (pid 8292)
[Fri Oct 18 10:48:07.241185 2013] [mpm_event:notice] [pid 8289:tid 139804677900160] AH00489: Apache/2.4.6 (Ubuntu) mod_fastcgi/mod_fastcgi-SNAP-0910052141 configured -- resuming normal operations
[Fri Oct 18 10:48:07.241652 2013] [core:notice] [pid 8289:tid 139804677900160] AH00094: Command line: '/usr/sbin/apache2'
[Fri Oct 18 10:48:28.313923 2013] [authz_core:error] [pid 8294:tid 139804573181696] [client 81.219.59.75:3536] AH01630: client denied by server configuration: /usr/lib/cgi-bin/php5-fcgi
File default.conf
#EU
<VirtualHost *:80>
#ServerName
DocumentRoot /var/www/dev_stable
DirectoryIndex index.php index.html index.htm
<Directory /var/www/dev_stable>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Require all granted
</Directory>
</VirtualHost>
File mods-enabled/fastcgi.conf
#<IfModule mod_fastcgi.c>
# AddHandler fastcgi-script .fcgi
# FastCgiWrapper /usr/lib/apache2/suexec
# FastCgiIpcDir /var/lib/apache2/fastcgi
#</IfModule>
<IfModule mod_fastcgi.c>
AddHandler php5-fcgi .php
Action php5-fcgi /php5-fcgi
Alias /php5-fcgi /usr/lib/cgi-bin/php5-fcgi
FastCgiExternalServer /usr/lib/cgi-bin/php5-fcgi -socket /var/run/php5-fpm.sock -pass-header Authorization
</Ifmodule>
When I trying to load the file via the browser I got:
site_name/TEST/
Forbidden
You don't have permission to access /php5-fcgi/TEST/index.php on this server.
What should I to fix it?
I have exactly the same issue. I ran a couple of virtual hosts on my local machine for developing.
First, I changed /etc/apache2/conf-available/php5-fpm.conf. I replaced every
Order Deny,Allow
Deny from all
to
Require all granted
The configuration has to be enabled by a2enconf php5-fpm. I did the same with my virtual hosts configurations and made the replacements.
I think this is not advised for security reasons, but as long as I use my server for local purposes only I can live with it.
I ran into this exact issue upon a new install of Apache 2.4. After a few hours of googling and testing I finally found out that I also had to allow access to the directory that contains the (non-existent) target of the Alias directive. That is, this worked for me:
# File: /etc/apache2/conf-available/php5-fpm.conf
<IfModule mod_fastcgi.c>
AddHandler php5-fcgi .php
Action php5-fcgi /php5-fcgi
Alias /php5-fcgi /usr/lib/cgi-bin/php5-fcgi
FastCgiExternalServer /usr/lib/cgi-bin/php5-fcgi -socket /var/run/php5-fpm.sock -pass-header Authorization
# NOTE: using '/usr/lib/cgi-bin/php5-cgi' here does not work,
# it doesn't exist in the filesystem!
<Directory /usr/lib/cgi-bin>
Require all granted
</Directory>
</Ifmodule>
I ran into a similar problem today (but with mod_wsgi). It might be an Apache 2.2-to-2.4 problem. A comprehensive list of changes can be found here.
For me, it helped to add an additional <Directory>-entry for every path the error-log was complaining about and filling the section with Require all granted.
So in your case you could try
<Directory /usr/lib/cgi-bin/php5-fcgi>
Require all granted
Options FollowSymLinks
</Directory>
and I had to move my configuration file from folder conf.d to folder sites-enabled.
All in all, that did the trick for me, but I don't guarantee it works in your case as well.
I recently ran into the same problem. I had to change my virtual hosts from:
<VirtualHost *:80>
ServerName local.example.com
DocumentRoot /home/example/public
<Directory />
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
To:
<VirtualHost *:80>
ServerName local.example.com
DocumentRoot /home/example/public
<Directory />
Options All
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
In apache2.conf, replace or delete <Directory /> AllowOverride None Require all denied </Directory>, like suggested Jan Czarny.
For example:
<Directory />
Options FollowSymLinks
AllowOverride None
#Require all denied
Require all granted
</Directory>
This worked in Ubuntu 14.04 (Trusty Tahr).
Your virtualhost filename should be mysite.com.conf and should contain this info
<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 mysite.com
ServerAlias www.mysite.com
ServerAdmin info#mysite.com
DocumentRoot /var/www/mysite
# 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
<Directory "/var/www/mysite">
Options All
AllowOverride All
Require all granted
</Directory>
# 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>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
I don't think that replacing "Require all denied" with "Require all granted" in this directive:
<Directory>
Options FollowSymLinks
AllowOverride None
#Require all denied
Require all granted
</Directory>
as suggested by Jan Czarny and seonded by user3801675 is the most secure way of solving this problem.
According to the Apache configuration files, that line denies access to the entirety of your server's filesystem. Replacing it might indeed allow access to your virtual host folders but at the price of allowing access to your entire computer as well!
Gev Balyan's approach seems to be the most secure approach here. It was the answer to the "access denied problems" plaguing me after setting up my new Apache server this morning.
And I simply got this error because I used a totally different DocumentRoot directory.
My main DocumentRoot was the default /var/www/html
and on the VirtualHost I used /sites/example.com
I have created a link on /var/www/html/example.com (to /sites/example.com).
DocumentRoot was set to /var/www/html/example.com
It worked like a charm.
I had the same issue after upgrading my system.
In my case, the problem was caused by the order of loading configuration files.
In the /etc/httpd/httpd.confinitally it was defined as follows:
IncludeOptional conf.d/*.conf
IncludeOptional sites-enabled/*.conf
After some hours of attempts, I tried the following order:
IncludeOptional sites-enabled/*.conf
IncludeOptional conf.d/*.conf
And it works fine now.
I had the following configuration in my httpd.conf that denied executing the wpadmin/setup-config.php file from wordpress. Removing the |-config part solved the problem.
I think this httpd.conf is from plesk but it could be some default suggested config from wordpress, i don't know. Anyway, I could safely add it back after the setup finished.
<LocationMatch "(?i:(?:wp-config\\.bak|\\.wp-config\\.php\\.swp|(?:readme|license|changelog|-config|-sample)\\.(?:php|md|txt|htm|html)))">
Require all denied
</LocationMatch>
For those of you on AWS (Amazon Web Services), remember to add a rule for your SSL port (in my case 443) to your security groups. I was getting this error because I forgot to open the port.
3 hours of tearing my hair out later...
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.