1

我正在开发新的服务器 NGINX 并且遇到了一个 php 脚本的问题,这里是脚本

$src = $_GET['src'];

header('Content-type: image/jpeg');

//watermark.png will go in root dir watermark.php?src=test.jpg watermark.png w_test.php
if (eregi("200x290", $src)) {
    $watermark = imagecreatefrompng('empty.png');
} else {
    $watermark = imagecreatefrompng('no_image.png');
}
$watermark_width = imagesx($watermark);
$watermark_height = imagesy($watermark);
$image = imagecreatetruecolor($watermark_width, $watermark_height);
if(eregi('.gif',$src)) {
$image = imagecreatefromgif($src);
}
elseif(eregi('.jpeg',$src)||eregi('.jpg',$src)) {
$image = imagecreatefromjpeg($src);
}
elseif(eregi('.png',$src)) {
$image = imagecreatefrompng($src);
}
else {
exit("Your image is not a gif, jpeg or png image. Sorry.");
}
$size = getimagesize($src);
$dest_x = $size[0] - $watermark_width - 20;
$dest_y = $size[1] - $watermark_height - 0;
imagecolortransparent($watermark,imagecolorat($watermark,0,0));
imagecopyresampled($image, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, $watermark_width, $watermark_height);

imagejpeg($image, "", 95);
imagedestroy($image);
imagedestroy($watermark);

它是一个简单的水印脚本......它在 Apache 服务器上工作但不能在 NGINX 上工作任何人都可以帮助(Apache 提供输出但 NGINX 没有结果)NGINX Conf ....

server {
    server_name xxxx.com www.xxxx.com xxxx.info www.xxxx.info;
    listen xx.xxx.xx.xx;
    root /home/xxxx/public_html;
    index index.html index.htm index.php;
    access_log /var/log/virtualmin/xxxx.com_access_log;
    error_log /var/log/virtualmin/xxxx.com_error_log;
    fastcgi_param GATEWAY_INTERFACE CGI/1.1;
    fastcgi_param SERVER_SOFTWARE nginx;
    fastcgi_param QUERY_STRING $query_string;
    fastcgi_param REQUEST_METHOD $request_method;
    fastcgi_param CONTENT_TYPE $content_type;
    fastcgi_param CONTENT_LENGTH $content_length;
    fastcgi_param SCRIPT_FILENAME /home/xxxx/public_html$fastcgi_script_name;
    fastcgi_param SCRIPT_NAME $fastcgi_script_name;
    fastcgi_param REQUEST_URI $request_uri;
    fastcgi_param DOCUMENT_URI $document_uri;
    fastcgi_param DOCUMENT_ROOT /home/xxxx/public_html;
    fastcgi_param SERVER_PROTOCOL $server_protocol;
    fastcgi_param REMOTE_ADDR $remote_addr;
    fastcgi_param REMOTE_PORT $remote_port;
    fastcgi_param SERVER_ADDR $server_addr;
    fastcgi_param SERVER_PORT $server_port;
    fastcgi_param SERVER_NAME $server_name;
    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_pass localhost:9001;
    }
    #setting error pages

     error_page    404 = /xxxx.php;

     fastcgi_intercept_errors on;

     location ~* \.(js|css|png|jpg|jpeg|gif|ico|html|htm)$ {
     expires 1y;
     log_not_found off;
    }

}
4

1 回答 1

0

问题可能是您没有正确匹配您的位置。这就是我正在使用的。

index index.php;
location ~ \.php$ {
  include /etc/nginx/fastcgi.conf;
  fastcgi_index index.php;
  fastcgi_pass    127.0.0.1:9000;
  fastcgi_cache_valid   200 302  1h;
  fastcgi_cache_valid   301      1d;
  fastcgi_cache_valid   any      1m;
  fastcgi_cache_min_uses  1;
  fastcgi_cache_use_stale error  timeout invalid_header http_500;
}
于 2012-09-08T22:37:14.333 回答