Ask Your Question
1

still trying to get PHP to work

asked 2012-01-02 00:13:53 -0500

willettwork gravatar image

I just restarted both httpd and mysql. both seem good. Why can I not get the simplest php script to come up in either of my browsers? I've been working on this for many days now. I really want my scripting to work.

edit retag flag offensive close merge delete

5 Answers

Sort by ยป oldest newest most voted
1

answered 2012-01-02 02:11:48 -0500

cwalkdawg gravatar image

Perhaps you are posting your PHP scripts into the incorrect directory. They should check the DocumentRoot listed in your httpd.conf.

You can find that conf file under:

/etc/httpd/conf/httpd.conf

In this file, unless mirrored somewhere else, you will find all your VirtualHost information within

<VirtualHost>
</VirtualHost>

tags like the above.

The

DocumentRoot

property is the directory where the PHP scripts will be able to be executed.

Put a simple PHP (1) script in a .PHP file within the directory listed under DocumentRoot in httpd.conf and then go to

http://localhost/<<yourfilename>>.php

Hopefully that will work.

(1) The simplest php script to test is

edit flag offensive delete link more
1

answered 2012-01-02 02:11:17 -0500

kumarpraveen gravatar image

Where did you put your php script? Please check DocumentRoot value in httpd.conf and put your script in same location. You can change that location by editing httpd.conf.

# grep -i 'DocumentRoot' /etc/httpd/conf/httpd.conf
edit flag offensive delete link more
0

answered 2012-01-03 04:38:13 -0500

TWCrap gravatar image

If the above doesn't work, check if your webserver is linsting on port 8080. In that case, you have to go to http://localhost:8080/<pathtofile>/what.php

edit flag offensive delete link more
0

answered 2012-01-06 11:14:30 -0500

asto gravatar image

Here's step by step instructions to get php working with a server called nginx (way better than apache httpd!)

First install nginx,php and php-fpm

sudo yum -y install nginx php php-fpm

Then open up your favourite text editor and edit /etc/nginx/nginx.conf and add the following configuration under server{}

location ~ \.php$ {
             include fastcgi_params;
             fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
             fastcgi_pass  127.0.0.1:9000;
        }

Now start nginx and php-fpm

sudo service nginx start; sudo service php-fpm start

That's it!

The entire nginx.conf configuration file should look something like this

user              nginx;
worker_processes  1;

error_log  /var/log/nginx/error.log;
#error_log  /var/log/nginx/error.log  notice;
#error_log  /var/log/nginx/error.log  info;

pid        /var/run/nginx.pid;


#----------------------------------------------------------------------
# Events Module 
#
#   http://wiki.nginx.org/NginxHttpEventsModule
#
#----------------------------------------------------------------------

events {
    worker_connections  1024;
}


#----------------------------------------------------------------------
# HTTP Core Module
#
#   http://wiki.nginx.org/NginxHttpCoreModule 
#
#----------------------------------------------------------------------

http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    # Load config files from the /etc/nginx/conf.d directory
    # The default server is in conf.d/default.conf
    include /etc/nginx/conf.d/*.conf;

    server {
        listen 127.0.0.1:80;
        root /var/www/html;
        location ~ \.php$ {
             include fastcgi_params;
             fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
             fastcgi_pass  127.0.0.1:9000;
        }   
    }
}
edit flag offensive delete link more
0

answered 2012-01-02 03:10:44 -0500

SoumyaC gravatar image

I have answered your question http://ask.fedoraproject.org/question/806/does-it-matter-where-i-run-a-php-script?answer=1529#answer-container-1529

I guess the problem is same only as the other php question you posted. Check the above answer and set your "DocumentRoot". Put all your files in that DocumentRoot.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2012-01-02 00:13:53 -0500

Seen: 2,805 times

Last updated: Jan 06 '12