I am trying to get Symfony to work without using the built in PHP server, however, I always get 403 when trying to access it via my virtual host address. My virtual host conf file looks like this:
<VirtualHost *:80>
ServerName www.symfony2.local
ServerAlias symfony2.local
DocumentRoot /var/www/vhosts/symfony2.local/web
<Directory /var/www/vhosts/symfony2.local/web>
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/httpd/symfony2-error.log
CustomLog /var/log/httpd/symfony2-access.log combined
</VirtualHost>
My hosts file looks like this:
127.0.0.1 symfony2.local
The .htaccess in web/ is the default Synfony2 installed file.
Whenever I try to access http://synfony2.local I get the following error in my log file:
(13)Permission denied: [client 127.0.0.1:32858] AH00529: /var/www/vhosts/symfony2.local/web/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable and that '/var/www/vhosts/symfony2.local/web/' is executable
-rwxr-xr-x. 1 apache apache 2.8K Mar 1 00:48 .htaccess
drwxr-xr-x. 3 apache apache 4.0K Mar 1 01:24 web
Can someone please point out what I am missing here?
There could be serveral reasons for the 403 foribben.
Reduce the permissions on the .htaccess file. You have the wrong
permissions on the htaccess file. You have it as 755 which should be used on directories and it should
be 644 rw-r--r--. Change it. My guess is that's the problem.
Make sure you have an index file in the web root. Of course if you have a web app there then make sure you have the DirectoryIndex index.php specified in the Apache config file.
Make sure the parent folder is 755 symfony2.local also which has been known to restrict access.
Option 2 and 3 are something to check if 1 doesn't fix it. Although you need to change the perms on htaccess regardless.
The solution by Panama Jack was useful and the points raised valid, however, it did not resolve the issue (although it may have had an effect).
I finally managed to get it to work after disabling SeLinux.
Related
I'm setting up a new Ubuntu 16.04 server with Apache. I followed this guide to do my setup.
Now when I try to access the site it shows me an empty directory. If I try to access a specific file (index.html) the server doesn't find it. Even trying to see the default website (by accessing my public IP) I get an empty directory.
Here's my .conf file:
ServerAdmin admin#website.com
ServerName website.com
ServerAlias www.website.com
DocumentRoot /var/www/website.com/public_html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
(for the purpose of this public question I changed the name of the site for website.com)
All file's and folder's rights are set to my username as owner and www-data as group. Apache's error log shows nothing wrong and access log is empty.
I banged my head for hours on this issue without any progress so any help is welcome!
Thanks
P.S.: The server is Ubuntu Server 16.04 LTS 64b running on a VirtualBox VM.
Obiviously you have missed out something. Please check that you have
/var/www/example.com/public_html/index.html
with correct spellings.
Also make sure that the config has both index.html and index.php in DirectoryIndex, check this link for more info
If all is correct create a .htaccess file in /var/www/example.com/public_html/
nano /var/www/example.com/public_html/.htaccess file
and then add the followings in it.
DirectoryIndex index.htm index.html index.php
Please help.
I'm trying to setup 3 test sites, so each could be reached from my server's ip like:
my-server-ip/site1
my-server-ip/site2
my-server-ip/site3
When I use ServerName as ip it works fine:
<VirtualHost 127.0.0.1:8080>
ServerName x.x.x.x
DocumentRoot "/home/myfolder/public_html"
<Directory "/home/myfolder/public_html">
AllowOverride All
</Directory>
</VirtualHost>
but using ServerName x.x.x.x/site1 is not working ofcourse.
I tryed to use Alias /site1 /path and it works for first virtual host but when i add 2 more virtual hosts to vhosts.conf only first works.
Another trick that i tryed is to add:
Alias /site1 /home/folder1/public_html
Alias /site2 /home/folder2/public_html
Alias /site3 /home/folder3/public_html
into /usr/local/apache/conf.d/domain-redirects.conf
and add options into /usr/local/apache/conf/httpd.conf
And this does work but not correctly.
I know I could use some domain name and setup a buch of subdomains for other sites..but using ip is better.
Is there a way to set things up this way?
You need to deposit your sites into the directory that the server accesses. The default that apache gives is /var/www. So if your file is at /var/www/test.html you can access it with 127.0.0.1:8080/test.html .
Thanks! Your idea led to solution. Just in case someone needs the same setup, here is what i've done (running on Centos 6 + Apache+Varnish).
Create and upload folders/files just like you do for normal domains.
By default http://ip -> my apache looks into a folder:
/usr/local/apache/htdocs
I could create a folder here and upload a site here but rather I've created a symlink to my testsite:
ln -s /home/user/public_html/test_site_folder testsite1
now my testsite is available at http://ip/testsite1
almost...to make it work for user I added in httpd.conf this statement (AllowOverride) in order to be able to use mod_rewrite and others in .htaccess located in root folder of testsite1
*** added
<Directory "/usr/local/apache/htdocs">
suPHP_UserGroup user user
AllowOverride All ***
Order allow,deny ***
Allow from all ***
I remember reading a while ago how it's possible for someone to access your computers filesystem from the website. I want to know how to do it, so I can test and prevent it from happening.
Running Apache 2.4 on Windows via XAMPP
My virtualhost is set up like so:
<VirtualHost *:80>
ServerName local.scrap
DocumentRoot "D:/Dropbox/www/scrap/public_html/"
<Directory "D:/Dropbox/www/scrap/">
Order allow,deny
Allow from all
Require all granted
</Directory>
ErrorLog "D:/Dropbox/www/scrap/logs/error.log"
</VirtualHost>
There is an index2.html in scrap/ and index.html in scrap/public_html/
hosts is set up to be 127.0.0.1 local.scrap
If I type the URL http://local.scrap/ I get index.html.
If I type the URL http://local.scrap/../index2.html it gets redirected to http://local.scrap/index2.html
Why is the ../ URL getting redirected to the DocumentRoot path?
Often times a non-malicious user-agent will resolve ../ in the URL before it ever contacts the server. But even without that, webservers are designe to not allow that kind of directory traversal outside of context roots.
You'd need to test with telnet/netcat/s_client to be sure.
If there's a directory traversal or LFI vulnerability in the website application code then this might indeed be possible.
Also, some webservers have directory traversal vulnerabilities. However, the current version of Apache has no known weaknesses in this respect.
I am using a new CentOS 6.3 minimal install with fresh httpd installed
When I go to my virtual host it is showing me the apache test page, and then if I go to mydomain.co.uk/index.html (That I have just set up to test with) it says forbidden. All the usual answers to this don't seem to be working and I have honestly looked through tons of forums and other people questions/answers and nothing seems to be working for me.
I have created a group called 'www' that I have added the user 'apache' to.. This is my root directory in httpd.conf file, I have left it pretty open just for testing:
<Directory />
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from All
</Directory>
This is my vhosts file:
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /var/www/html/
</VirtualHost>
<VirtualHost *:80>
ServerName domain.co.uk
ServerAlias www.domain.co.uk
DocumentRoot /home/domain/public_html
<Directory "/home/domain/public_html">
Options Indexes FollowSymLinks ExecCGI
AllowOverride AuthConfig FileInfo
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
From /home/ onwards I have set the group to www
When ls -lA on home folder I get
drwxrwsr-x. 5 root www 4096 Feb 5 20:57 home
The error I am getting in my logs file is a permission one:
[Wed Feb 06 10:24:42 2013] [error] [client 62.254.7.226] (13)Permission denied: access to /index.html denied (filesystem path '/home/domain/public_html/index.html') because search permissions are missing on a component of the path
As is everything else in that folder. I really don't know what to try next. I have come to the point of needing to ask for my specific setup as following other tutorials or answers has not worked for me. Any help is greatly appreciated!
Error 13 means that the user/group specified in your apache configuration (httpd.conf) didn't have permission to access the files. The files, and all the directories above them, need to have permission that allow for that user and group.
One of the trickier bits can be extended permissions. If you are running selinux, the server user could be denied because of the extended permissions on the file. To check for this, run (from the command line):
setenforce 0
If the problem goes away (i.e. the page is visible) then your extended permissions are blocking access.
See http://wiki.apache.org/httpd/13PermissionDenied for details.
Selinux is not expecting the http server to access files under /home/domain since it is not a standard path.
You can change it with following command:
chcon -R --type=httpd_sys_rw_content_t /home/domain/public_html/
I am trying to configure the Apache server on my MacBooks (running Lion OS) to handle dynamic virtual hosts. I have managed to get it "working" but I whenever I access the domain I get a 403 Forbidden message. The hosts file is configured to point to 127.0.0.1 whenever one of these domains are requested. The httpd.conf is shown below:
VirtualDocumentRoot "/web"
<Directory "/web">
Options All
AllowOverride All
Order allow,deny
Allow from all
ScriptAlias /web/cgi-bin/
</Directory>
UseCanonicalName Off
VirtualDocumentRoot /web/%2/%1/public_html
This is set up so that http://foo.bar/ goes to "/web/bar/foo/public_html/".
I have checked the permissions on all the directories and files and they are all set to '777'. I have Googled for hours and hours and I am still getting 403 Forbidden. If there is anyone that can help me that would be greatly appreciated.
-Sam
You got it right, it's about permission. Check your site's parent folder permission, it might be stuck somehow on one of it's parent folder, make sure all of you site's parent folder from the root are readable by apache.