0

I've uploaded some php scripts to my server under /php directory and sub directories.

When using my root user in terminal and running php file.php it execute it perfectly, but when trying to reach the same file through the browser - nothing happens...

I guess it something to do with permissions.

I've tried chmod 755 phpdirectory but it doesn't work..

what else should i do in order to give the browser user the ability to run php scripts ?

Update I'm using FreeBsd system with apache and Direct Admin on it. Can some one please guide me to where to check the settings ?

Asaf Nevo
  • 11,338
  • 23
  • 79
  • 154
  • 2
    If you're using the apache server, then it will run under the user the apache server uses. If you run it yourself, then it will run under your user. – rid Oct 06 '13 at 09:00
  • see this:: http://stackoverflow.com/questions/15341713/php-script-works-in-the-terminal-but-not-the-browser – Sudhir Bastakoti Oct 06 '13 at 09:04
  • There is no such thing as "nothing happens". You should get at least an error code or a timeout. – Sumurai8 Oct 06 '13 at 09:04
  • @Sumurai8 no i get just a blank screen – Asaf Nevo Oct 06 '13 at 09:16
  • 1
    @AsafNevo Even that is not "nothing happens". Open the developer console and look under the network tab, then reload the page. It will tell you the status code and the exact response you get. – Sumurai8 Oct 06 '13 at 09:23
  • @Sumurai8 your comment was great.. doing what you said i found a 500 internal error which was caused by error in the php but the php.ini was set not to display error.. if you'll write it as an answer - i will accept it :) – Asaf Nevo Oct 06 '13 at 12:41
  • @AsafNevo What I gave was nothing more than basic debugging advice and doesn't really answer the question. I think you are able to answer your own question after an x amount of time, and you'll be able to write more thorough everything you have done to fix the problem. – Sumurai8 Oct 06 '13 at 12:54
  • you are right, and the curve of learning is definitely getting better along time. i wasn't aware of that option to see the networking, that why i was so excited :) – Asaf Nevo Oct 06 '13 at 13:06

3 Answers3

0

Usualy All webb access to a file is done through a specific user (eg. www-data) in order for the file to be reachable through web www-data needs permission to reach the code. How you setup that depends on what system the server is running.

Also the server document_root needs to be setup correctly. Where you do this also depends on what server you are runnning.

EDIT after update question.

In apache this is normally done through the file /etc/apache/sites-avalible/your_site If the server only serves one page you can do this in http.conf

Philip G
  • 4,098
  • 2
  • 22
  • 41
0

Check whether the User directive inside httpd.conf file is same as the user you used to ran the PHP script.

Ismail Faruqi
  • 482
  • 4
  • 16
0

You need to make sure your PHP scripts have same user and group as you configured in Apache configuration(/etc/httpd/httpd.conf in CentOS 6.4).

# User/Group: The name (or #number) of the user/group to run httpd as.
User apache
Group apache

Check the owner and group of your PHP directory and files. In this case owner and group (root/root) are not same as Apache User and Group.

# ls -alh
total 516K
drwxr-xr-x.  5 root root 4.0K Aug 29 17:57 .
drwx------.  5 root root 4.0K Jun 24 12:06 ..
-rwxr--r--.  1 root root 356K Jul  7  2012 index.php

To change the owner and group of your PHP directory. Use the following command.

# chown -R apache:apache www
Thein Hla Maw
  • 685
  • 1
  • 9
  • 28