Welcome! Log In Create A New Profile

Advanced

Can't get php applications to work in web root (/var/www)?

Posted by davidlondonuk 
Can't get php applications to work in web root (/var/www)?
July 24, 2011 06:39PM
Hi,

If I try to run php applications located in web root (/var/www) they just won't work-they either get 404 page or mainly 'no input file' error. I tried to get phplist working, but it would be the same for any app placed in /var/www.

My default vhost is:

server {
server_name 192.168.0.150;

location / {
root /var/www;
}

#php
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/tmp/php.socket;
include fastcgi_params;
}

#status and stats
location /nginx_status {
stub_status on;
access_log off;
allow 192.168.0.0/16;
deny all;
}

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}

This works for sites I have setup via dyndns: the vhosts I put to together from the info on the nginx wiki for a drupal and wordpress site work, however- if I try to set the default server_name to localhost or use anything but the server ip address, all the sites stop working due to dns.

How do I setup a php application in /var/www so that nginx can find it? I cant use the server ip again, it's already been used in the default vhost? How would I set things up if I wanted 3 or 4 php applications like phplist in /var/www? If phplist is in /var/www/phplist on the server (192.168.0.150) what vhost do I use?

As you can tell, I'm a bit stumped after a few hours of messing around-this should have been easy but I can't see where I'm going wrong.

Thanks for any help.
Re: Can't get php applications to work in web root (/var/www)?
July 25, 2011 03:16AM
[SOLVED]

As usual the answer was simple and staring me in the face. By defining the root of /var/www in a location instead of in the server section, nginx did not know how to find anything-this simple change in the default vhost solved the problem:

server {
server_name 192.168.0.150;
root /var/www;

location / {
try_files $uri $uri/ /index.php;
}
...........

Thanks to this site for making it easy to understand: http://blog.martinfjordvald.com/2010/07/nginx-primer/
Re: Can't get php applications to work in web root (/var/www)?
July 28, 2011 06:40AM
how solved ?
Re: Can't get php applications to work in web root (/var/www)?
July 28, 2011 06:46AM
i have same problem
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 214
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