LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   Slack14.1 nginx works but no php (https://www.linuxquestions.org/questions/slackware-14/slack14-1-nginx-works-but-no-php-4175503648/)

skinney 05-01-2014 10:34 PM

Slack14.1 nginx works but no php
 
slack 14.1 x64, nginx 1.6, php 5.4.27
Installed nginx from slackbuild
php was already installed
nginx works but i can't get php files to load. I've been all over trying different configs. here's my current state.
> ps aux | grep [p]hp
Code:

root      2130  0.0  1.7 243228  8952 ?        Ss  13:48  0:00 php-fpm: master process (/etc/php-fpm/php-fpm.conf)                                           
nobody    2131  0.0  1.6 243228  8580 ?        S    13:48  0:00 php-fpm: pool www                                                                             
nobody    2132  0.0  1.6 243228  8408 ?        S    13:48  0:00 php-fpm: pool www

> ps aux | grep [n]ginx
Code:

root      1692  0.0  0.2  23964  1504 pts/3    S    11:36  0:00 sudo emacs /etc/nginx/nginx.conf
root      1693  0.1  6.4 288072 32844 pts/3    S+  11:36  0:14 emacs /etc/nginx/nginx.conf
root      2137  0.0  0.4  57624  2104 ?        Ss  13:48  0:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
nobody    2138  0.0  0.6  58008  3452 ?        S    13:48  0:00 nginx: worker process

> /etc/nginx.conf
Code:

#user  nobody;
worker_processes  4;

#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;
...
 include /etc/nginx/conf.d/*.conf;
 include /etc/nginx/sites-enabled/*.conf;
...

i sniped the commented out blocks
> /etc/nginx/sites-enabled/dokuwiki.conf
Code:

server {
  server_name dokuwiki;
  listen 80;
  autoindex off;
  client_max_body_size 15M;
  client_body_buffer_size 128k;
  index index.html index.htm index.php doku.php;
  access_log  /var/log/nginx/dokuwiki/access.log;
  error_log  /var/log/nginx/dokuwiki/error.log;
  root /var/www/dokuwiki;

location / {
  try_files $uri $uri/ @dokuwiki;
}

location ~ ^/lib.*\.(gif|png|ico|jpg)$ {
  expires 30d;
}

location = /robots.txt  { access_log off; log_not_found off; }
location = /favicon.ico { access_log off; log_not_found off; }
location ~ /\.          { access_log off; log_not_found off; deny all; }
location ~ ~$          { access_log off; log_not_found off; deny all; }

location @dokuwiki {
  rewrite ^/_media/(.*) /lib/exe/fetch.php?media=$1 last;
  rewrite ^/_detail/(.*) /lib/exe/detail.php?media=$1 last;
  rewrite ^/_export/([^/]+)/(.*) /doku.php?do=export_$1&id=$2 last;
  rewrite ^/(.*) /doku.php?id=$1 last;
}

location ~ \.php$ {
  try_files $uri =404;
  #fastcgi_pass  unix:/var/run/php-fpm/dokuwiki.sock;                                                                                                       
  fastcgi_pass  127.0.0.1:9000;
  fastcgi_index  index.php;
  fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
  include /etc/nginx/fastcgi_params;
  fastcgi_param  QUERY_STRING    $query_string;
  fastcgi_param  REQUEST_METHOD  $request_method;
  fastcgi_param  CONTENT_TYPE    $content_type;
  fastcgi_param  CONTENT_LENGTH  $content_length;
  fastcgi_intercept_errors        on;
  fastcgi_ignore_client_abort    off;
  fastcgi_connect_timeout 60;
  fastcgi_send_timeout 180;
  fastcgi_read_timeout 180;
  fastcgi_buffer_size 128k;
  fastcgi_buffers 4 256k;
  fastcgi_busy_buffers_size 256k;
  fastcgi_temp_file_write_size 256k;
}

location ~ /(data|conf|bin|inc)/ {
  deny all;
}

location ~ /\.ht {
  deny  all;
}

}

in /var/www/dokuwiki/index.php
Code:

<? phpinfo() ?>
where am i going wrong?
I'd also like to use a unix socket instaed of tcp over 127.0.0.1:9000
which i confirmed is is up and listening with
> netstat -lnp | grep 9000

If you all have input on how to tell php to listen on a .sock I'd love to hear it

Chuck56 05-02-2014 07:54 AM

I'm running apache/php-fpm instead of nginx/php-fpm but the concept is similar. nginx calls fastcgi, is that the right module? Here's an apache/mod_proxy_fcgi .htaccess rewrite rule as an example.

Code:

RewriteRule ^(.*\.php)$ fcgi://localhost:9000/var/www/$1 [P,L]
Hope that helps.

skinney 05-02-2014 08:02 AM

in nginx vhost .conf it's in the 'location' block inside the 'server' block
Code:

location ~ \.php$ {
  try_files $uri =404;
  #fastcgi_pass  unix:/var/run/php-fpm/dokuwiki.sock;                                                                                                       
  fastcgi_pass  127.0.0.1:9000;
  fastcgi_index  index.php;
  fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
  include /etc/nginx/fastcgi_params;
  fastcgi_param  QUERY_STRING    $query_string;
  fastcgi_param  REQUEST_METHOD  $request_method;
  fastcgi_param  CONTENT_TYPE    $content_type;
  fastcgi_param  CONTENT_LENGTH  $content_length;
  fastcgi_intercept_errors        on;
  fastcgi_ignore_client_abort    off;
  fastcgi_connect_timeout 60;
  fastcgi_send_timeout 180;
  fastcgi_read_timeout 180;
  fastcgi_buffer_size 128k;
  fastcgi_buffers 4 256k;
  fastcgi_busy_buffers_size 256k;
  fastcgi_temp_file_write_size 256k;
}

this douwiki.conf i got right from dokuwikis site. i have nginx and php5-fpm running great in an unbuntu container. nginx and php was installed from ubuntu repos.

it must be a php config issue.

skinney 05-02-2014 09:09 AM

the code in index.php was wrong!

ahhh

this works
Code:

<?php
  phpinfo();
?>



All times are GMT -5. The time now is 09:18 PM.