PHP at the root directory using Ngnix on Linode and Ubuntu 12.04
Posted
by
Steve Kinney
on Server Fault
See other posts from Server Fault
or by Steve Kinney
Published on 2012-06-03T00:40:28Z
Indexed on
2012/06/03
22:42 UTC
Read the original article
Hit count: 315
I originally set up my Linode to use it with the Sinatra applications using Phusion Passenger that I was developing and I have it working great for that. However, as time goes on, I find myself needing just a wee bit of PHP to do a server-side thing here or there.
My basic set up was based off of this Linode recipe (I copied and pasted the parts that I needed—I did not install Redis and Node). If I go to http://scholarsnyc.com/index.php
everything works great. If I just go the base URL however, I get a 403 Forbidden error (I have a vanilla HTML page there for now). I've played with file permissions and the same file will work if I call it directly. I've done my homework and nothing I try seems to work. I'm sure there is an obvious error. I'm also sure that there are some rookie mistakes in my Nginx configuration (some of those mistakes are the artifacts of trying different fixes from my research.
user www-data www-data;
worker_processes 1;
events {
worker_connections 1024;
}
upstream php {
server 127.0.0.1:9001;
}
http {
passenger_root /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.12;
passenger_ruby /usr/local/bin/ruby;
include mime.types;
default_type application/octet-stream;
index index.php index.html index.htm;
sendfile on;
keepalive_timeout 65;
server {
server_name localhost scholarsnyc.com www.scholarsnyc.com;
root /srv/www/scholarsnyc.com/public;
location / {
index index.php;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
server {
server_name data.scholarsnyc.com;
root /srv/www/data.scholarsnyc.com/public;
passenger_enabled on;
}
server {
server_name tech.scholarsnyc.com;
root /srv/www/tech.scholarsnyc.com/public;
location / {
root /srv/www/tech.scholarsnyc.com/public;
index index.php index.html index.htm;
}
}
}
Any other optimizations are also appreciated. I literally don't know what to do at this point.
© Server Fault or respective owner