Symbolic link not allowed apache 2.4 chiliproject - ubuntu-14.04

Few hours ago I upgraded ubuntu 13.10 to 14.04 LTS. I have 1 problem with chiliproject application wich running on Rails.
I got error 403 when I'm trying to access my chiliproject application. In apache2 error log i got:
Symbolic link not allowed or link target not accesibble /var/www/chili
In my apache2 conf i got:
<Directory /var/www/>
Options FollowSymLinks MultiViews SymLinksIfOwnerMatch
AllowOverride All
Require all granted
# Order allow,deny
# allow from all
</Directory>
RailsBaseURI /chili
<Directory /var/www/chili>
AllowOverride all
Options -MultiViews
Require all granted
# Order deny,allow
# Allow from all
</Directory>
I don't know why it's not running. Passenger is running and I'm stuck. Can somebody please help me ?
I tried to check users ownership in catalogs:
ls -ld /var/www/chili
lrwxrwxrwx 1 root root 41 gru 31 2013 /var/www/chili -> /var/www/chiliproject/chiliproject/public
And Target
drwxrwxrwx 4 chiliproject root 4096 gru 31 2013 chiliproject/

change the ownership of /var/www/chili using
sudo chown -R www-data: /var/www/chili
and preferably the ownership of parent dir /var/www as well.
Restart apache2
Apache will be able to read if the owner is www-data.

Related

apache "Access forbidden! Error 403" when creating alias to a directory in home

I'm new to apache.
I'm trying to create an alias to my project folder which is in home/Documents/Projects/blog directory.
I added this to httpd configs:
Alias /blog "/home/ehsan/Documents/Projects/blog/ui/dist"
<Directory "/home/ehsan/Documents/Projects/blog/ui/dist">
DirectoryIndex index.html
AllowOverride All
Options FollowSymlinks
Require all granted
</Directory>
I did this also:
sudo chmod -R 775 /home/ehsan/Documents/Projects/leitner/ui/dist
but I get "403 Access forbidden!" error.
I did the same thing for phpmyadmin and it works.
I read somewhere that apache should have access to all the higher level directories. is that true?
apache version: 2.4.41 (Unix)
os: manjaro 18
I think you can make apache the owner of the folder which it's gonna make changes in it.
Try this:
head to your project directory as below
cd /home/ehsan/Documents/Projects/leitner
and then :
chown -R www-data:www-data ui/
if there was any error going on, send the log of apache here would be helpful

Configuring Apache for localhost

I am new to Linux and Apache. I have tried to configure Apache2 to serve a website I develop on my local Linux Mint machine. I have not attepted to use PHP yet.
In spite of trying to follow all the instructions, I still got a 404 Not Found or 403 Forbidden.
The name of the directory that holds the website is Web and has permissions
drwxr-xr-x 4 www-data www-data 4096 May 15 18:46 Web
I also tried my own user group with no luck. All files inside Web have the usual r-x or r-- permissions for both Group and Others.
/etc/hosts is
127.0.0.1 localhost
/etc/apache2/ports.conf is
Listen 127.0.0.1:80
/etc/apache2/sites-available/Web.conf is
<VirtualHost 127.0.0.1:80>
ServerName Web
ServerAdmin webmaster#localhost
DocumentRoot /xxx/xxxx
</VirtualHost>
Note that /xxx is my custom partion on my local machine and xxxx is a directory in this partion.
/etc/apache2/sites-enabled is
lrwxrwxrwx 1 root root 27 May 23 13:04 Web.conf -> ../sites-available/Web.conf
Finally, the /etc/apache2/apache2.conf included this
<Directory /xxx/xxxx/Web/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
I finally did get localhost to work, but it was not as above. I simply made a link to the directory Web in /var/www/html.
/var/www/html is
-rw-r--r-- 1 root root 11321 Apr 14 15:11 index.html
lrwxrwxrwx 1 root root 17 May 22 16:54 Web -> /xxx/xxxx/Web
This worked with no chances in apache2.conf and I did not have to enable the site (make a link with a2ensite).
The url
localhost/Web
now works with no errors.
It works, but it can not be the right way. What am I doing wrong?
/xxx/xxxx also needs to be readable by www-data in order to work as document root. You'll also need the permissions defined in a directory block.
<Directory /xxx/xxxx/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
Or set your DocumentRoot /xxx/xxxx/Web

