403 error with LAMP and symfony - apache

With a LAMP server running on Ubuntu 16.04, I get the error in the log file defined as in conf :
[Tue Dec 26 16:56:35.930629 2017] [core:error] [pid 21749] (13)Permission denied: [client 127.0.0.1:43872] AH00035: access to / denied (filesystem path '/home/christophe/public_html') because search permissions are missing on a component of the path
I set my .conf file with the following :
<VirtualHost *:80>
ServerName memory.test
ServerAlias www.memory.test
DocumentRoot /home/christophe/public_html/memory/web
<Directory /home/christophe/public_html/memory/web>
AllowOverride All
Require all granted
Allow from all
</Directory>
ErrorLog /var/log/apache2/memory_error.log
CustomLog /var/log/apache2/memory_access.log combined
</VirtualHost>
The access right are set for user christophe:christophe and www-data is part of the group christophe, the mod is 775 but even with the www-data:www-data I get the error.
The /etc/hosts file contains the line :
127.0.0.1 memory.test
I seem to not have selinux installed as this solution is given in some other questions. I would not consider myself as a newbee and I succeeded to have many test environments working this way but this linux is a fresh installation and for a while no other website is working on it...

Did you check that you have 0644 in the directory you are trying to serve?, besides, you also give permissions to www-data user to access that directory, note that the folder you are trying to serve is located in your home directory.

Related

403 error forbidden you don't have permission to access /myapp on this server mod_wsgi and apache

I have installed mod_wsgi as an Apache module and I want to run a simple hello world application to see that the module works properly.
I have followed this guide, which is based on the official Quick Configuration Guide.
After completing all the steps I get a 403 error
Forbidden You don't have permission to access /myapp on this server..
I am using Apache/2.4.10 on Raspbian and my installed mod_wsgi version is
libapache2-mod-wsgi-py3 4.3.0-1 armhf Python 3 WSGI adapter module for Apache.
I have added example.com to my hosts' file as follows:
127.0.0.1 localhost example.com
I created the example.com.conf file in /etc/apache2/sites-enabled/ with contents:
<VirtualHost *:80>
ServerName www.example.com
ServerAlias example.com
ServerAdmin test#test.com
DocumentRoot /usr/local/www/documents
<Directory /usr/local/www/documents>
Order allow,deny
Allow from all
</Directory>
WSGIScriptAlias /myapp /usr/local/www/wsgi-scripts/myapp.wsgi
<Directory /usr/local/www/wsgi-scripts>
Order allow,deny
Allow from all
</Directory>
myapp.wsgi contents:
def application(environ, start_response):
status = '200 OK'
output = 'Hello World!\n'
response_headers = [('Content-type', 'text/plain'),
('Content-Length', str(len(output)))]
start_response(status, response_headers)
return [output]
and created the files/folders for the hello world application with the following permissions:
drwxr-sr-x 2 root www-data 4096 Feb 1 13:18 documents
drwxr-sr-x 2 root www-data 4096 Feb 1 13:22 wsgi-scripts
I also made sure that example.com is served locally and not through DNS with ping.
I cannot understand why my installation is not working.
Are any further configuration options missing or is there something wrong with any of my settings?
I figured it out after a few modifications.
The new example.com.conf file is:
<VirtualHost *:80>
ServerName www.example.com
ServerAlias example.com
DocumentRoot /usr/local/www/documents
<Directory /usr/local/www/documents>
Require all granted
Satisfy Any
</Directory>
WSGIScriptAlias /myapp /usr/local/www/wsgi-scripts/myapp.wsgi
<Directory /usr/local/www/wsgi-scripts>
<Files myapp.wsgi>
Require all granted
Satisfy Any
</Files>
</Directory>
After the syntax changed to match apache 2.4 I got 500 Internal Server Error, which upon further investigation inside apache error.log file indicated the following error:
[wsgi:error] [pid 11216] [client 127.0.0.1:56642] mod_wsgi (pid=11216): Exception occurred processing WSGI script '/usr/local/www/wsgi-scripts/myapp.wsgi'.
[wsgi:error] [pid 11216] [client 127.0.0.1:56642] TypeError: sequence of byte string values expected, value of type str found
To solve this error I changed the output variable assignment in myapp.wsgi file from output = 'Hello World!\n'
to output = b'Hello World!' as it is indicated here.

Apache error 403 after redirecting Apache to /media/... path

