Saturday, February 28, 2015

PHP (78) JavaScript, Ajax (46) windows (39) MySQL (37) C # (35) Linux (22) design patterns (19) Apa


General PHP will use the $ _SERVER ["SERVER_NAME"] obtain the domain name of the site. SERVER_NAME this value is set in the web server, Server only if a domain name is set, there will be no problem. However, if multiple aliases set in Apache and Nginx will have different results. Apache + PHP setting multiple domains, VirtualHost set in Apache, you may like this ServerName a1.example.com ServerAlias a2.example.com ServerAlias a3.example.com separate visits a1.example.com, a2.example.com, a3.example.com, $ _SERVER ["SERVER_NAME"] values are also a1.example.com, a2.example.com, a3.example.com, this seems reasonable, but it should be noted that, assuming there A domain a4.example.com orange mail can also access orange mail to the station, although the value is not set in Server a4.example.com, but the $ _SERVER ["SERVER_NAME"] will be a4.example.com Nginx + PHP same situation , the change to Nginx. Setting multiple domains, in Nginx setting might like server_name a1.example.com a2.example.com a3.example.com separate visits a1.example.com, a2.example.com, a3.example.com, $ _SERVER ["SERVER_NAME"] value will always be the first to set a1.example.com, which prior to use in apache $ _SERVER ["SERVER_NAME"] of the program, when you move Nginx, will cause a lot of problems. Nginx server_name later found the set, you can use regular expressions (Regular expression) to write, I think since Nginx will only respond to the first set value, then I put three domains written in a regular expression, only put one should You can solve it? But not from day one is willing to do so the result is, $ _ SERVER ["SERVER_NAME"] direct the regular expression is displayed. Finally, had to modify variables inside fastcgi_params profile settings will fastcgi_param SERVER_NAME $ server_name; orange mail changed fastcgi_param SERVER_NAME $ host; Reference: showing correct server_name to fcgi (php) http://nginx.org/en/docs/http/server_names .html Nginx regex vhost pattern ends up as PHP server name
Leave a message
PHP (78) JavaScript, Ajax (46) windows (39) MySQL (37) C # (35) Linux (22) design patterns (19) Apache (17) jQuery (16) C (12) C ++ (12) HTML (11 ) News (11) HTML5 (9) Zend Framework (9) Android (7) MS SQL (6) google (6) nginx (5) Git (4) memcached (4) Gadgets orange mail (4) Hardware (3) CSS (2) IIS (2) Java (2) regular expression (2) ASP.NET orange mail MVC (1) Email (1) SVN (1) VIM (1) XML (1) Zeus (1) iPhone (1)


No comments:

Post a Comment