Forbidden Error in Apache after extracting files - php

My dedicated server has Debian wheezy installed along with Apache2 php and mysql. ISPConfig3 is installed as the control panel.
After creating a site under ISPConfig and a shell user account with it I uploaded the tar file into the web directory and extracted the files.
The default ispconfig index.html file would display how ever after the extraction the index.php is not getting picked up and after deleting the default index.php i get the error message
Forbidden
You don't have permission to access / on this server.
Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.
I tried going directly to www.domain.com/index.php and that doesnt work too.
Do I have to modify anything in apache? Any help would be appreciated.

That error is telling you the server can't read the file (or files) specified in your DirectoryIndex directive, and is trying to display a 403 (security) error document instead, which is doesn't have permission to read either.
You need to check what user your httpd daemon is running as, and make sure that user had at least read permissions to all the files in your DocumentRoot. The best way to do this is to ensure that user is the owner of the files.
On a Redhat/CentOS system, httpd runs as the user "apache"
chown -R apache:apache /var/www/html

Related

Symfony 3.3.9 deployment to PHP 5.6 wont render default application

I am struggling to get a default Symfony application from PhpStorm 2017.2.1 which works locally (Windows), but seemingly will not deploy to a remote server (Linux) and run.
Windows setup:
Windows 10, PHPstorm 2017.2.1, php5.6, symfony 3.3.9, default symfony app (namely, I installed Symfony and am using their default app -- no personally written code). This works, when run with "php bin/console server:run" from a command prompt, and "localhost:8000" in a broswer, generating "Welcome to Symfony 3.3.9" "Your application is now ready. You can start working...."
I believe nothing is wrong here.
Remote Linux Setup:
Shared hosting, bash 4.2.46, I don't have root access, everything supposed to go in the public_html directory. A simple one line phpinfo.php file containing only
"<?php phpinfo(); ?>"
placed in that directory will render when accessing
'www.example.com/phpinfo.php'
the usual phpinfo() dump, thus I believe the PHP server is operational. I'm not sure if there is some configuration error with apache that is causing problems on the server for something more complicated like a default symfony application, or whether the issue is my PHPstorm configuration.
PHPstorm deploy configuration:
SFTP to www.example.com (test connection works, files will upload).
root path: /home/example/public_html
username and password work, auth type=password.
Web server root URL=sftp://ftp.example.com,
and it does allow files to be browsed on the server.
PHPstorm mappings:
local path=c:\blah (works, since files upload)
deployment path on server=/
web path on server=/web
I have only one mapping.
PHPstorm excluded paths:
empty
Upload and Prepare:
Cleared Linux public_html directory of everything including . files. Uploaded the local app to remote Linux server. Logged on via SSH and chmod everything public_html and under to 777 (yes, horrible security practice, but this is a test, and there is nothing else on the domain at the moment, and this will rid me of any security protection issues for test).
Test results, in order:
Test1: Browsing to www.example.com results in
**
Forbidden
You don't have permission to access / on this server.
Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.
**
Test 2: Browsing to www.example.com/web results in
**Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator at webmaster#example.com to inform them of the time this error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error log.
Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.
**
Logs: Performing
ls -alsgR | grep log
produces nothing that appears to be a server logfile.
What process do I follow to get the default application to work?
This appears to have been a web server issue.
My web hosting provider would not allow me to see the httpd.conf file for this shared hosting situation, but did run test cases for me, and for whatever the configuration is, determined that
1. All files within public_html/ need to be have permissions 644 (777 not good enough)
2. All directories within public_html/ need to have permissions 755 (777 not good enough).
The two bash commands to do this, run after cd to the public_html/ folder are
find . -type f -exec chmod 644 {} \;
find . -type d -exec chmod 755 {} \;
Very frustrating problem solved w.r.t. the server.
Although I haven't fully checked it out, PHPstorm does appear to have,
under file/settings/Build/Deployment/Options, an ability to override default
protections for files and directories, so I believe it likely that any
problems occurring with PHPstorm can be fixed by configuration of those
overrides.

PHP include file from outside of webroot

I'm using Apache and PHP. Webroot directory is /home/name/public_html
I want to include a file from /home/name/abc.php
include_one "/home/name/abc.php";
I got failed to open stream: Permission denied warning.
If i move the same file inside the webroot /home/name/public_html/abc.php
There is no error.
Apache User and Group has the permission to access the file /home/name/abc.php
I have another server with the similar configuration, it is working. Just want to know the possible reason.
I tried to run the PHP script directly in linux console, there is no permission issue. I guess the problem is in Apache configuration.
You should verify that php is really executed as the apache user. Depending on your configuration it might be possible that php is running under a different user, e.g. if your Apache is set up to use php-fpm.
If the server is a linux system, putting this
<?php
echo "<pre>";
var_dump(posix_getpwuid());
into a file and accessing via the web browser should show you the user informations.
I found the way to solve this issue from here. I have SELinux running on my Centos 7 Virtual Server.
I need to grant httpd permission to read from /home dir using:
sudo setsebool httpd_read_user_content=1

When creating virtual-host, apache would work only with /var/www/html/ directory

I just moved from WAMP to LAMP, and can't figure out this problem that I am facing.
Whenever I create new vhost which is not in this directory /var/www/html/ i get a 403 forbidden message. (Permission are the same and there is an index file)
It seems to me that somewhere in Linux you specify a list of directories and apache works explicitly with those ones.
I use Apache 2.4.6.
I appreciate your help,
After checking the error log(vhost), I found this error message "search permissions are missing on a component of the path".
Meaning that one of the parent directories from where the vhost was located didn't not have search (+x) permission for the apache user.

What are the configurations required for Apache (HTTPD) for enabling directory/file writing and file uploading?

Hie,
I have installed a new httpd server and loaded my web application on it which is designed to upload files on the server. Also it creates new directories and files inside the web directory of the application. But i am unable to use these features because it gives me a permission denied error. I searched onto the web and got the clue that i require to enable ftp login through my PHP script. I changed the ownership and permissions but it is still not working. Can please someone explain the configuration required in simple steps to enable these features. I am using CentOs-6. It will be highly appreciated. Sorry for the miss formed question.
Configurations I tried out:
Create a Linux user and group named webuser. Give it permissions of
the directory of my web applications. Install Vsftpd and allow webuser
to login. Set webuser FTP root directory same as my Web Application
directory (i.e /var/www/mysite)
My httpd user is apache.
I was doing everything right. The only problem was CentOS SELinux. It was not allowing apache to write files into the web directory.
Using the command "setenforce 0" , i closed it down and everything started working.
Later, I added an exception into my SELinux policies to fix issues.

403 Forbidden trying to execute php scripts

Fresh install of a Debian server. Apache2, PHP5.
When I try to browse a PHP file I get 403 Forbidden. I am able to browse to html files.
I have tried the following:
Reinstalled Apache, PHP, libapache2-mod-php5
Restarted Apache
Checked the conf file thoroughly, copied from default, set the correct Directory path and allow from all
Checked permissions of directory, as a test have given full 777 permission to /var/www/site - still forbidden
Cant think of what else to try ?
Perform chmod 755 of the directory in which the PHP scripts reside.
After that restart the Apache/nginx server
or
if above method not work then contact your hosting provider to whitelist that url to phpscript because it can be issue with mod_security. Its the most annoying thing hostgator user are facing.
Check if the alow/deny pattern in your http.conf is set correctly.
What's written to the apache error log?

Categories