Prev Previous Post   Next Post Next
Old 3rd January 2011, 12:05
Paladinemishakal Paladinemishakal is offline
Junior Member
Join Date: Jan 2008
Posts: 12
Thanks: 0
Thanked 1 Time in 1 Post
Default Nginx and PHP and Fastcgi

Hi All,

I am trying to migrate a website from Apache2 to Nginx. The new server is installed with Debian Lenny + Nginx 0.6.32 + PHP 5.2.6 + FastCGI.

I have the following directory structure:
1. /var/www/nginx/ - Main site
2. /var/www/nginx/ - Sub site

This is my nginx vhost config:
# Redirect to www
server {
rewrite ^(.*)$1 permanent;

server {
root /var/www/nginx/abc_production/htdocs;
index index.php;
include /etc/nginx/fastcgi.conf;

# serve static files
location ~ ^/(cache|cms|css|img|js|language|gallery)/ {
root /var/www/nginx/abc_production/htdocs;
expires 30d;

location ~ ^/cms {
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/nginx/abc_production/htdocs/cms$fastcgi_script_name;

location ~ \.php {
fastcgi_index index.php;
if ($request_filename ~ '.+\.(jpg|jpeg|gif|css|png|js|ico|html)$') { access_log off; expires 1d; }
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

access_log /var/log/nginx/abc_production-access.log main;
error_log /var/log/nginx/abc_production-error.log;

This is the problem I encounter with my current vhost config:
1. Typing the URL will get the nginx to serve the correct php file index.php in /var/www/nginx/abc_production/htdocs/index.php.
2. When I try to access, the server will serve me the raw content of the index.php file under /var/www/nginx/abc_production/htdocs/cms/.

I want to know how I can get nginx to serve me the sub site as the cms subdirectory contains the content management software to add stuffs to the main site. What is wrong with my nginx vhost config?

Reply With Quote
Sponsored Links


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP cgi wrapper created with wrong paths Norman General 4 8th December 2010 15:11
Nginx on Fedora 11 Nammut HOWTO-Related Questions 1 3rd October 2009 17:35
A few nginx questions JACOBKELL Server Operation 0 15th July 2009 16:45
What's wrong with this nginx conf? JACOBKELL Server Operation 3 19th June 2009 17:15
Nginx + Apache on Ubuntu 8.04 AdamBoyle HOWTO-Related Questions 3 10th December 2008 23:54

All times are GMT +2. The time now is 09:30.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.