You are not logged in.
Pages: 1
Hello
I'd love to switch from apache2 running on a Debian Wheezy VM I have to Nginx on Arch (not a VM)
Nginx on it's own works but when I install php and php-fpm it just doesn't work. I get everything from "file not found" errors to "access denied" to:
"An error occurred.
Sorry, the page you are looking for is currently unavailable.
Please try again later."
Now I have tried to follow the Arch wiki on setting this up (except that I didn't set up nginx in chroot -- does it matter?)
I've searched around and tried numerous changes to my nginx.conf file (and yes I restart nginx and php-fpm each time I save it) and it still won't work.
here's my nginx.conf file
#user html;
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 8080;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root /srv/http/sites;
index index.html index.htm;
}
#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 /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
location ~ \.(php|html|htm)$ {
#fastcgi_pass unix:var/run/php-fpm/php-fpm.sock;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
}
#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$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$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;
# }
#}
}
so far I am finding setting up php to work with nginx to be waaaaaaaay harder than with apache.
Please help
Offline
Show us your php-fpm config too. I'm guessing it isn't configured to listen on 127.0.0.1:9000; which is why the socket is recommended. Also; you could have a look at both the nginx and fpm error-logs if you want to fix this yourself. Also; why haven't you configured a global root?
Try moving one from a location-block to 'server'. If you still have problems you could have a look at https://bbs.archlinux.org/viewtopic.php?id=178203
Last edited by Spider.007 (2014-03-14 17:26:07)
Offline
thanks for the tips! I'll look into it. I've got nginx working with php-fpm nicely on Openbsd I'll also look there at the configs to see if there isn't something I haven't overlooked.
I really want to get it going on Arch though because Pacman >> PKG_ADD IMHO
Offline
I put hell in the title because as I tried to fix the issue I would get the various errors, each time, after editing the .conf, restarting nginx and reloading the page. Ah good times.
Offline
This is a basic working configuration. (The listen-socket in php-fpm.conf is /run/php-fpm/php-fpm.sock and cgi.fix_pathinfo is on )
server {
listen 80;
server_name localhost;
root /srv/http;
location / {
autoindex on;
index index.html index.php index.htm;
}
location ~ [^/]\.php(/.*)?$ {
fastcgi_split_path_info ^(.+\.php)(/.*)?$;
# the if is not really necessary.
# php-fpm already checks if the script has a .php extension
#~ if (!-f $document_root$fastcgi_script_name) {
#~ return 404;
#~ }
fastcgi_pass unix:/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$uri;
fastcgi_param PATH_INFO $fastcgi_path_info if_not_empty;
}
location ~ /.ht {
deny all;
}
}
Last edited by progandy (2014-03-15 23:48:38)
| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |
Offline
thank you for your replies. I thought I had it going on openbsd, but can't seem to get phpMyAdmin going, and even Drupal7 won't go through the setup. somehow some php modules not loading I think..
Offline
Pages: 1