# PHP Not Working

**URL:** <https://www.ruby-forum.com/t/php-not-working/205870>\
**Category:** NGINX\
**Created:** [April 17, 2011, 9:47pm UTC](https://www.ruby-forum.com/t/php-not-working/205870 "2011-04-17T21:47:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [April 17, 2011, 9:47pm UTC](https://www.ruby-forum.com/t/php-not-working/205870/1 "2011-04-17T21:47:25Z")

</div>

I am aware I am posting this again but a boy told me to change the port,  
which I have however it only made loading the php page take longer, but  
it still ends in a resulted broken page.

Here is my default.conf file, if anybody can fix it up so I can get my  
site working.

[code]# You may add here your

# server {

# …

# }

# statements for each of your virtual hosts

server {  
listen 80;  
server\_name [thefoool.co.uk](http://thefoool.co.uk);

access\_log /media/disk/localhost.access.log;

location / {  
root /media/disk/web\_server;  
index index.html index.htm index.php;  
}

```
    root /media/disk/web_server;

```

location /doc {  
autoindex on;  
allow 127.0.0.1;  
deny all;  
}

location /games {  
allow all;  
autoindex on;  
}

```
    location /music {
            allow all;
            autoindex on;
    }

    location /layla {
            allow all;
            autoindex on;
    }

```

#error\_page 404 /404.html;

# redirect server error pages to the static page /50x.html

# 

error\_page 500 502 503 504 /50x.html;  
location = /50x.html {  
root /media/disk/web\_server;  
}

# proxy the PHP scripts to Apache listening on 127.0.0.1:80

# 

#location ~ .php$ {  
#proxy\_pass[http://127.0.0.1](http://127.0.0.1);  
#}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

# 

location ~ .php$ {  
fastcgi\_pass [thefoool.co.uk:81](http://thefoool.co.uk:81);  
fastcgi\_index index.php;  
fastcgi\_param SCRIPT\_FILENAME  
/media/disk/web\_server/$fastcgi\_script\_name;  
fastcgi\_param SCRIPT\_NAME  
/media/disk/web\_server/$fastcgi\_script\_name;  
include /etc/nginx/fastcgi\_params;  
}

# deny access to .htaccess files, if Apache’s document root

# concurs with nginx’s one

# 

#location ~ /.ht {  
#deny all;  
#}  
}

# another virtual host using mix of IP-, name-, and port-based

configuration

# 

#Server {  
#listen 8000;  
#listen somename:8080;  
#server\_name somename alias another.alias;

#location / {  
#root html;  
#index index.html index.htm;  
#}  
#}

# HTTPS server

# 

#Server {  
#listen 443;  
#server\_name localhost;

#ssl on;  
#ssl\_certificate cert.pem;  
#ssl\_certificate\_key cert.key;

#ssl\_session\_timeout 5m;

#ssl\_protocols SSLv2 SSLv3 TLSv1;  
#ssl\_ciphers  
ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;  
#ssl\_prefer\_server\_ciphers on;

#location / {  
#root html;  
#index index.html index.htm;  
#}  
#}[/code]

Posted at Nginx Forum:

> **[PHP Not Working \[2\]](https://forum.nginx.org/read.php?2,191913,191913#msg-191913)**
>
> I am aware I am posting this again but a boy told me to change the port, which I have however it only made loading the php page take longer, but it still ends in a resulted broken page. Here is my default.conf file, if anybody can fix it up so I can...

---

<div class="post-metadata">

**Author:** ![Cain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/85e7bf/32.png) [@Cain](https://www.ruby-forum.com/u/Cain)\
**Post date:** [April 17, 2011, 10:44pm UTC](https://www.ruby-forum.com/t/php-not-working/205870/2 "2011-04-17T22:44:18Z")

</div>

Your error is not in your Nginx configuration. Are you sure your have  
configured PHP to listen on port 81, though? This seems like an odd port  
to start PHP on. Can you paste your php-fpm configuration?

Posted at Nginx Forum:

> **[Re: PHP Not Working \[2\]](https://forum.nginx.org/read.php?2,191913,191933#msg-191933)**
>
> I am aware I am posting this again but a boy told me to change the port, which I have however it only made loading the php page take longer, but it still ends in a resulted broken page. Here is my default.conf file, if anybody can fix it up so I can...

---

<div class="post-metadata">

**Author:** ![Cain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/85e7bf/32.png) [@Cain](https://www.ruby-forum.com/u/Cain)\
**Post date:** [April 18, 2011, 12:27am UTC](https://www.ruby-forum.com/t/php-not-working/205870/3 "2011-04-18T00:27:25Z")

</div>

Hi Cain,

On 17/04/2011 20:46, Cain wrote:

> I am aware I am posting this again but a boy told me to change the port,  
> I haven’t been called a boy these last 50 years! 🙂  
> which I have however it only made loading the php page take longer, but  
> it still ends in a resulted broken page.

snip

> # proxy the PHP scripts to Apache listening on 127.0.0.1:80
> 
> # 
> 
> #location ~ .php$ {  
> #proxy\_pass[http://127.0.0.1](http://127.0.0.1);  
> #}
> 
> # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
> 
> # 
> 
> location ~ .php$ {  
> fastcgi\_pass thefoool.co.uk:81;  
> That is not port 9000 that is 81. Which are you using?  
> fastcgi\_index index.php;  
> I suspect the key parts you need are:

```
  index index.php;
  location ~ \.php {
        fastcgi-pass 127.0.01:9000;
        fastcgi-param SCRIPT_FILENAME

```

$document\_root$fastcgi\_script\_name;  
include /etc/nginx/fastcgi\_params;  
}

But you must match the port (the 9000) with the port you have started  
php-fastcgi on.

Regards

Ian
