Apache : client denied by server configuration for some local ressources - apache

i have some troubles to install local website for development.
I have an "client denied by server configuration"' error for some local ressources like .png or .js
My website have following treepath :
website/files
website/app/local
website/app/share
My mainpage is in app/local and can access to files /files but i have 403 error for files in app/share.
I put "chmod -R 777 www-data" on full website directory so what's wrong ?
[SOLVING]I have another little problem : i can't access to my website with localhost/website but only with localhost/
I have reading some tutos and think my following configuration is right (my apache is 2.2) :
<VirtualHost *:80>
ServerName julien.quai13.com
DocumentRoot /home/julien-quai13/www
<Directory />
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerAdmin julien#andcotransport.com
ServerName julien.quai13.com/andcotransport
DocumentRoot /home/julien-quai13/www/andcotransport
#<Directory />
# Options FollowSymLinks
# AllowOverride All
#</Directory>
<Directory /home/julien-quai13/www/andcotransport>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride All
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
And this my /etc/hosts :
127.0.0.1 localhost
127.0.0.1 julien.quai13.com
127.0.1.1 julien-quai13
192.126.0.34 julien.quai13.com
Not very important but annoying, i always have problems when i switch of Wamp to Linux.
Thanks for helping (promise i stay on Linux this time ;)

Well, when using vhosts, if apache doesn't match the URL with any server name, it will serve the first one it comes to, if this is the first one, then localhost will map straight to /home/julien-quai13/www/andcotransport
You should set up a virtualhost for default with DocumentRoot /home/julien-quai13/www and add a Directory directive for this directory, then localhost/andcotransport will work.
Not sure if this is what you meant to write: chmod -R 777 www-data but this is wrong, commands should be chmod -R 755 /home/julien-quai13/www/andcotransport and chown -R julien-quai13:www-data /home/julien-quai13/www/andcotransport
But permissions wouldn't give you a client denied by server configuration error, this is down to allow being set incorrectly.
Also you have defined julien.quai13.com twice in your hosts file.. one points to 127.0.0.1 and another points to 192.126.0.34.. this may be another problem..
Otherwise i'd consider restructuring your vhosts.
Judging by your vhost:
<VirtualHost *:80>
ServerName julien.quai13.com
DocumentRoot /home/julien-quai13/www
<Directory /home/julien-quai13/www>
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride All
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
You don't actually need the second vhost unless its under a different domaing, like andcotransport.julien.quai13.com so, just use the default domain and pass everything to /andcotransport, if thats how you want to do it...
but make sure all your resources are going to /andcotransport/files and /andcotransport/app/share then this should work, unless you have an overriding ACL somewhere which is blocking directories.

Related

ServerAlias in apache, ubuntu

