nginx + apache subdomain question
I'm trying to figure out the best way to create subdomains with this type of setup. The only way I could think of was to send requests to a subdomain over a different port listened on by apache, but I've been told that apache will create a new instance for each port listened on (though I'm not sure of this?). Is there a better way to do this?
2 Replies
Unless you have a specific need to have both nginx and apache running at the same time, I wouldn't recommend doing that. There are reasons for having both running, but it will take up more resources on your Linode, and you're just adding an extra layer to your software. You basically will have nginx sending the php to apache, which will load a module to connect to php, which will then send the php files to php, then back to apache, then back to nginx. If you use something like fastcgi or php-fpm in nginx, you will apache from this. You'll still have a module being loaded to bridge nginx to php, but that module will be used by nginx directly rather than sending it to apache first in order to use it.
For the original question, I usually just pass the Host: header along and use virtual hosting on the back-end web server.