Apache2 - Error 403 forbidden - apache2

I develop projects that I've located in /home/user/projects directory. This directory is chmod 777. The problem is that I'm always getting Error 403 Forbidden when I try to access this directory or any subdirectory. This is how my /etc/apache2/sites-available/000-default.conf looks like:
<VirtualHost *:80>
ServerName localhost
ServerAdmin user#user.com
DocumentRoot /home/user/projects
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Options +FollowSymLinks
<Directory />
Options FollowSymLinks
AllowOverride None
Order allow,deny
allow from all
</Directory>
<Directory /home/gtakacs/projects>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
Require all granted
</Directory>
</VirtualHost>
What's wrong with this? When I used /var/www as my document root, everything worked.

EDIT : try doing chmod -R 777 /home to make sure all your home is available (note that this solution is NOT RECOMENDED, having your project in /var/www would definitely be a better solution in my opinion)
(Can't comment so post reply)
Isn't there a config file in your project where you're supposed to set who can access the app? Check if you didn't forget to add your ip adress and domain name in this file.
When using Apache2 with Django framework (python), I had the same error, and it was because I forgot to add the domain name to authorized hosts.
You can also check access.log and error.log to have more detailed informations on what caused the error.

Command out:
#Order allow,deny

I had this issue before, the problem might be that your document root does not contain the described directories.

Related

CakePHP directory not found in Digitalocean

I have a create a blog in local, everything is working fine in local. After upload in digitalocean server I am not getting others page without home page.
This is the location : http://IP:8090/cake-blog/
If I try
http://IP:8090/cake-blog/articles
getting Not Found.
In /etc/apache2/apache2.conf I have change none to all like below
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
listen 8090
<VirtualHost *:8090>
ServerName 111.1**.1**.31
DocumentRoot /var/www/wb02/
<Directory /var/www/web02/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
All extension I have enable. What could be problem now ?
Can anybody has idea ?
After enable rewrite , my application working fine. I have applied below procedure.
sudo a2enmod rewrite
Then
sudo service apache2 restart

error apache2 chmod 777 only works

I have my first server and i don't undeststand many things.
First, i've created one user called guillaume and create a specific folder in /home/web and put my website in there and it works BUT...
i've created a second website and it's work but only with chmod 777
i've made chmod -R guillaume:guillaume *
and chmod -R 777 *
but if i do
chmod -R 755 *
i've an error 500, file cannot be writed...
So i don't understand why i don't change permissons to 755, on my first domain it works well.
there is my vhosts:
<VirtualHost *:80>
ServerName bio.dev2prod.fr
ServerAdmin guillaume.batier#gmail.com
DocumentRoot /home/guillaume/web/bio.dev2prod.fr/public
<Directory />
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
Allow from all
</Directory>
<Directory /home/guillaume/web/bio.dev2prod.fr>
Options FollowSymLinks
Require all granted
Order allow,deny
allow from all
Options Indexes FollowSymLinks MultiViews
AllowOverride All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
what am i doing wrong ?
PS: i put my user to www-data group ? it that good ?
Thanks and sorry for my bad english, i'm french..
PS: i'm using laravel 5 so the document root is in /public folder
The problem could be caused by several issues. So let me ask a few questions.
(if I'm not totally wrong) the first <Directory> directive points to the root directory. wich might not directly relate to your problem but are you sure to map any file? I guess it should be same as <DocumentRoot>
The <DocumentRoot> should be the base directory for the particular vhost. So the <Directory> path should normaly belong to a sub directory of the DocumentRoot.
If you wan't to use directories from outside the DocumentRoot mod_alias might be worth looking at.
Alias /somalias/ /path/to/somewhere/else
Hope this helps you a bit.

How to change default Apache conf file for prestashop?

How to make prestashop to use prestashop.conf file which is a clone of 000.default.conf on my local server?
When I disable 000-default.conf, prestashop don't load.
When I enable that back, the web-page loads normally.
I've enabled prestashop.conf and reloaded/restarted Apache.
I use Apache2, prestashop 1.6.1, OS is Linux Mint.
Maybe someone can give me advice what else should I change. I haven't found solution so far.
P.S. prestashop.conf is complete clone of 000-default.conf.
Have you changed the paths to match these of your website?
<VirtualHost *:80>
ServerAdmin youradminlogin#yourwebsite.com
DocumentRoot "path/of/your/website"
ServerName website-name.com
Options All Indexes FollowSymLinks
<Directory "path/of/your/website">
DirectoryIndex index.html
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
Require local
</Directory>
</VirtualHost>
Make shure it is in /etc/apache2/sites-enabled/ !
After modifying this, you'll need to restart the server (sudo apachectl restart)

VirtualHost on Apache2 gives no response

I'm trying to create a virtual host on apache2 but I am getting no response. I have tried serveral tutorials but nothing has helped. This is my file:
<VirtualHost *:80>
ServerName androidwebservice.com
DocumentRoot "/var/www/my_webservice/public"
LogLevel warn
ErrorLog /var/log/apache2/redmine_error.log
CustomLog /var/www/my_webservice/android_access.log combined
<Directory "/var/www/my_webservice/">
Options FollowSymLinks
AllowOverride All
Order deny,allow
Allow from all
RailsEnv production
RailsBaseURI /my_webservice
PassengerResolveSymlinksInDocumentRoot on
</Directory>
</VirtualHost>
I have enabled it using the command sudo a2ensite androidbackend(this is the file name). The file is located in /etc/apache2/sites-available.
The ServerName has been declared in /etc/hosts:
127.0.1.1 androidwebservice.com
Are you visiting androidwebservice.com or www.androidwebservice.com
Because you have declared androidwebservice.com not www.androidwebservice.com
The basic (working) example is over here:
https://reformatcode.com

Resolve Error default site does not exist after update to Ubuntu 13.10 and apache 2.4

I updated my ubuntu lately, I wanted to program in my Ubuntu 13.10, and was setting up apache2, and every time I run the command:
sudo a2ensite default
I get the following error:
Error default site does not exist
how can I fix this issue?
To fix this and any other virtual host running on apache 2.4 I needed to set the
default (and any other virtual host you have)
as
default.conf (add .conf any virtual host you have already set)
Enter the console (terminal) and type the following commands:
sudo mv /etc/apache2/sites-available/default /etc/apache2/sites-available/default.conf
sudo a2ensite default
And we will get the following:
Enabling site default. To activate the new configuration, I needed to run: service apache2 reload
now run:
service apache2 reload
and done.
or create the default.conf file if you don't have it and this is what it should contain by default:
<VirtualHost *:80>
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>
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 /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
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>
The simple way of doing it is adding your .conf file or your virtual host configurations to the site-available folder and then when in the folder and then try again. Worked for me.
I had the same problem, so I tried changing my virtual host configuration file name from default to default.conf, as mentioned here, and it was still not working.
At last i got it. It is necessary also to change the code:
Order allow,deny
Allow from all
to
Require all granted
http://httpd.apache.org/docs/2.4/upgrading.html
After that, I've restarted apache and it worked again

Resources