Apache cannot access custom directory - apache

I am using apache 2.4 and ubuntu 15.10.
I want to change default /var/www/html/ directory for my files into /home/myuser/mydir/. I know there are many tutorials, but it doesn't seem to work.
I changed 000-default.conf:
ServerAdmin webmaster#localhost
# DocumentRoot /var/www/html
DocumentRoot /home/myuser/mydir
# <Directory /var/www/html>
<Directory /home/myuser/mydir>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
I changed default-ssl.conf:
ServerAdmin webmaster#localhost
# DocumentRoot /var/www/html
DocumentRoot /home/myuser/mydir
I changed apache.conf:
# <Directory /var/www/html>
<Directory /home/myuser/mydir>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
ls -l in /home/myuser/mydir is solid: -rwxrwxrwx
If I restart apache2 and access "localhost" in my browser I get:
Forbidden
You don't have permission to access / on this server.
Apache/2.4.12 (Ubuntu) Server at localhost Port 80
I don't know what else I can do.

Make /home/myuser/ world readable and world executable.

Related

Apache 2.4 Httpd 403 Forbidden in Vagrant of Centos 7

After vagrant up with Centos7 and httpd (Apache 2.4) is installed, I test the testa.dev.conf in /etc/httpd/conf.d as
<VirtualHost *:80>
ServerName html.testa.dev
DocumentRoot "/var/www/html/testa.dev/htdocs"
<Directory "/var/www/html/testa.dev/htdocs">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride None
Require all granted
</Directory>
</VirtualHost>
and it can be accessed as http://html.test.dev while
the domain name is added to /etc/hosts in host
NO change in the default setting /etc/httpd/conf/httpd.conf
a test page /var/www/html/testa.dev/htdocs/index.html is created
However, when I'm trying to test other directories, it comes to 403 Forbidden. What I have done is
to create testb.dev.conf in /etc/httpd/conf.d as
<VirtualHost *:80>
ServerName html.testb.dev
DocumentRoot "/srv/www/testb.dev/htdocs"
<Directory "/srv/www/testb.dev/htdocs">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride None
Require all granted
</Directory>
</VirtualHost>
to create a test page /srv/www/testb.dev/htdocs/index.html
to grant permissions by
chown -R apache:apache /srv/www/testb.dev/htdocs
chmod -R 755 /srv/www/testb.dev/htdocs
My idea is straight forward. Just want to change /var/www to /srv/www. But it seems there still some configuration around I missed.

Virtual Hosts on WAMP causing 403 forbidden on 192.168.1.6… other aliases still work

recently modified httpd.conf and httpd-vhosts.conf to add vhosts...
#IncludeOptional "E:/wamp/vhosts/*"
Include "E:/wamp/alias/*"
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot "e:/wamp/www"
ServerName localhost
ServerAlias localhost
<Directory "e:/wamp/www">
Options Indexes FollowSymLinks
AllowOverride All
Require local
Require ip 192.168.1
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot E:/activeWork/projects
ServerName projects.local
<Directory "E:/activeWork/projects">
Options Indexes FollowSymLinks
AllowOverride All
Require local
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot E:/activeWork/projects
ServerName www.projects.local
<Directory "E:/activeWork/projects">
Options Indexes FollowSymLinks
AllowOverride All
Require local
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot E:/activeWork/projects
ServerName api.projects.local
<Directory "E:/activeWork/projects">
Options Indexes FollowSymLinks
AllowOverride All
Require local
</Directory>
</VirtualHost>
after that when i try to load 192.168.1.6 or 127.0.0.1 , gives me :
Forbidden
You don't have permission to access / on this server.
i've tried to solve it whit this answer but not works for me
and by recommandation in answers i check my access.log and this is the result:
192.168.1.6 - - [03/Oct/2016:11:03:00 +0330] "GET / HTTP/1.1" 403 288
127.0.0.1 - - [03/Oct/2016:11:00:55 +0330] "GET / HTTP/1.1" 403 286
if you are sure that your wamp Installation path is inside E:
then I suggest you to check your access log and error log to collect more information.
I assume you are using Apache 2.4 or later on your Wampserver? If so, then replace the require rules with "Require all granted" in your vhosts, like this:
<VirtualHost *:80>
DocumentRoot "e:/wamp/www"
ServerName localhost
ServerAlias localhost
<Directory "e:/wamp/www">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
If it still doesn't work, check if your firewall is blocking your access.
my problem is to define 3 vhost point to same directory and this confused apache...finally tnx to riggsfolly i fixed that...beside of this i make changes from this guide to define VHost to have setup things in a right way

How to change port number of Apache server in ubuntu

I want to change my port number 80 to some other number of my Apache server . how it possible in ubuntu
Change your virtal host on any OS, ubuntu path is something like /etc/apache2/apache2 config or something.
#Virtual host for YOURSITE
<VirtualHost *:4343>
ServerAdmin john.doe#jd.com
ServerName webpage.dev #same as in your /etc/hosts file
DocumentRoot /var/www/yoursite
DirectoryIndex index.html
<Directory /var/www/yoursite>
Options FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/httpd/yoursite_error.log
#CustomLog /var/log/apache2/customLog.log #for ubuntu
</VirtualHost>
Hope this will help you, you should read about apache coinfiguration...
Here's a great link https://www.digitalocean.com/community/tutorials/how-to-configure-the-apache-web-server-on-an-ubuntu-or-debian-vps
You can create a virtual host configuration file in /etc/apache2/sites-available
Example :--
<VirtualHost *:8080>
ServerAdmin webmaster#localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
. . .
and you have to change Listen port on /etc/apache2/ports.conf
EX:--
Listen 8080