I have a virtual host in ubuntu on apache, this is not my main config, i have another web page as my main, so i wanted to set this one up on the same IP using a virtual host.
urologyexpert.mx is my server name, and this works perfect, but i want to have several aliases to access this page
I put as server alias:
www.urologyexpert.mx (doesn't work)
urologoexpertomonterrey.mx (doesn't work)
www.urologoexpertomonterrey.mx (working)
The one's that does not work gets routed to my default webpage on this IP,
here's my apache config in /etc/apache2/sites-enabled
A records are set up for urologyexpert.mx and urologoexpertomonterrey.mx, both pointing at the same IP, and i have a CNAME for www for urologyexpert.mx
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName urologyexpert.mx
ServerAlias www.urologyexpert.mx, urologoexpertomonterrey.mx, www.urologoexpertomonterrey.mx
DocumentRoot /var/www/urologyexpert.mx
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/urologyexpert.mx>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride All
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Can someone help me with this? i just can't figure out why one alias is working and two aren't
Ok, I actually know now what was the problem,
The multiple ServerAlias have to be separated by a space, and not a comma, thats why only the ServerName and the last Alias was working
ServerAlias www.urologyexpert.mx urologoexpertomonterrey.mx www.urologoexpertomonterrey.mx
I hope this helps someone

Apache2 virtual host not updating correctly

I have the following as my default virtual host in /etc/apache2/sites-available/default
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/customers/webs/speed
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/customers/webs/speed>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
The idea is that it would read the index.html from /var/customers/webs/speed, however, it's still reading the default index.html in /var/www
I have restarted apache and even the server itself, but it just don't seem to want to update.
You must edit /etc/apache2/sites-enabled/default to change default page
If you access http://localhost Apache will load the index.html from Document Root defined in httpd.conf.
If you would like to load Document Root of Virtual Host, try below -
<VirtualHost *:80>
ServerName virtualhost.com
ServerAdmin webmaster#localhost
DocumentRoot /var/customers/webs/speed
<Directory /var/customers/webs/speed>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
</VirtualHost>
Go to your Host file and add a new entry 127.0.0.1 virtualhost.com
Apache should now understand which document root to load when you access http://localhost and http://virtualhost.com.
The above code would get you started and then you can add your customization accordingly .
Hope that help!

Apache 2.4.7 403 Forbidden Error

I'm trying to install the overpass api as a web server with apache (http://wiki.openstreetmap.org/wiki/Overpass_API/install)
Here is my 000-default.conf
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ExtFilterDefine gzip mode=output cmd=/bin/gzip
DocumentRoot /root/osm-3s_v0.7.4/html
# This directive indicates that whenever someone types http://www.mydomain.com/api/
# Apache2 should refer to what is in the local directory [YOUR_EXEC_DIR]/cgi-bin/
ScriptAlias /api/ /srv/osm3s/cgi-bin/
# This specifies some directives specific to the directory: [YOUR_EXEC_DIR]/cgi-bin/
<Directory "/srv/osm3s/cgi-bin/">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
#SetOutputFilter gzip
#Header set Content-Encoding gzip
</Directory>
ErrorLog /var/log/apache2/error.log
# Possible values include: debug, info, notice, warn, error, crit, alert, emerg
LogLevel warn
CustomLog /var/log/apache2/access.log combined
However when I try to run the command:
http://175.33.148.57/api/interpreter?data=%3Cprint%20mode=%22body%22/%3E
I get the 403 Forbidden error.
I have already done
chmod 777 /srv/osm3s/cgi-bin/
But nothing seems to work.
Please help, Ive been stuck on this for 3 days now! Thanks in advance.
Replace:
Allow from all
by
Require all granted
<Directory /www/mysite>
Allow from All
</Directory>
<Directory /www/mysite>
Require all granted
</Directory>
Here is how I solved this problem for anyone who might have a similar one:
It seemed the problem came from where I installed the overpass installation ($EXEC_DIR).
So I had to change the install directories to:
$EXEC_DIR /var/www/osm/
$DB_DIR /var/www/osm/db/
$PLANET_FILE /var/www/osm/planet.osm.bz2
$REPLICATE_DIR /var/www/osm/rep/
Giving the resulting default.conf:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ExtFilterDefine gzip mode=output cmd=/bin/gzip
DocumentRoot /root/osm-3s_v0.7.4/html
# This directive indicates that whenever someone types http://www.example.com/api/
# Apache2 should refer to what is in the local directory [YOUR_EXEC_DIR]/cgi-bin/
ScriptAlias /api/ /var/www/osm/cgi-bin/
# This specifies some directives specific to the directory: [YOUR_EXEC_DIR]/cgi-bin/
<Directory "/var/www/osm/cgi-bin/">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
#SetOutputFilter gzip
#Header set Content-Encoding gzip
</Directory>
ErrorLog /var/log/apache2/error.log
# Possible values include: debug, info, notice, warn, error, crit, alert, emerg
LogLevel warn
CustomLog /var/log/apache2/access.log combined
</VirtualHost>
I tried and tried but couldn't get it working with the old dir. Good luck!
try this as it is. don't add Order allow,deny or others
AddHandler cgi-script .cgi .py
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Require all granted
Allow from all
</Directory>

More than one virtual host in Apache2 Ubuntu

I have tried to configure a new virtual host in apache. I have copied the default. Updated the paths. The conf looks like this
<VirtualHost *:8081>
ServerAdmin webmaster#localhost
DocumentRoot /home/ubuntu/video
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /home/ubuntu/video>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog /home/ubuntu/video/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /home/ubuntu/video/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
I ran the command
sudo a2ensite video
which gave messaage that virtual host successfully added and will run upon reload. But i am not able to access the same. I have checked the path /home/ubuntu/video where error.log, access.log files are also created. I am not able to find the solution as well as problem. I searched in the internet if anyone have same problem.
The following blog post: Adding virtual hosts to Ubuntu Apache, says in its update the we cannot create more than one virtual host. I have already a virtual host installed. Does this mean 2nd virtual host cannot be configured in Ubuntu for apache?
Read these instructions.
If you try using <VirtualHost name:port> without the NameVirtualHost name:port or you try to use the Listen directive, your configuration will not work.
So make sure you have these directives outside the <VirtualHost> tag:
Listen 8081
NameVirtualHost *:8081
You can also add:
ServerName www.example.com
to your VirtualHost section.

How can i move Apache localhost from /var/www to my mount directory

I am new in ubuntu(and Linux) and have simple-lamer question.
I have mounted directory /media/2A98EDD2ACA90087/WebProject/ and would like to move http:/localhost/ from var/www to /media/2A98EDD2ACA90087/WebProject/
I have change sites-enabled/000-default and /etc/apache2/sites-available
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /media/2A98EDD2ACA90087/WebProject
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /media/2A98EDD2ACA90087/WebProject>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
And have this apache message!
Forbidden
You don't have permission to access / on this server
When i have created "test" dir and move localhost from var/www to var/www/test - everything works. I suppose that problem with file permissions??!What should i do?
The problem has been solved. Thanks Patrick and Joh. Really need to give read access to index.html: chmod 644 /media/2A98EDD2ACA90087/WebProject/index.html
But i can't change access to my Ntfs mounted drive. I have to remount
why cant change permission ownership group of external hard drive on ubuntu
The apache server runs as a certain user -- probably "apache", you can run ps to see -- and that user must have permission to access the webroot. You can make it be owned by apache, or make it group-readable (and you'll probably want it group-writable) and either add apache to the group that owns it, or change the group to apache's group.
Assuming httpd runs as "apache" (group: apache) and you are "jdoe" (group: jdoe)
$ sudo chown -R jdoe:apache /media/2A98EDD2ACA90087/WebProject
$ sudo chmod -R 755 /media/2A98EDD2ACA90087/WebProject