我有一個模塊化的Zend Framework應用程序,我想爲基礎,使用了幾個網站有不同的領域,即:的Nginx + Zend框架2 +運行從相同的代碼不同領域的多個網站
- mywebsite.com
- mydifferentwebsite.com
- mythirdwebsite.com
我想從同一個代碼庫,並在同一臺服務器上運行所有這些網站。我想根據主機名來更改不同的設置,例如樣式或可用頁面。
目前,這是我如何得到主機名:
$requestSiteUrl = $this->serviceLocator->get('URLRequest')->getServer('HTTP_HOST');
但是我不知道如何可靠,這將是。有沒有更好的方法來找出請求來自哪個網站?
下面是一個例子Nginx的配置我使用了不同服務器上的網站:
server {
listen 80;
server_name mywebsite.com;
root /var/www/mywebsite/public;
index index.php;
server_tokens off;
if (!-e $request_filename) {
rewrite ^.*$ /index.php last;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param APPLICATION_ENV develop;
fastcgi_param PHP_VALUE "error_log=/var/log/php/mywebsite_php_errors.log";
include /etc/nginx/fastcgi_params;
}
}