403 Forbidden trying to execute php scripts - php

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?

Related

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

rewrite.php not exists in elgg installation files

I am trying to install elgg version 1.12.2 according to documentation http://learn.elgg.org/en/1.x/intro/install.html
I have uploaded elgg on server, created MySql database and created data folder.
After that I open in thew latest chrome my website and process installation starts.
Immediately I have experienced warning:
I have tried to open "test" link(which points to rewrite.php page) but this page does not exists???
Here is list of all files in my root folder: http://i.imgur.com/kcQkeei.png
I have downloaded latest elgg from https://elgg.org/download.php
Mod Rewrite should be installed and enabled. If you have done this before it seems to be a permission problem.
Try running these commands:
chown apache: path_to_elgg_dir -R
chmod 644 path_to_elgg_dir -R
It might be selinux issue. You can check selinux status using sestatus -v.
In order to disable selinux follow this link.
rewrite.php does not exist indeed as it's special path that's supposed to be rewritten by mod_rewrite of equivalent (depending on type of web server you're using). If you get 404, that means you have not configured URL rewriting properly.
The link that you posted yourself contains "Troubleshooting" section. Additionally I'd recommend enabling curl in your PHP configuration to make sure that installer is able to reliably test URL rewriting (your error indicates that it's missing).
You did not mention any issues with following installation documentation? What server are you using? Did you have problems with any steps described in documentation?

Forbidden Error in Apache after extracting files

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

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.

Categories