permission for virtual host outside www directory - apache

I am having trouble getting virtual hosts to work in apache 2.2.22 on linux (and windows!). I can get vhosts working within the www/html folder, but I am unable to get it working if the website folders are elsewhere. The permissions I was using in the httpd.conf file are:
<Directory "/path/to/my/websites">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order Deny,Allow
Allow from all
</Directory>

Related

How do I grant permission on an Apache 2.4 server?

I have an Apache 2.4 server (WAMP) on my pc (running windows 10). It is fine when I connect to it on my pc (the host) but when I test it on another device it simply gives a 403 forbidden error and refuses to load. I have been trying so many solutions online with the config file but to no avail. How do I fix this?
Here is my httpd.conf file: http://pastebin.com/5B5Q31im
Please note that I am new to this.
Not a WAMP guy but a linux admin.... and your config file looks like Apache 2.2, 2.4 has some changes where it defines the top level document root directory, and the forbidden error is what usually reminds me I've copied an old config over to a new system...
DocumentRoot "${INSTALL_DIR}/www"
<Directory "${INSTALL_DIR}/www/">
Options +Indexes +FollowSymLinks +Multiviews
AllowOverride all
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
Should be more like
DocumentRoot ${INSTALL_DIR}/www
<directory ${INSTALL_DIR}/www>
Options All
AllowOverride All
Require all granted
</directory>

Apache virtual host permissions not working

I need some help here my virtual hosts permissions appear not to be working.
For example site1.com and site2.com can access each others files and even create files!. I have tried to prevent this by having this in the apache2.conf file.
<Directory />
Options FollowSymLinks
Order deny,allow
Deny from all
</Directory>
And then in the virtual host file for site1 I have this
<Directory /var/www/site1.com/public_html>
Options indexes, FollowSymLinks
Order Allow,Deny
Allow from all
</Directory>
And for the virtual host ifle in site2 I have this
<Directory /var/www/site2.com/public_html>
Options indexes, FollowSymLinks
Order Allow,Deny
Allow from all
</Directory>
Can anyone help me with this please as its a big security issue?
What have I done wrong?
Thanks,
Dan
An Apache configuration doesn't have anything to do with who/what can create files in the filesystem, it only determines what this particular program (httpd) is willing to serve.

How to configure the virtual host in apache to let the users access those resources with certain file extensions only?

How to configure the virtual host in apache to let the users access those resources with certain file extensions only?
Eg. I want users have access to .jpg .png .html files only. How to configure that in the virtual host?
you can set the apache directories by allowing access for images folder and deny the access to the others
<virtualhost>
Documentroot /var/www
Alias /images /path/to/images
<Directory "path/to/images">
Options Indexes FollowSymLinks
AllowOverride None
Allow from all # allow access to images only
</Directory>
<Directory "path/to/apps">
Options Indexes FollowSymLinks
AllowOverride None
Deny from all
</Directory>
</virtualhost>

Laravel 4 - Options not allowed here in the .htaccess

I have installed Laravel 4 on my public_html folder locally, and I can access its public folder when declaring a vhost pointing to it, through the vhost url.
But, when I try to access Laravel public folder through its parent folders, I get an error in apache logs (error_log): $LARAVEL_HOME/public/.htaccess: Options not allowed here. Even if there is a AllowOverride All in $VHOST_CONF/site.
The first line in the .htaccess (Options Multiviews), is causing this error when I delete it, or put it in $VHOST_CONF/site, it works.
So, How do I do to I access through the hierarchy, without modifying the .htaccess file?
In the Apache configuration file for the website set AllowOverride to AllowOverride All similar to the following:
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
# changed from None to All
AllowOverride All
Order allow,deny
allow from all
</Directory>

XAMPP pointing a file outside root folder

I am using XAMPP for first time in Mac. Running out problems accessing other than root folder(htdocs).when I am placing my web application inside htdocs with default httpd.conf file it works when I try to point my web application url in httpd.conf it throws You don't have permission to access / on this server. error
I am aware that to modify the root folder I need to do changes to my XAMPP/etc/httpd.conf file
With Default XAMPP MAC Settings, I am trying to change Server root,Document root and Directory in XAMPP/etc/httpd.conf file the following
ServerRoot "/Applications/XAMPP/xamppfiles"
DocumentRoot "/Users/ravi/Documents/Development/Backbone/backboneboilerplate"
<Directory />
#Options FollowSymLinks
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order deny,allow
Allow from all
</Directory>
<Directory "/Users/ravi/Documents/Development/Backbone/backboneboilerplate">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
It was chmod problem. I tried giving chmod -r 777 to Development folder, backbone folder and Backboneboilerplate.. It worked.