Hello,
On 06/20/2017 06:17 AM, guruprasads wrote:
> Hi all,
>
> I am trying to configure 3 virtual hosts for single server with same port,
> but php is not working for all virtual hosts.
>
> My requirement is as below,
>
> IP:port-A/
> IP:port-A/local
> IP:port-A/viewer
>
> These 3 virtual hosts i want to configure, only html contents are displaying
> on browser, if i add php code its not displaying any php actions(like i
> written simply echo "guru";).
>
> below is my configuration file content.
>
> server {
>
> listen 80 default;
> listen 443 ssl;
> server_name $hostname;
> client_max_body_size 16384M;
>
> location / {
> root /opt/xxx/yyy/myweb/admin;
> index index.php index.phtml index.html index.htm;
> try_files $uri $uri/ /index.php$is_args$args;
> }
>
> location /viewer {
> root /opt/xxx/yyy/myweb/viewer;
> index index.php index.phtml index.html index.htm;
> try_files $uri $uri/ /index.php$is_args$args;
> }
>
> location /local {
> root /opt/xxx/yyy/myweb/local;
> index index.php index.phtml index.html index.htm;
> try_files $uri $uri/ /index.php$is_args$args;
> }
>
>
> location ~ \.php$ {
> root /opt/xxx/yyy/myweb/admin;
> try_files $uri =404;
> fastcgi_pass 127.0.0.1:9000;
> fastcgi_index index.php;
> fastcgi_param SCRIPT_FILENAME
> $document_root$fastcgi_script_name;
> fastcgi_split_path_info ^(.+\.php)(/.+)$;
> fastcgi_intercept_errors on;
> fastcgi_read_timeout 300;
> include fastcgi_params;
> }
>
> location ~ \.php$ {
> root /opt/xxx/yyy/myweb/viewer;
> try_files $uri =404;
> fastcgi_pass 127.0.0.1:9000;
> fastcgi_index index.php;
> fastcgi_param SCRIPT_FILENAME
> $document_root$fastcgi_script_name;
> fastcgi_split_path_info ^(.+\.php)(/.+)$;
> fastcgi_intercept_errors on;
> fastcgi_read_timeout 300;
> include fastcgi_params;
> }
>
> location ~ \.php$ {
> root /opt/xxx/yyy/myweb/local;
> try_files $uri =404;
> fastcgi_pass 127.0.0.1:9000;
> fastcgi_index index.php;
> fastcgi_param SCRIPT_FILENAME
> $document_root$fastcgi_script_name;
> fastcgi_split_path_info ^(.+\.php)(/.+)$;
> fastcgi_intercept_errors on;
> fastcgi_read_timeout 300;
> include fastcgi_params;
> }
> }
>
This configuration will never do what you expect. All PHP requests will
be handled by the first "php" location. See
http://nginx.org/en/docs/http/ngx_http_core_module.html#location.
--
Jim Ohlstein
Profesional Mailman Hosting
https://mailman-hosting.com
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx