Welcome! Log In Create A New Profile

Advanced

Trouble with PHP

Posted by Whippy 
Trouble with PHP
April 10, 2014 02:59AM
I've got nginx working well with Django sites and static content. Now I'm importing some php utilities. There is a folder accessed as http://paulwhippconsulting.com/atwell/ that contains a mix of php, html and javascript files. It is password protected.

I got the password protection working fine and all the files being served but when I add the php location expression to get the php working, strange things happen: I get 403 forbidden for the index.php file and 404 not found for the php and other files.

I've been round the houses trying to set up the right location statement without undue repetition and I got to:

location /atwell/ {
alias /home/paul/atwell;
auth_basic "Please log in";
auth_basic_user_file /home/paul/atwell/htpasswd;
index index.php;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
include fastcgi_params;}}

What am I doing wrong?
Re: Trouble with PHP
April 10, 2014 07:22PM
From continued experimentation, the fix was that I'd accidentally missed the slash of the alias statement. It should have been:

location /atwell/ {
alias /home/paul/atwell/;
auth_basic "Please log in";
auth_basic_user_file /home/paul/atwell/htpasswd;
index index.php;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
include fastcgi_params;}}

Doh! The errors were very obscure for such a trivial mistake. Such is life.

BTW - How do I post code in this forum??
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 307
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready