我有一个模块化的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;
}
}