Hi Guys,
I have installed nginx 1.2.2, php and mysql on my Ubuntu 11.10 VPS
To install wordpress on my vps I made the following configurations:
1. created a directory for my wordpress site:
Code:
/home/username/public_html/mysite
2. created a virtual host file for my wordpress site at:
/usr/local/nginx/sites-available/mysite, with the following contents:
Code:
server {
listen SERVER_NAME:80;
server_name SERVER_NAME;
access_log /home/username/public_html/mysite/logs/access.log;
error_log /home/username/public_html/mysite/logs/error.log;
location / {
root /home/username/public_html/mysite/;
index index.php index.html;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ \.php$
{
try_files $uri =404;
fastcgi_pass 127.0.0.1:9000;
#fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
#Prevent php version info leakage
fastcgi_hide_header X-Powered-By;
}
}
3. And added symlink using:
Code:
sudo ln -s /usr/local/nginx/sites-available/mysite /usr/local/nginx/sites-enabled/mysite
4. restarted the nginx server using:
service nginx restart
5. To test the proper functioning, I created two files in the root dir (
/home/username/public_html/mysite/)
foo.html and bar.php
Now when I enter in the browser
http://MyVPSIP/foo.html it works perfectly but when I enter
http://MyVPSIP/bar.php instead of the php output I get a 404 Not Found Error
This means that nginx is not passing the PHP scripts to FastCGI server listening on 127.0.0.1:9000
Whereas I don't get this problem when working with php scripts in the nginx web root directory
I don't understand why I'm getting this problem
Please help me out
Thanks a lot