Server issue - I can't access php files

I have some issues with my server, for example public_html is my root folder, if I put any php file in root I have this error:
403 Forbidden
You don't have permission to access /check.php on this server.
I try to change permissions on the file is the same. Now the php file is with 0644 permissions
How I can solve this?
Thank you
this is what httpd conf
<Directory "/">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
Allow from all
</Directory>
<Directory "/usr/local/apache/htdocs">
Options All
AllowOverride None
Require all granted
</Directory>
<Files ~ "^error_log$">
Order allow,deny
Deny from all
Satisfy All
</Files
Check if your public_html folder has 755 permission.
If this doesn't work, check if In your /usr/local/apache/htdocs/httpd.conf settings are like the below
<Directory "/usr/local/apache/htdocs">
Options Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
</Directory>
If the settings are correct there, check your .htaccess file.
Last but not the least. Check if your files and folders have the save usergroup as public_html folder
that means you do not have the required permissions to access this file.
open a terminal in that directory and write
ls -l check.php
If the owner of the file isnt www-data or some server user then you have to change it with
chmod 755 check.php
chown www-data:www-data check.php

Apache 2 default document root won't change (Ubuntu)

I want to prevent direct access to the server web root showing the Ubuntu home page at /var/www/html/index.html
I have changed the following:
/etc/apache2/sites-available/000-default.conf
DocumentRoot /var/www/websites
And restarted Apache but it's still going to /var/www/html if I visit my server directly.
Edit:
It appears this problem is only when I access the server on HTTPS. On HTTP it works fine.
You also need to change in /etc/apache2/apache2.conf. Find this:
<Directory /var/www/html/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
and change to your desired directory

How to change DocumentRoot to a custom folder

I got my new VPS server with CentOS 5.8, I could not transfer my domain yet but I want to reach my site via http://my-server-ip and since I am using laravel framework I need to change default DocumentRoot httpdocs to httpdocs/public I have tried to put those lines to httpd.conf file:
<VirtualHost my-server-ip:80>
DocumentRoot /var/www/vhosts/my.domain.org/httpdocs/public
ServerName my.domain.org
</VirtualHost>
However after restarting apache it warns me like this:
Warning: DocumentRoot [/public] does not exist
What should I do?
You'll need to enable read (and possibly execute) privileges on the directory. As root try:
# Recursively set the owner of this folder to 'www'
chown -R www /var/www/vhosts/my.domain.org/httpdocs/public
# Recursively give the owner read and execute privileges
chmod -R u+rx /var/www/vhosts/my.domain.org/httpdocs/public
As an alternative on some setups the user might be called nobody. So if www doesn't work try:
chown -R nobody /var/www/vhosts/my.domain.org/httpdocs/public
EDIT:
As user tink pointed out in the comments
"...in Centos the user running apache is aptly called apache. In debian and it's derivatives, it's www-data."
might be that the apache user can't get into the new directory. try
chmod a+r /var/www/vhosts/my.domain.org/httpdocs/public
I had the same "403 page" problem. Just after I changed Document Root in my /etc/apache2/conf-available/sitename.conf from /var/www/html to /data/www.
To solve the problem I did the folowing:
1) Utilized chown and chmod examples, provided by Mike (2 posts above). Many thanks to him;
2) Added 2 lines to the end of /etc/apparmor.d/abstractions/web-data as follows:
/data/www/ r,
/data/www/** r,
and then run:
sudo service apparmor reload
3) I also needed to add the following bit of code to my apache.conf:
<Directory /data/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
May be some actions were superfluous, but It worked pretty nice for me (Apache v2.4.7, Ubuntu 14.04.1)

Resources