Fedora httpd.conf virtualhost - apache

I trying to move localhost to home folder, but I get an error 403. Here end of httpd.conf:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /home/valera5505/sites/localhost
ServerName localhost
<Directory /home/valera5505/sites/localhost>
AllowOverride All
Order allow,deny
Require all granted
</Directory>
</VirtualHost>

Try this (I'm not an Apache pro) :
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /home/valera5505/sites/localhost
ServerName localhost
<Directory /home/valera5505/sites/localhost>
Options FollowSymLinks
AllowOverride None
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
And try (I'm still not a professional Linux user ):
chmod 755 /home/valera5505
chmod 755 /home/valera5505/sites
chmod 755 /home/valera5505/localhost

Have you assigned correct privileges ?
chown apache:apache -R /home/valera5505/sites
chmod 775 -R /home/valera5505/sites
using -R param is better
also join your user at the apache group
hope you help

Related

You don't have permission to access / on this server

I'm on linux mint and I want to configure a virtual host for my symfony 3 application.
this is my Vhost on /etc/apache2/sites-available/evaluation.conf :
<VirtualHost *:80>
ServerName evaluation.dev
ServerAlias www.evaluation.dev
DocumentRoot /home/sahnoun/InternshipPFE/Dev/systeme_evaluation/web
<Directory /home/sahnoun/InternshipPFE/Dev/systeme_evaluation/web>
AllowOverride All
Order Deny,Allow
Allow from All
</Directory>
ErrorLog /var/log/apache2/project_error.log
CustomLog /var/log/apache2/project_access.log combined
</VirtualHost>
I've added the host in /etc/hosts like that :
127.0.0.1 evaluation.dev
That's not wrking for me and it return this error :
Forbidden
You don't have permission to access / on this server.
Apache/2.4.18 (Ubuntu) Server at evaluation.dev Port 8
Maybe you need to grand files access rights
chown -R www-data:www-data /home/sahnoun/InternshipPFE/Dev/systeme_evaluation/web
chmod -R 755 /home/sahnoun/InternshipPFE/Dev/systeme_evaluation/web
and
move the VirtualHost file from /etc/apache2/sites-available/evaluation.conf to /etc/apache2/sites-enabled/evaluation.conf

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.

Apache cannot access custom directory

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.

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>

Setting the Root to public folder in laravel #Apache2 Server Ubuntu 14.04 LTS

I have the following configuration and yet i am not able to access
Laravel directly.
in /etc/apache2/sites-available/laravel.conf
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html/laravel/public
<Directory /var/www/html/laravel/public>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
the following appears:
Any help would be highly appreciated.
Thanks in advance.
You must to change in your /etc/apache2/sites-enabled/laravel.conf file the directory to the public path. Like this:
<VirtualHost your-ip-address:80>
ServerAdmin admin#amdinserver.es
ServerName localhost
ServerAlias your-url
DocumentRoot /var/www/html/laravel/public
<Directory "/var/www/html/laravel/public">
AllowOverride All
Options FollowSymLinks Indexes
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
You should also check the permissions of the directories. Most folders should be normal "755" and files, "644". Of course, your vendor folder must be avaible to install any update.
Remember that the apache user is www-data.
This is an example that makes the apache application work on laravel bootstrap cache:
sudo chgrp -R www-data storage bootstrap/cache
sudo chmod -R ug+rwx storage bootstrap/cache