For the past year I have worked on a complicated web app that consists of three machines.
Machine 1 runs nginx.
machine 2 (11.22.333.32) (Runs pm2 / node only)
machine 3 (123.123.11.00) (runs pm2 / node only)
yoururl.com/canvas points to machine 2 and it handles those requests
yoururl.com/admin points to machine 3 and it handles those requests.
Recently I have been tasked with pointing yoururl.com/account to a new machine 4 (222.11.56.32) that runs php
What i've done so far is create a fresh ubuntu 14.04 install and did the following commands:
apt-get install php5
apt-get install php5-fpm
Then I created an index.php file in /home on machine 4
Every guide I run across seems to need nginx and php-fpm on the same machine. Do I need to run nginx in machine 4 as well as php-fpm? I feel like that is unnecessary, that is why I'm asking your guys help to guide me in the right direction on accomplishing this. Below is my attempt, any guidance even links to relevant guides, would be appreciated
server {
listen 80;
listen [::]:80;
server_name yoururl.com www.yoururl.com;
client_max_body_size 10M;
location /canvas {
proxy_pass http://11.22.333.32:8080;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
location /admin {
proxy_pass http://123.123.11.00:8080;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
location /account {
index index.html index.htm index.php;
include /etc/nginx/fastcgi_params;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param SCRIPT_FILENAME /home/index.php;
fastcgi_pass 222.11.56.32:9000;
}
}
Also is there a way to go to http://222.11.56.32:9000 in a browser and view the php site with just php5 / phpfpm installed and not nginx or apache?
It is usual to run nginx
and php-fpm
on the same machine simply because most applications have static content as well as dynamic content which is collocated within the same document root.
But if you had an application which was dynamic only (only PHP files), then the front-end nginx
instance is quite capable of reaching over to a back-end php-fpm
instance using FastCGI over TCP/IP.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.