Error apache : access denied

My configuration :
Wampserver 3.0.0 32bits
Apache 2.4.17
php 5.6.15
mysql 5.7.9
My problem :
WampServer start properly, but when I try to access a project in the log i have:
[Sat May 21 10:55:39.393866 2016] [authz_core:error] [pid 6984:tid 1140] [client 127.0.0.1:50070] AH01630: client denied by server configuration: C:/wamp/www/project/api/app/
[Sat May 21 10:55:39.395878 2016] [authz_core:error] [pid 6984:tid 1140] [client 127.0.0.1:50070] AH01630: client denied by server configuration: C:/wamp/www/project/api/src/
Yet I check my configuration files and all seems OK.
There are my configs files :
httpd.conf :
<Directory "C:/wamp/www/">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# [httpd.apache.org]
# for more information.
#
Options Indexes FollowSymLinks
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# AllowOverride FileInfo AuthConfig Limit
#
AllowOverride all
#
# Controls who can get stuff from this server.
#
#onlineoffline tag - don't remove
#Require local
Require all granted
</Directory>
httpd-vhosts.conf:
<VirtualHost *:80>
ServerAdmin admin#test.fr
ServerName localhost
DocumentRoot "C:/wamp/www"
<Directory "C:/wamp/www">
Options +Indexes +FollowSymlinks
AllowOverride All
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerAdmin admin#test.fr
ServerName localhost.project.com
#ServerAlias localhost.project.com
DocumentRoot "C:/wamp/www/project/website/web/"
<Directory "C:/wamp/www/project/website/web/">
Options +Indexes +FollowSymlinks
AllowOverride All
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerAdmin admin#test.fr
DocumentRoot "C:/wamp/www/project/api"
ServerName api.project.com
#ServerAlias api.project.com
<Directory "C:/wamp/www/project/api">
Options +Indexes +FollowSymlinks
AllowOverride All
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerAdmin admin#test.fr
DocumentRoot "C:/wamp/www/Demo_websocket/web"
ServerName demo.websocket
#ServerAlias demo.websocket
<Directory "C:/wamp/www/Demo_websocket/web">
Options +Indexes +FollowSymlinks
AllowOverride All
</Directory>
</VirtualHost>
My hosts file :
I think I do not understand very well what you mean. The content of my
hosts file is :
127.0.0.1 localhost
127.0.0.1 api.project.com
127.0.0.1 localhost.project.com
I already tried to set Require all granted in VirtualHost but no success :s
If someone has already faced this problem and found a solution , I'm interested. Thank you
you are using localhost with virtual hosting,
if this is your hosts file, it is correct
127.0.0.1 localhost
127.0.0.1 api.project.com
127.0.0.1 localhost.project.com
and in your local browser you'll write one of these urls.
But your virtual host configuration must respond to a specific host and not to *, for example fo api you must have <VirtualHost api.project.com:80> and not <VirtualHost *:80>
also the generic * virtual host MUST be at the end of the list, then the result is:
<VirtualHost localhost.project.com:80>
ServerAdmin admin#test.fr
ServerName localhost.project.com
#ServerAlias localhost.project.com
DocumentRoot "C:/wamp/www/project/website/web/"
<Directory "C:/wamp/www/project/website/web/">
Options +Indexes +FollowSymlinks
AllowOverride All
</Directory>
</VirtualHost>
<VirtualHost api.project.com:80>
ServerAdmin admin#test.fr
DocumentRoot "C:/wamp/www/project/api"
ServerName api.project.com
#ServerAlias api.project.com
<Directory "C:/wamp/www/project/api">
Options +Indexes +FollowSymlinks
AllowOverride All
</Directory>
</VirtualHost>
<VirtualHost demo.websocket:80>
ServerAdmin admin#test.fr
DocumentRoot "C:/wamp/www/Demo_websocket/web"
ServerName demo.websocket
#ServerAlias demo.websocket
<Directory "C:/wamp/www/Demo_websocket/web">
Options +Indexes +FollowSymlinks
AllowOverride All
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerAdmin admin#test.fr
ServerName localhost
DocumentRoot "C:/wamp/www"
<Directory "C:/wamp/www">
Options +Indexes +FollowSymlinks
AllowOverride All
</Directory>
</VirtualHost>

Apache Symfony Vitrual Host

I clone project in /home/ivan/host/name/web and create virtual host. a2ensite and reload and restart server.
<VirtualHost *:80>
ServerName name.local
DocumentRoot /home/ivan/host/name/web
DirectoryIndex app.php
ErrorLog /var/log/apache2/name-error.log
CustomLog /var/log/apache2/name-access.log combined
<Directory "/home/ivan/host/name/web">
AllowOverride All
Allow from All
</Directory>
and hosts
127.0.0.1 name.local
but have
Forbidden
You don't have permission to access / on this server.
I doing chmod 777 -R host/ but still have error
what I'am doing wrong ?
SOLVED
<VirtualHost *:80>
ServerName aog.local
DocumentRoot /home/ivan/host/name/web
DirectoryIndex app.php
ErrorLog /var/log/apache2/name-error.log
CustomLog /var/log/apache2/name-access.log combined
<Directory "/home/ivan/host/name/web">
AllowOverride All
Require all granted
Allow from All
</Directory>
Look like you are using apache 2.4,
add directive Require all granted as shown below:
<Directory /home/ivan/host/name/web>
AllowOverride All
Options +FollowSymlinks
Require all granted
</Directory>