When moving files from my main disk (where the OS is installed), to a second disk (other storage), I am trying to redirect Apache to the new disk, but this returns error number 403. I am running Ubuntu 16.04.
I originally redirected Apache to /home/user/Documents by adding the following lines to corresponding files:
in /etc/apache2/apache2.conf
<Directory /home/jawa/Documents/>
#<Directory /media/jawa/R2D2/Webpages>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
and in /etc/apache2/sites-enabled/000-default.conf
DocumentRoot /home/jawa/Documents
#DocumentRoot /media/jawa/R2D2/Webpages
This worked fine, but since I have moved the files to a new location, I must also redirect Apache.
When trying to redirect Apache to /media/jawa/R2D2/Webpages, I toggle the above comments and restart apache using sudo service apache2 restart. Visiting localhost in the browser returns error 403 and using the command cat /var/log/apache2/error.log gives the following log:
[Wed Dec 27 17:24:48.583062 2017] [core:error] [pid 22343] (13)Permission denied: [client ::1:35704] AH00035: access to / denied (filesystem path '/media/jawa/R2D2') because search permissions are missing on a component of the path
Permissions and owners of both folders:
drwxr-xr-x 2 jawa jawa 4096 dec 27 17:12 Documents
drwxrwxrwx 1 jawa jawa 0 dec 27 16:46 Webpages
What is causing the error and how can it be fixed?
Since we know one works and the other does not, list the permissions of both the folder structures :
ls -ld /home/ /home/jawa /home/jawa/Documents
ls -ld /media/ /media/jawa/ /media/jawa/R2D2 /media/jawa/R2D2/Webpages
Once listed compare the two.
The default permissions are controlled by umask and this could result in the permissions being different.

(13)Permission denied: access to /wsgi denied, mod_wsgi, CentOs

I have a problem. I have operating system CentOS 5.8 . I have written this configuration in httpd.conf file:
Listen 85
and at the end of the file:
<VirtualHost *:85>
ServerName localhost
ServerAdmin irakli2692#hotmail.com
DocumentRoot /home/irakli/www/document
<Directory /home/irakli/www/document>
Order allow,deny
Allow from all
Require all granted
</Directory>
WSGIScriptAlias /wsgi /home/irakli/www/wsgi-scripts/wsgi.wsgi
<Directory /home/irakli/www/wsgi-scripts>
Order allow,deny
Allow from all
Require all granted
</Directory>
</VirtualHost>
selinux is permissive.
here are the directories and the file that apache uses:
>
drwxr-xr-x 2 apache root 4096 Aug 1 10:30 document
drwxr-xr-x 2 apache root 4096 Aug 4 12:32 wsgi-scripts
-rw-r--r-- 1 irakli apache 271 Aug 4 12:57 wsgi.wsgi
and when I call
'server ip':85/wsgi
from browser , there is ip of my server instead of 'server ip', I get message: (403) Forbidden: You don't have permission to access /wsgi on this server.
and in /var/log/httpd/error.log writes:
(13)Permission denied: access to /wsgi denied
(13)Permission denied: access to /favicon.ico denied
can anyone help me?
thanks in advance.
A home directory such as '/home/irakli' would itself normally have restrictive permissions such that Apache user cannot see in that directory. It is not enough just to change permissions of where your code is stored, parent directories must also be accessible.

Virtual host showing apache test page and everything else in doc root is forbidden

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/

Setting up pow.cx to use Apache for PHP apps

I've set up Pow and Apache the way they suggest in this tutorial. My httpd-vhosts.conf contains the following entry.
<VirtualHost *:80>
DocumentRoot /Users/michael/Dropbox/Development/test
ServerName test.dev
<Directory "/Users/michael/Dropbox/Development/test">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
I'm still getting a 403 Forbidden when I got to http://test.dev/.
Error log says:
[Wed Nov 21 19:24:21 2012] [crit] [client 127.0.0.1] (13)Permission denied: /Users/michael/Dropbox/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable
[Wed Nov 21 19:24:43 2012] [error] [client 127.0.0.1] (13)Permission denied: access to / denied
Has anyone else had this problem?
This seems to have nothing to do with Pow. Apache doesn't have the necessary permissions to work within /Users/michael/Dropbox/Development/test.
Please check the permissions of this directory, I think they should be 755. Check them with:
cd /Users/michael/Dropbox/Development/
ls -l
And copy paste the line of the test directory.
The issue was the permissions. It finally worked when I chmod'd the full path to the directory I was working in to 755.
~/, ~/Dropbox, ~/Development...etc.
I'll bet there's a nicer way to do this, but it's working. So, there you go.