You are not logged in.

#1 2011-09-24 23:11:01

Akael
Member
Registered: 2011-09-19
Posts: 23

[Solved] I am having problems with PHP in Nginx

Hello,

I have searched here and Google, but can't seem to find the right answer. I am trying to setup a VPS server that has Arch 32bit running Nginx and PHP / PHP-FPM

I have followed the setup instructions here: https://wiki.archlinux.org/index.php/Ng … P_5.3.3.29

I chose the recommended route of using php-fpm, but for some reason all php pages simply download instead of processing.

I thought I might need to add the mime type, so I add it to the /etc/nginx/conf/mime-types like this:

application/x-httpd-php               php;

But the files still just download.

Thanks for your help.

Last edited by Akael (2011-09-25 20:24:16)

Offline

#2 2011-09-25 06:33:23

ViruSzZ
Member
From: The Streets
Registered: 2010-10-14
Posts: 202
Website

Re: [Solved] I am having problems with PHP in Nginx

Please post your nginx conf and your location / and/or location ~ \.php sections.

The day before yesterday I was setting nginx+php-fpm on my vps and it is working just perfect ....


Their Momma Made Em, Their Momma Gave em & now she can`t even SAVE`em | My WebLog

Offline

#3 2011-09-25 15:43:52

Akael
Member
Registered: 2011-09-19
Posts: 23

Re: [Solved] I am having problems with PHP in Nginx

I just uninstalled nginx and php-fmp and re-installed to start over. Here is what I have:


#user http;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       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  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

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

        #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   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ \.php$ {
            try_files	   $uri =404;
	    root           html;
            #fastcgi_pass   127.0.0.1:9000;
	    fastcgi_pass   unix:/var/run/php-fpm/php-fpm.sock;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        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  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers   on;

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

}

For testing I put the following index.html file in /etc/nginx/html:

<head>
	<title>Nginx is Working</title>
</head>
<a href="/index.php">Test php</a> This is a test!

And in the same directory the index.php file:

<?php phpinfo(); ?>

I used:

 
rc.d start nginx
rc.d start php-fpm

The index.html file works, but when I load up the index.php it just downloads.

Thanks for your help.

Offline

#4 2011-09-25 17:30:45

Akael
Member
Registered: 2011-09-19
Posts: 23

Re: [Solved] I am having problems with PHP in Nginx

Ok, got it working.

I originally had apache setup, and after removing apache, php and all php modules and reinstalling only nginx and php it just worked.

Offline

Board footer

Powered by FluxBB