php - Setting up Wordpress and Rails in Nginx -


I have nginx set for rail applications which is working beautifully for me now I Blog.website.com to website.com/blog , so the web crawler takes it as part of this site.

I have created a symbolic link in the public / directory of my rail app and added the following to my nginx configuration:

  # rail Server server {root / project / path / current / public; Server_name project.com; Active on passenger; Rails_env production; Client_max_body_size 20m; If ($ http_x_forwarded_proto! = 'Https') {return 301 https: // $ host $ request_uri; } Location / blog {index index.html index.php; Try_files $ uri $ uri / /blog/index.php?q=$uri&$args; If (! -e $ request_filename) {rewrite ^. (? / Blog / .php) $ $ last $; Rewrite ^ /blog/index.php last; }} Place ~ \ .php $ {try_files $ uri = 404; Fastcgi_intercept_errors on; Includes fastcgi_params; Fastcgi_index index.php; Fastcgi_param SCRIPT_NAME $ fastcgi_script_name; Fastcgi_param SCRIPT_FILENAME $ document_root $ fastcgi_script_name; Fastcgi_pass Unix: /var/run/php5-fpm.sock; }}  

This works great but what I want to do is drop the symbolic link part. I want to root nginx directly in the WordPress directory I tried to convert to / blog block:

  space ^ ~ / blog {root / home / ubuntu / Apps / blog; Index index index.php; Try_files $ uri $ uri / /blog/index.php?q=$uri&$args; If (! -e $ request_filename) {rewrite ^. (? / Blog / .php) $ $ last $; Rewrite ^ /blog/index.php last; }}  

This works, as I am being redirected to the WordPress folder correctly but my server does not know what to do with php files and make them Sends files in the browser as / blog inside the place . Php $ is trying to position, but the result is a 404 error.

> What is wrong with the following piece and how to fix it?

  place ^ ~ / blog {root / home / ubuntu / apps / blog; Index index index.php; Try_files $ uri $ uri / /blog/index.php?q=$uri&$args; If (! -e $ request_filename) {rewrite ^. (? / Blog / .php) $ $ last $; Rewrite ^ /blog/index.php last; } Location ~ \ .php $ {try_files $ uri = 404; Fastcgi_intercept_errors on; Includes fastcgi_params; Fastcgi_index index.php; Fastcgi_param SCRIPT_NAME $ fastcgi_script_name; Fastcgi_param SCRIPT_FILENAME $ document_root $ fastcgi_script_name; Fastcgi_pass Unix: /var/run/php5-fpm.sock; }}  

I have not fixed the snippet from the question, but I managed to solve Problem with nginx configuration without using symbolic links using two server blocks.

  server {location / {proxy_pass http: // localhost: 82 /; } Location / Blog {root / var / proj / blog / current; Fastcgi_intercept_errors on; Includes fastcgi_params; Fastcgi_index index.php; Fastcgi_param SCRIPT_NAME $ fastcgi_script_name; Fastcgi_param SCRIPT_FILENAME $ document_root $ fastcgi_script_name; Fastcgi_pass Unix: /var/run/php5-fpm.sock; }} #Rail Server Server {82; Root / var / proj / site / current / public; Server_name site.com; Active on passenger; Rails_env staging; Client_max_body_size 20m; # Other configuration}  

Comments