Welcome! Log In Create A New Profile

Advanced

Problems with PHP and Virtual Hosts

Posted by jgothtx 
Problems with PHP and Virtual Hosts
October 13, 2011 11:18AM
I am having a problem with PHP and virtual hosts on Nginx. See below for config. Site 1 works perfectly. But, for the default site, the PHP file is downloaded to the browser rather than executed.

Any ideas?


nginx.conf
------------------------------------------------


worker_processes 1;

events {
worker_connections 1024;
}


http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;

server {
listen 80 default;
server_name _;
root /path_to_default;
index iindex.php ndex.html ;

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME /path_to_default$fastcgi_script_name;
}
}


# Site 1
#
server {
listen 80;
server_name site1;
root /path_to_site1;
index index.php index.html ;

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME /path_to_site1$fastcgi_script_name;
}
}
}
Re: Problems with PHP and Virtual Hosts
October 13, 2011 11:19AM
Please ignore the iindex.php ndex.html; error. That was a cut and paste problem. The config file is correct:

index index.php index.html ;



Edited 1 time(s). Last edit at 10/13/2011 11:19AM by jgothtx.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

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