Downloaded Files Are Not Working on Apache DocumentRoot - php

I'm serving my pages with Apache 2.4 on a Ubuntu Mate OS. I've been building a system that allows my clients to download many files from a directory which has been created by each one of them at the moment they sign in.
Apache DocumentRoot is /var/www/public_html and Downloads process works fine in it but by the time I create a folder CLIENTS (absolute path: /var/www/public_html/CLIENTS/) file downloads arent working as they should. There`s just a message saying "Failed - No File" on incoming files.
I've already changed Directory permissions with chown on Linux, changed masks as well as checked Apache configuration using Directory directives but no results! Apache settings below:
VIRTUAL HOST CONFIGURATION
<Directory /var/www/public_html/CLIENTS/>
Options -Indexes +FollowSymLinks +Multiviews
AllowOverride None
Order allow,deny
allow from all
Require all granted
</Directory>
APACHE2.CONF
<Directory /var/www/public_html/CLIENTS/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
LINUX PERMISSIONS
drwxrwxrwx 3 www-data www-data public_html

Related

VPS ubuntu apache server - web page

I bought a VPS server, where I installed apache, mysql, php and phpmyadmin. I created database (like in my local project).
So, now I want to migrate a local project to my server and please, tell me I am right:
Files .php has to be in folder var/www on my apache server? (here is index.html too) and from this folder connect with database?
I have to download NPM on ubuntu
I have to download GIT on ubuntu
Download repo from my github where I've got whole code (webpack dist files, node modules, src and whole config) to /var/www catalog
index.html has to be in top-level directory (just in var/www not for example var/www/src
Please help me and tell if I am thinking right.
Files .php has to be in folder var/www on my apache server? (here is index.html too) and from this folder connect with database?
It depends on what you set in /etc/apache2/sites-available/000-default.conf. I assume that you installed with default configuration from apt-get.
index.html has to be in top-level directory (just in var/www not for example var/www/src
If for example your source codes are in /var/www/src instead of /var/www, the just modify the 000-default.conf. Example:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName your_domain_name.com
DocumentRoot /var/www/src/
<Directory />
Options FollowSymLinks
AllowOverride None
Options -Indexes
</Directory>
<Directory /var/www/src>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
Options -Indexes
</Directory>
ErrorLog /var/log/your_log_file.log
LogLevel warn
CustomLog /var/log/your_access_log_file.log combined
</VirtualHost>
Restart Apache and try open in your browser to see if it works.
As for the database, since you have phpmyadmin, just export the sql data from your local machine and import it into the VPS phpmyadmin.

Index of / with blank page output on server

I uploaded my PHP(codeigniter) project on server. But when I run it I get below window
Index of /
Name Last modified Size Description
Apache Server at 'ip address here' Port 80
project folder is in /var/www/
DocumentRoot is set in projectName.conf directory as /var/www/projectName
Make sure your site .conf points to the public folder and not the site root.
<VirtualHost *:80>
ServerName site.co.uk
DocumentRoot /var/www/site.co.uk/public
<Directory "/var/www/site.co.uk/">
Options -Indexes +FollowSymLinks
Order allow,deny
Allow from all
AllowOverride FileInfo All
Require all granted
</Directory>
</VirtualHost>
You have to make sure about 3 points for this issue
Need .htaccess file in /var/www/projectName/.htaccess which is provided by Codeigniter
Must have rewrite module enabled.
If you are using Ubuntu OS and apache2 then execute sudo a2enmod rewrite in your terminal to enable this.
Must allow override URL by .htaccess rule in apache.conf for /var/www folder.
If you are using Ubuntu OS and apache2 then edit file /etc/apache2/apache.conf and change AllowOverride none to AllowOverride All in block/section of <directory /var/www> and then restart apache by sudo service apache2 restart command.

403:You don't have permission to access /index.php on this server

I'm facing the following message when I visit my website:
You don't have permission to access /index.php on this server.
I am able to visit my other website in same URL, as in http://xiukun.wang/scrapy/, but http://xiukun.wang/datavis/ doesn't work.
I have tried many methods to solve it, like editing my httpd.conf file, however it doesn't work. How do I solve it?
<Directory "/alidata/www">
AllowOverride none
Require all granted
</Directory>
DocumentRoot "/alidata/www"
<Directory "/alidata/www">
Options Indexes FollowSymLinks
AllowOverride all
Require all granted
</Directory>
Have you changed anything in your .htaccess file? Also did you change anything in config file such as DB name user and pass?
Also update the permissions to 755 of your public_html.
EDIT
Since you specified its apache, try these solutions:
Can you open your APACHE config file and find out the index name?
Check your Directive DirectoryIndex and make sure your index is listed, or else upload:
DirectoryIndex index.html index.cgi index.pl index.php index.xhtml
Check for correct dir permissions:
<Directory "/home/domain/www">
Options +Indexes FollowSymLinks +ExecCGI
AllowOverride AuthConfig FileInfo
Order allow,deny
Allow from all
</Directory>
Modify file system permissions of Home directory that APACHE is
installed:
#chmod a+x /apache-home-dir-of installation
Make sure the CGI script requested have executable permissions set on
files. Use chmod command to set permission:
$ chmod +x file.cgi
Check APACHE logs for errors:
# tail -f /path/to/apache/error.logs
Source: https://www.cyberciti.biz/faq/apache-403-forbidden-error-and-solution/

Apache website permissions under Centos 7

I have a site in dir /home/nbo/mysiteA. (nbo is the user)
I've create a new dir structure /var/www/mysiteB/public_html
public_html is a symlink to /home/nbo/mysiteA
httpd.conf settings:
Listen 82
<VirtualHost *:82>
ServerName mysite.com
DocumentRoot /var/www/mysiteB/public_html/
DirectoryIndex index.php
<Directory "/var/www/mysiteB/public_html/">
Options +FollowSymLinks -SymLinksIfOnwerMatch
Require all granted
AllowOverride All
</Directory>
</VirtualHost>
When I test the website I get a 403 error (Forbidden You don't
have permission to access /index.php on this server.)
I've already tried to add the nbo user to apache group.
I've already tried to change the ownership of the entire site to apache user.
What I'm missing?

How do fix apache error "not within configured docroot" under Ubuntu

Greetings experts and gurus, I am looking for some help with an apache php configuration problem.
I have been running several websites from an apache2 setup on an ubuntu server for some time now without problems using the line NameVirtualHost * in my etc/apache2/conf.d/virtual.conf file. I recently updated the server version to the latest lts version and I am now unable to run php files.
I am running all my sites for the location "/home/www/[site-name]/htdocs" and I have setup and enabled all my sites in /etc/apache2/sites-available. I have also disabled the default site.
for each sites file I have specified the following:
# Indexes + Directory Root.
# DirectoryIndex index.html index.htm index.php
DocumentRoot /home/www/[site-name]/htdocs/
# CGI Directory
ScriptAlias /cgi-bin/ /home/www/[site-name]/cgi-bin/
<Location /cgi-bin>
Options +ExecCGI
</Location>
# Logfiles
ErrorLog /home/www/[site-name]/logs/error.log
CustomLog /home/www/[site-name]/logs/access.log combined
I restart apache and enter the url for a php test page on my server and I am met with an "Internal Server Error". When I check the error log I get:
Script "/home/www/[site-name]/htdocs/test.php" resolving to "/home/www/[site-name]/htdocs/test.php" not within configured docroot.
For some reason when looking into the error, suphp came up a lot. According to this link:
Don't be fooled into thiking this has anything to do with the Apche virtual host document root, this is actually another setting in the suphp config file. Including the paths which contained the RoundCube scripts fixed this one. For example:
docroot=/var/www:/usr/share/roundcube:/var/lib/roundcube:${HOME}/public_html
You need to edit your /etc/suphp/suphp.conf file and change the docroot to whatever is appropriate.
It looks you missed the virtual hosts configuration for every site name:
<VirtualHost IP:80>
ServerName yourdomainname
ServerAlias www.yourdomainname
DocumentRoot /home/www/[site-name]/htdocs/
ScriptAlias /cgi-bin/ /home/www/[site-name]/cgi-bin/
<Location /cgi-bin>
Options +ExecCGI
</Location>
ErrorLog /home/www/[site-name]/logs/yourdomainname.ua-error.log
CustomLog /home/www/[site-name]/logs/yourdomainname-access.log combined
</VirtualHost>
<Directory "/home/www/[site-name]/htdocs/">
Options FollowSymLinks
AllowOverride None
Order allow,deny
<Limit GET POST OPTIONS>
Order allow,deny
Allow from all
</Limit>
<LimitExcept GET POST OPTIONS>
Order deny,allow
Deny from all
</LimitExcept>
</Directory>
Thanks for all the help, I got there in the end. It seems that upgrading to Ubuntu 10.04 turned on suPHP. It has ended up being a good thing as the reason why I was getting errors was down to file management in my htdocs getting sloppy.
To fix my issues I had to do several things:
First I turned on suphp error messages in /etc/apache2/sites-available/[site-name]. This gave me the true error, which told me that some of my pages had the wrong permissions. I then set all my folder permissions in www to 755 and the files to 644. I also had to lower the min_uid and min_gid fileds in suphp.conf to 33.

Categories